Cannot use Random
Gu-meng opened this issue ยท 1 comments
Issue description
import crafttweaker.api.util.Random;
Random.nextInt();
After running, this will result in :No compatible methods found!
Steps to reproduce
import crafttweaker.api.util.Random;
Random.nextInt();
Script used
2:0: No compatible methods found!
The crafttweaker.log file
2:0: No compatible methods found!
Minecraft version
1.16
Modloader
Forge
Modloader version
36.2.39
CraftTweaker version
7.1.2.527
Other relevant information
No response
The latest.log file
.
The nextInt method, and all the methods on random are instance methods, not static methods, so you need an instance of Random to use them.
In nearly all the places that you could actually make use of a random number, you can get the random number from the world, either you have a world passed in, or you can get the world from an entity using entity.world
.