From 37d2aa89682a6305ff9df6ed5b3aa2d9b0a06610 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 22 Nov 2015 23:02:59 +0100 Subject: [PATCH] Made Drill fire Block Breaking Event --- .../ellpeck/actuallyadditions/util/WorldUtil.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java index 7dfd6bae3..b8a151fc1 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java @@ -29,8 +29,10 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fluids.*; import java.util.ArrayList; @@ -350,6 +352,14 @@ public class WorldUtil{ //If the Block can be harvested or not boolean canHarvest = block.canHarvestBlock(player, meta); + //Send Block Breaking Event + if(player instanceof EntityPlayerMP){ + BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP)player).theItemInWorldManager.getGameType(), (EntityPlayerMP)player, xPos, yPos, zPos); + if(event.isCanceled()){ + return false; + } + } + if(!world.isRemote){ //Server-Side only, special cases block.onBlockHarvested(world, xPos, yPos, zPos, meta, player); @@ -381,7 +391,9 @@ public class WorldUtil{ if(!world.isRemote){ //Update the Client of a Block Change - ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(xPos, yPos, zPos, world)); + if(player instanceof EntityPlayerMP){ + ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(xPos, yPos, zPos, world)); + } } else{ //Check the Server if a Block that changed on the Client really changed, if not, revert the change