Started by
Cheezy_Amuzus
on
Topic category: Help with Minecraft modding (Java Edition)
Hi, first post on the forum (i think) and I was able to do a lot of advanced modding in MCreator but I'm having an issue figuring out how to make it so when a block is mined, or mob is killed with an item that has an enchantment I made, it teleports the drops to the player's inventory. I've gotten everything else done except I'm stuck on the part where it finds out the normal drops for the mob or block so it can set it in the player's inventory.
Btw I found out how to teleport blocks to inventory when mined but not drops. For example, when you mine stone it teleports the stone into your inventory not cobblestone which is what it should drop.
you could then remove one stone from the inventory and give the player a cobblestone
And how did you make sure the actual drop doesn't get picked up by the player?
For your first question: So I have to code all the alternate drops for each block? Well, what if someone uses the enchantment on pickaxe with a block in other mods?
For your second question: I break the block in the event because based on what I've seen when triggered with "when a block is broken" it runs the event specifically before the block is officially broken. So I just get the drop of the block that was mined and import it into the player's inventory and then the last event destroys the block and turns it into an air block before it can officially be "broken" so it doesn't drop anything. On the player's screen it seems seamless and it looks normal. If you want me to send my code I can.
For your first question: So I have to code all the alternate drops for each block? Well, what if someone uses the enchantment on pickaxe with a block in other mods?
For your second question: I break the block in the event because based on what I've seen when triggered with "when a block is broken" it runs the event specifically before the block is officially broken. So I just get the drop of the block that was mined and import it into the player's inventory and then the last event destroys the block and turns it into an air block before it can officially be "broken" so it doesn't drop anything. On the player's screen it seems seamless and it looks normal. If you want me to send my code I can.
Ok, but I think people would understand if different mods won't compile with each other, otherwise you might have to code to access the code? (Don't ask me how, I cannot code.)
I know this would be really painstaking process but it actually wouldn't take that long to code in every block in minecraft because
1. Not all of them are mineable
2. You can just copy&paste the code and change the input and output.
if you are looking at mobs it gets pretty complicated. You can quickly place fire where they stood to burn the loot and turn it to air again? it would only take a tick or two so it wouldn't be really recognisable. it wouldn't work in water but that is the only suggestion I have. For the actual drop for the player you need to look at the minecraft wiki for the loot table and drop rate.
After some thought, you don't even have to code most of it. You already know how to get the blocks into the player's inventory. You just need to specify on the few blocks including leaves, coal, diamonds, stone, crops, sea lanterns, etc. There is a much shorter list of that, and won't take you long.
Hey can u send the code