Posted January 18, 201510 yr Is random class makes like a probability and chances method ? like random.nextint(20) <---------- is 20 like 20 % chance or a loop between 1 - 20? thankyouu
January 18, 201510 yr Not sure if this can help you at al but i used a random code in one of my other mods. Setting 2 ints out of 10 is same as a 20% chance. Random randomGenerator = new Random(); int randomBlock = randomGenerator.nextInt(10); if (randomBlock == 0) {world.setBlock(x, y, z, CreativeBlocks.RedBlock.blockID); } if (randomBlock == 1) {world.setBlock(x, y, z, CreativeBlocks.BlueBlock.blockID); } if(randomBlock == 2) {world.setBlock(x, y, z, CreativeBlocks.GreenBlock.blockID); } if(randomBlock == 3) {world.setBlock(x, y, z, CreativeBlocks.YellowBlock.blockID); } if(randomBlock == 4) {world.setBlock(x, y, z, CreativeBlocks.LBlueBlock.blockID); } if(randomBlock == 5) {world.setBlock(x, y, z, CreativeBlocks.BrownBlock.blockID); } if(randomBlock == 6) {world.setBlock(x, y, z, CreativeBlocks.GrayBlock.blockID); } if(randomBlock == 7) {world.setBlock(x, y, z, CreativeBlocks.PurpleBlock.blockID); } if(randomBlock == {world.setBlock(x, y, z, CreativeBlocks.OrangeBlock.blockID); } if(randomBlock == 9) {world.setBlock(x, y, z, CreativeBlocks.PinkBlock.blockID); } //20% if(randomBlock == 10) {world.setBlock(x, y, z, CreativeBlocks.PinkBlock.blockID); } //20%
January 18, 201510 yr Author Ahh ok i get somehow it similar for the ones i had in wc3 modding , thanks
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.