use of forestry.arboriculture.blocks.BlockForestryLeaves in project ForestryMC by ForestryMC.
the class ModuleArboriculture method onHarvestDropsEvent.
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
IBlockState state = event.getState();
Block block = state.getBlock();
if (block instanceof BlockLeaves && !(block instanceof BlockForestryLeaves)) {
EntityPlayer player = event.getHarvester();
if (player != null) {
ItemStack harvestingTool = player.getHeldItemMainhand();
if (harvestingTool.getItem() instanceof ItemGrafter) {
if (event.getDrops().isEmpty()) {
World world = event.getWorld();
Item itemDropped = block.getItemDropped(state, world.rand, 3);
if (itemDropped != Items.AIR) {
event.getDrops().add(new ItemStack(itemDropped, 1, block.damageDropped(state)));
}
}
harvestingTool.damageItem(1, player);
if (harvestingTool.isEmpty()) {
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, harvestingTool, EnumHand.MAIN_HAND);
}
}
}
}
}
Aggregations