Random Drops

Started by Newbie23 on Sat, 11/21/2015 - 02:06
Last seen on 06:57, 23. Nov 2015
Joined Nov 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Random Drops
Sat, 11/21/2015 - 02:06

Hello,
I didn't find any example on the Wiki, so i want to ask you. Is there a way to let a block (when mined) drop a random value of Items? Like a Redstone Ore.

Thanks for answers,

Newbie23.

Last seen on 01:08, 17. Aug 2018
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
The easiest way how to make
Sat, 11/21/2015 - 09:30

The easiest way how to make random amount of drop is:

View source of your block. On the end is this line:
 

public int quantityDropped(Random par1Random){
return 1;
}

}

 

And there the return 1; change to return 1 +(int)(Math.random()*7);

The 1 is minimal amount of drop.

The 7 is maximal amout drop - minimal drop so in this example is maximal drop 8.