diff --git a/api/buildcraft/api/events/BlockPlacedDownEvent.java b/api/buildcraft/api/events/BlockPlacedDownEvent.java index cc5f2d9a..47cd5c3f 100644 --- a/api/buildcraft/api/events/BlockPlacedDownEvent.java +++ b/api/buildcraft/api/events/BlockPlacedDownEvent.java @@ -11,11 +11,14 @@ import cpw.mods.fml.common.eventhandler.Event; public class BlockPlacedDownEvent extends Event { public EntityPlayer player; public Block block; - public int meta; + public int meta, x, y, z; - public BlockPlacedDownEvent(EntityPlayer player, Block block, int meta) { + public BlockPlacedDownEvent(EntityPlayer player, Block block, int meta, int x, int y, int z) { this.player = player; this.block = block; this.meta = meta; + this.x = x; + this.y = y; + this.z = z; } } diff --git a/api/buildcraft/api/events/RobotPlacementEvent.java b/api/buildcraft/api/events/RobotPlacementEvent.java new file mode 100644 index 00000000..52c2fcc5 --- /dev/null +++ b/api/buildcraft/api/events/RobotPlacementEvent.java @@ -0,0 +1,26 @@ +package buildcraft.api.events; + + +import net.minecraft.entity.player.EntityPlayer; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + +/** + * Copyright (c) 2014, AEnterprise + * http://buildcraftadditions.wordpress.com/ + * Buildcraft Additions is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://buildcraftadditions.wordpress.com/wiki/licensing-stuff/ + */ +@Cancelable +public class RobotPlacementEvent extends Event { + public EntityPlayer player; + public String robotProgram; + + public RobotPlacementEvent(EntityPlayer player, String robotProgram) { + this.player = player; + this.robotProgram = robotProgram; + } + +} diff --git a/common/buildcraft/core/BlockBuildCraft.java b/common/buildcraft/core/BlockBuildCraft.java index 399ef74a..89a76ea0 100644 --- a/common/buildcraft/core/BlockBuildCraft.java +++ b/common/buildcraft/core/BlockBuildCraft.java @@ -44,7 +44,7 @@ public abstract class BlockBuildCraft extends BlockContainer { @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { super.onBlockPlacedBy(world, x, y, z, entity, stack); - FMLCommonHandler.instance().bus().post(new BlockPlacedDownEvent((EntityPlayer) entity, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z))); + FMLCommonHandler.instance().bus().post(new BlockPlacedDownEvent((EntityPlayer) entity, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z), x, y, z)); TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileBuildCraft) { ((TileBuildCraft) tile).onBlockPlacedBy(entity, stack); diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 25f61d12..4069a58f 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -48,6 +48,7 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.BCLog; import buildcraft.api.core.BlockIndex; +import buildcraft.api.events.BlockInteractionEvent; import buildcraft.api.events.PipePlacedEvent; import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.IGateExpansion; @@ -714,6 +715,11 @@ public class BlockGenericPipe extends BlockBuildCraft { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) { super.onBlockActivated(world, x, y, z, player, side, xOffset, yOffset, zOffset); + BlockInteractionEvent event = new BlockInteractionEvent(player, this); + FMLCommonHandler.instance().bus().post(event); + if (event.isCanceled()) { + return true; + } world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock);