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

Started by Guillesahu07 on

Topic category: Help with MCreator software

Last seen on 18:08, 13. Sep 2021
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I make a block randomly drop between two items when broken?

 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 01:42, 12. Feb 2024
Joined Jul 2017
Points:

User statistics:

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

you need simple procedures

Last seen on 18:08, 13. Sep 2021
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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 14:30, 2. Aug 2022
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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.