Started by
Bloodshot_pico
on
Topic category: Help with Minecraft modding (Java Edition)
Help With Leaf Decay Dropping Mod Items
Hello so I was wondering how would one make it so that certain leaves within vanilla drop certain items and give them percentages? I'm not sure if this would be too advanced but I'm not sure honestly. I'm guessing it would be a little bit of code though. I just don't see an option in the events for anything I'm guessing it would be a global event but I just looked and there's nothing about leaf decay or anything about blocks. So I have no idea. :/
Anyhow I'd basically want another apple to be dropped from others leaves in the game, that is what I'm going after.
If anyone is able to help that would be appreciated, thanks for reading. :)
~Blood
Hello.
What you most likely want to do is hook to the BlockEvent.HarvestDropsEvent.
There is not quite, unfortunately, any direct support by MCreator for this, but nothing stops you from doing it manually.
First, you need some EventHandler class. From the name you can guess that it is basically a class, that listens for events and handles actions what should happen, when they are fired.
Fortunately, there is already one element type in MCreator, that provides you registred EventHandler - Overlay. So simply just create a new empty Overlay element.
Then open its code and remove everything in the eventHandler void, so you will get something like this:
You have to listen for the correct event, so replace RenderGameOverlayEvent by BlockEvent.HarvestDropsEvent.
Now the code is ready for adding the actual logic of dropping the apples.
First, you need to check the leaves block. This is one of many possible ways to do it:
(NOTE: This will check for any variants of Blocks.LEAVES - Oak, Birch, Spruce, Jungle. You may want to check for the variant.
Dark Oak and Acacia are stored in Blocks.LEAVES2)
The final step is adding the actual drop.
That is as easy as this code:
At the end, you should end up with something like this:
And that's it. This code should work, hopefully.
So how would I do this with entities?