- check_circle Advancements
- check_circle Functions
- 924 views, 1 today
- 20 downloads, 0 today
10
NOTE: I am moving this library to 1.17. This page will remain as the 1.16 version, but will no longer receive updates.
This is a utility library for math, list operations, and other random stuff. It's starting as just things I need for other projects, but I am open to requests to add functions to it.
It is worth noting that like most programming languages, lists in Minecraft start at index of 0.
Warning: Do Not run any functions from the folder internal - these are used by functions for internal purposes, and the results may not be what you expect.
To remove the pack, call the function m.util:uninstall
Currently m.util has:
List functions:
Math functions:
Misc/other:
Usages
List slice:
List splice:
List shuffle:
List length:
List merge:
Replace By Index:
Get Index Of:
Min:
Max:
Random generator:
Custom Damage:
Note: For accuracy purposes (up to 3 decimal places) multiply your number by 1000. Thus to deal 1 heart of damage (2 points) you want the number 2000.
If you have any suggestions/needs/requests for other features, please tell me! I fully intend to add more to this library, both things I need and feasible requests I receive.
This is a utility library for math, list operations, and other random stuff. It's starting as just things I need for other projects, but I am open to requests to add functions to it.
It is worth noting that like most programming languages, lists in Minecraft start at index of 0.
Warning: Do Not run any functions from the folder internal - these are used by functions for internal purposes, and the results may not be what you expect.
To remove the pack, call the function m.util:uninstall
Currently m.util has:
List functions:
- Slice - Slices an array
- Splice - Splices an array
- Shuffle - Shuffles an array
- Get Length - Gets the length of an array
- Merge 2 arrays - Merges 2 arrays together
- Replace by Index - replaces a single entry in the list, with the index as a score
- Get Index Of - gets the index of the first occurrence of the specified item, returning -1 if the item is not in the list
Math functions:
- Min function - Returns the smaller of 2 numbers
- Max function - Returns the larger of 2 numbers
- Random number generator - Generates a random number between a min and max (inclusive)
Misc/other:
- Custom damage support (Deals custom damage to entities or players)
Usages
List slice:
- Set storage util list1 to the list you wish to slice from
- Set score util.begin on player util to the index you wish to start from
- Set score util.number on player util to the number of items you wish to take
- Run function m.util:list/slice
- The sliced section will be in storage util out
List splice:
- Set storage util list1 to the list you wish to splice from
- Set score util.begin on player util to the index you wish to start from
- Set score util.number on player util to the number of items you wish to splice out
- Run function m.util:list/splice
- The resulting list will be in storage util out
List shuffle:
- Set storage util list1 to the list you wish to shuffle
- Run function m.util:list/shuffle
- The shuffled list will be in storage util out
List length:
- Set storage util list1 to the list you wish to get the length of
- Run function m.util:list/length
- The length of the list will be in the score util.out on player util
List merge:
- Set storage util list1 to the list you wish to merge into
- Set storage util list2 to the list you wish to merge from
- Set the score util.begin on player util to the index you wish list2 to start at
- Run function m.util:list/merge
- Your output will be in storage util out
Replace By Index:
- Set storage util list1 to the list you wish to edit
- Set storage util item1 to the item you wish to replace into it
- Set the score util.begin on player util to the index of the item you wish to replace
- Run function m.util:list/replacebyindex
- Your output will be in storage util out
Get Index Of:
- Set storage util list1 to the list you wish to search
- Set storage util item1 to the item you wish to search for
- Run function m.util:list/getindexof
- The index of the first occurrence of the item will be in the score util.out on player util - with a score of -1 if the item is not in the array
Min:
- Set score util.item1 on player util to the first number
- Set score util.item2 on player util to the second number
- Run function m.util:math/min
- The smaller number will be copied to the score util.out on player util
Max:
- Set score util.item1 on player util to the first number
- Set score util.item2 on player util to the second number
- Run function m.util:math/max
- The larger number will be copied to the score util.out on player util
Random generator:
- Set score util.min on player util to the lower bound of the random
- Set score util.max on player util to the upper bound of the random
- Run function m.util:math/randomgen
- The resulting number will be on score util.out on player util
Custom Damage:
- Set the score util.damage on the entity you wish to damage to a positive number - this number, divided by 1000, will be the damage dealt (and the score will be reset).
Note: For accuracy purposes (up to 3 decimal places) multiply your number by 1000. Thus to deal 1 heart of damage (2 points) you want the number 2000.
If you have any suggestions/needs/requests for other features, please tell me! I fully intend to add more to this library, both things I need and feasible requests I receive.
Compatibility | Minecraft 1.16 |
Tags |
1 Update Logs
Infinity : by WeaverSong 04/02/2021 2:16:31 pmApr 2nd, 2021
- Added Replace By Index function
- Added Get Index Of function
- All list functions now support lists of infinite length!
5036123
119
Create an account or sign in to comment.