How can I make a block randomly drop between two items when broken?

Started by Guillesahu07 on Sun, 09/20/2020 - 20:33

Topic category: Help with MCreator software

Last seen on 18:29, 20. Mar 2021
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How can I make a block randomly drop between two items when broken?
Sun, 09/20/2020 - 20:33

 Hi. I am making a mod I am doing leaves for a tree. How can I make it so that when I break them there is a chance that you get a sapling or the fruit I added? Also please tell me how to make the leaves properties like getting the block with shears and breaking themselves if there are no nearby logs. Thank you.

Last seen on 13:57, 17. Apr 2021
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
you need simple procedures
Sun, 09/20/2020 - 22:57

you need simple procedures

Last seen on 18:29, 20. Mar 2021
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Ok, if they are simple…
Mon, 09/21/2020 - 05:47

Ok, if they are simple explain them to me or put a photo please.

Last seen on 10:45, 10. May 2021
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Something like this should…
Fri, 10/23/2020 - 21:15

Something like this should work:

https://drive.google.com/file/d/1HXqzbH5FPvUVmtWz7ERHTU9TPalJiJhJ/view?usp=sharing

When a block is broken, check if its the block you want, and if so cancel the event so that the natural block drop doesn't get dropped. Then, remove the block anyways, and randomly spawn an item to be the new drop. In this example I give dirt a 10% chance to drop grass and otherwise it drops dirt, but you could easily change this to be any other items and any other percentage. I also check if the player who broke the block is in not in creative, but that's optional.