Destructor needs to call the block break event
This commit is contained in:
@@ -26,8 +26,12 @@ import net.minecraft.network.datasync.DataSerializers;
|
|||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
@@ -140,16 +144,20 @@ public class TileDestructor extends TileMultipartNode implements IComparable, IF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
worldObj.playEvent(null, 2001, front, Block.getStateId(frontBlockState));
|
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(worldObj, front, frontBlockState, FakePlayerFactory.getMinecraft((WorldServer) worldObj));
|
||||||
worldObj.setBlockToAir(front);
|
|
||||||
|
|
||||||
for (ItemStack drop : drops) {
|
if (!MinecraftForge.EVENT_BUS.post(e)) {
|
||||||
// We check if the controller isn't null here because when a destructor faces a node and removes it
|
worldObj.playEvent(null, 2001, front, Block.getStateId(frontBlockState));
|
||||||
// it will essentially remove this block itself from the network without knowing
|
worldObj.setBlockToAir(front);
|
||||||
if (network == null) {
|
|
||||||
InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), drop);
|
for (ItemStack drop : drops) {
|
||||||
} else {
|
// We check if the controller isn't null here because when a destructor faces a node and removes it
|
||||||
network.insertItem(drop, drop.stackSize, false);
|
// it will essentially remove this block itself from the network without knowing
|
||||||
|
if (network == null) {
|
||||||
|
InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), drop);
|
||||||
|
} else {
|
||||||
|
network.insertItem(drop, drop.stackSize, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user