- check_circle Functions
Published May 20th, 2020, 5/20/20 7:18 am
- 3,020 views, 1 today
- 86 downloads, 0 today
8
Lib.Random (Random Number Generator) Minecraft Developer Library.
Lib.Random (also Random Class)is Minecraft new way to generate a random chance by function commands. For someone who already learning code, Random Class is almost the same as Java.util.Random in Java or Random in Python. The main objective of this data pack is to create a number from your range of numbers.
Documents
Variable
Name | Type | Display Name | Note |
random | dummy | - | - |
Function
Function | Description | Target | Command | Command Comment |
random:next/x | Set score random randomly from the range 1 to x. | @s | /function random:next/x | replace x by your number (1-100) |
random:reset | Reset random entities. | - | /function random:reset | |
random:create | Create random entities. | - | /function random:create | |
random:setup | Create "random" variable from the scoreboard. | - | /function random:setup | already create on import |
Note: random:reset and random:create are part functions. They are no need to use for the normal circumstance.
Tutorials and Guides
This data pack, the target of the random is @s which mean you can target your own entity. If you just type command
/function random:next/x
for example:/function random:next/10
When you set scoreboard random as sidebar, you will see a random number generated randomly.However, if you put the previous command in command block, it definitely not work because the command block has no target as @s. What you need to do is put execute command to dedicate the target so you need to type (in command block)
execute as <target> run function random:next/x
for example:execute as @p run function random:next/69
The random number will create in range 1 to 69 for the nearest play(@p).To set random in another scoreboard variable, you just need to use equal operation in scoreboard command.
/scoreboard players operation @s <Your Scoreboard> = @s random
for example:/function random:next/10
/scoreboard players operation @s killPoint = @s random
The random number will create in range 1 to 10 and put into scoreboard killPoint instead. or adding point to your scoreboard by/function random:next/20
/scoreboard players operation @s gold += @s random
The random number will create in range 1 to 20 and add into scoreboard gold.There are many more ways to use. Just try to apply to your problem.
Installation
1. Put "lib.random" into <your save folder>/datapacks.
2a. If you are currently in your world, type command
/reload
2b. If you are not currently in your world, it will automatically be installed as you load your world. if not, do 2a.3. If it has succussed, the text "rib.random imported" will appear in chat box.
Note: Data packs format is 5 and never test on another version so it should work well on 1.15 or later.
Usage
This is open-source data pack so use as your will. Just do not replicate and do not use for direct profiting.
Compatibility | Minecraft 1.15 |
to | Minecraft 1.16 |
Tags |
4605312
119
Create an account or sign in to comment.