From f23102c96e456b7983dcb707847fc6a1690b01a2 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Fri, 27 Nov 2015 00:05:52 -0500 Subject: [PATCH] Buildcraft wrench support to rotate drawers / drop sealed drawers --- .../storagedrawers/block/BlockDrawers.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java index 368ac7c..11c74fa 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java @@ -101,6 +101,8 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH @SideOnly(Side.CLIENT) private IIcon iconTaped; + private long ignoreEventTime; + public BlockDrawers (String blockName, int drawerCount, boolean halfDepth) { this(Material.wood, blockName, drawerCount, halfDepth); } @@ -236,6 +238,11 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH @Override public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if (Minecraft.getMinecraft().getSystemTime() == ignoreEventTime) { + ignoreEventTime = 0; + return false; + } + TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z); ItemStack item = player.inventory.getCurrentItem(); @@ -383,6 +390,30 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH } } + @Override + public boolean rotateBlock (World world, int x, int y, int z, ForgeDirection axis) { + TileEntityDrawers tile = getTileEntitySafe(world, x, y, z); + if (tile.isSealed()) { + harvestBlock(world, Minecraft.getMinecraft().thePlayer, x, y, z, world.getBlockMetadata(x, y, z)); + return true; + } + + if (tile.getDirection() == axis.ordinal()) + return false; + + if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) + return false; + + tile.setDirection(axis.ordinal()); + + world.markBlockForUpdate(x, y, z); + + if (world.isRemote) + ignoreEventTime = Minecraft.getMinecraft().getSystemTime(); + + return true; + } + @Override public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side) { if (halfDepth)