PSmithgamer Posted July 28, 2015 Share Posted July 28, 2015 I'm currently making a leaf block for my tree - but so far when ever the leaf block is broken it drops both the block and the mango so I need it to only drop the mango if its broken by hand and only the leaf if its broken by shears! Second thing, if anyone knows how I can make the leaves decay like a on a normal tree that will be fantastic. I'm sorry if this is something simple, I'm still learning Java and Forge. (code is in my event handler class) @SubscribeEvent public void checkLeave(BlockEvent.HarvestDropsEvent event) { if(event.state.getBlock() == AlkiaBlocks.mango_leaves) { event.drops.remove(AlkiaBlocks.mango_leaves); event.drops.add(new ItemStack(AlkiaItems.Mango)); } } Quote Link to comment Share on other sites More sharing options...
Earthcomputer Posted July 28, 2015 Share Posted July 28, 2015 Override the method getItemDropped in the block class Quote catch(Exception e) { } Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em). Link to comment Share on other sites More sharing options...
Failender Posted July 28, 2015 Share Posted July 28, 2015 Events are ONLY for things that are out of your control (vanilla) dont use Them for your own Blocks, there are Methods to overwrite to control The behaviour Quote Link to comment Share on other sites More sharing options...
PSmithgamer Posted July 28, 2015 Author Share Posted July 28, 2015 Override the method getItemDropped in the block class I'm such a noob to ask this but how would one do this? I've had an attempt and so far it say it doesn't want the @Override > package com.PSmithgamer.Alkia.blocks; import java.util.Random; import java.lang.Override; import com.PSmithgamer.Alkia.init.AlkiaItems; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class mango_leaves extends Block{ public mango_leaves(Material materialIn) { super(materialIn); this.setStepSound(soundTypeGrass); this.setHardness(1); this.setHarvestLevel("shears", 3); this.getItemDropped(); } //@Override public Item getItemDropped() { return AlkiaItems.Mango; } } Quote Link to comment Share on other sites More sharing options...
PSmithgamer Posted July 28, 2015 Author Share Posted July 28, 2015 Events are ONLY for things that are out of your control (vanilla) dont use Them for your own Blocks, there are Methods to overwrite to control The behaviour ah thanks for clearing that up for me! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.