This has the obvious disadvantage, that you'll need one entity per possible score. 5: Range: (theoretically infinite, but practically anything above 10 is not worth it)īefore we got the (arguably much better) solutions above, we could use minecrafts to select a random entity, which we would've each given their respective scoreboard score (or put the commandblock to be triggered below them or something similar). It's very much deprecated now though, thanks to Number 2 in this list. 4: item rotationĪ way to get a random number before 1.13 in the range of up to 360 numbers was to summon an entity like a squid, kill it and check the rotation of the inksac item entity it just dropped, since that rotation is always random. Use only for smaller amounts of values and if methods 1 and 2 don't work for you. The third best option, with a small effective range. run loot spawn ~ ~ ~ loot example:random_loot_table Use only if Method 1 doesn't work for you or if you need a specifc player to always get the same random number (their uuid doesn't change). More taxing on the server due to it's creation and removal of entities as well as NBT access, so better limit its use as much as possible. Scoreboard players operation random %= range 1/10 chance like this: Įxecute store result score random run data get entity UUID 1 A simple predicate can be used to run something with an e.g. Have something happen with a random chanceįor this special case, you don't need any of the random number methods, thanks to 1.15's predicates. the first two are arguably the best as they have the least limitations and require the least work to set up. There are many ways to get a random number in minecraft. This likely won't affect your contraption, but it's important to point out. ![]() They will be refered to "random" generator for simplicity. They are all only "pseudo"-random (which means they only feel like they are random to a human, but are using some form of deterministic algorithm behind the scenes) because that's how computers work. In Bedrock, you can just use scoreboard players random to get a random number into your scoreboard and don't need to go through all this hassle.ĭisclaimer: None of these numbers are truly random. This article talks about the Java Edition of the game. ![]() Have something happen with a random chance.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |