From 12885c24a17760ebc6f9c04c07f35530951bc064 Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sun, 20 Dec 2015 14:07:57 +0100 Subject: [PATCH] rotate block --- .../java/storagecraft/block/BlockBase.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/storagecraft/block/BlockBase.java b/src/main/java/storagecraft/block/BlockBase.java index 31104ab3a..0a7d314aa 100644 --- a/src/main/java/storagecraft/block/BlockBase.java +++ b/src/main/java/storagecraft/block/BlockBase.java @@ -30,6 +30,29 @@ public abstract class BlockBase extends Block { return "block." + StorageCraft.ID + ":" + name; } + @Override + public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileBase) { + ForgeDirection dir = ((TileBase) tile).getDirection(); + + int newDir = dir.ordinal() + 1; + + if (newDir > ForgeDirection.VALID_DIRECTIONS.length - 1) { + newDir = 0; + } + + ((TileBase) tile).setDirection(ForgeDirection.getOrientation(newDir)); + + world.markBlockForUpdate(x, y, z); + + return true; + } + + return false; + } + @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);