Posted October 2, 201510 yr Hi, got a problem. I need to change the drops of a modded item. I know, I can access the HarvestDropsEvent event, so I can do something like this: public void onHarvestDropsEvent(HarvestDropsEvent event) { if(event.block.toString().contains("net.minecraft.block.BlockOldLog")) { event.drops.clear(); event.drops.add(new ItemStack(Items.stick, random.nextInt(3)+1)); } } When I break wood, I get a few sticks instead of the wood logs. That works! But now I want to drop a modded item. How can I spawn it when I only got the name of it and not the actual class? Thank you!
October 2, 201510 yr don't check against the string, check against the Item class, public void onHarvestDropsEvent(HarvestDropsEvent event) { if(event.state.getBlock() == Blocks.log) { event.drops.clear(); event.drops.add(new ItemStack(Items.stick, random.nextInt(3)+1)); } } same idea for your own modded item, make sure you have a public static variable to your item such as public static Item sharpstick = new SharpStick(); (where the class SharpStick extends Item) then you add it using your main Mod class public void onHarvestDropsEvent(HarvestDropsEvent event) { if(event.state.getBlock() == Blocks.log) { event.drops.clear(); event.drops.add(new ItemStack(Items.stick, random.nextInt(3)+1)); event.drops.add(new ItemStack(ModClass.sharpstick, random.nextInt(3)+1)); } }
October 2, 201510 yr Author Thank you! But for that I need to include the modded class. I want to find a way around this.
October 2, 201510 yr Thank you! But for that I need to include the modded class. I want to find a way around this. little confused about what you mean... if you want to drop a mod item, then the mod has to be included, you cant drop something that doesn't exist
October 2, 201510 yr Author The item is registered under a name in the system. When this item exists can I pull it from there?
October 2, 201510 yr Gameregistry has a method for that. I think it was Gameregistry#findItem. Check ur ide
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.