diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKCraneConsole.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKCraneConsole.java index 21059f59a..b181f5b35 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKCraneConsole.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKCraneConsole.java @@ -4,14 +4,17 @@ import com.hbm.blocks.BlockDummyable; import com.hbm.handler.MultiblockHandlerXR; import com.hbm.tileentity.machine.rbmk.TileEntityCraneConsole; +import api.hbm.block.IToolable; +import api.hbm.block.IToolable.ToolType; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class RBMKCraneConsole extends BlockDummyable { +public class RBMKCraneConsole extends BlockDummyable implements IToolable { public RBMKCraneConsole() { super(Material.iron); @@ -72,4 +75,19 @@ public class RBMKCraneConsole extends BlockDummyable { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } + + @Override + public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { + + if(tool == ToolType.SCREWDRIVER) { + if(world.isRemote) return true; + + TileEntityCraneConsole tile = (TileEntityCraneConsole) world.getTileEntity(x, y, z); + tile.cycleCraneRotation(); + tile.markDirty(); + return true; + } + + return false; + } } diff --git a/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java b/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java index d06119605..c4a54fe6d 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java +++ b/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java @@ -99,12 +99,7 @@ public class RenderCraneConsole extends TileEntitySpecialRenderer { double cranePosZ = (-te.zCoord + console.centerZ); GL11.glTranslated(cranePosX, cranePosY, cranePosZ); - switch(te.getBlockMetadata() - BlockDummyable.offset) { - case 2: GL11.glRotatef(90, 0F, 1F, 0F); break; - case 4: GL11.glRotatef(180, 0F, 1F, 0F); break; - case 3: GL11.glRotatef(270, 0F, 1F, 0F); break; - case 5: GL11.glRotatef(0, 0F, 1F, 0F); break; - } + GL11.glRotatef(((TileEntityCraneConsole)te).getCraneRotation(), 0F, 1F, 0F); double posX = (console.lastPosFront + (console.posFront - console.lastPosFront) * interp); double posZ = (console.lastPosLeft + (console.posLeft - console.lastPosLeft) * interp); diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityCraneConsole.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityCraneConsole.java index cf1d2d8bf..e672372dc 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityCraneConsole.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityCraneConsole.java @@ -28,6 +28,8 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.List; +import org.lwjgl.opengl.GL11; + @Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")}) public class TileEntityCraneConsole extends TileEntity implements INBTPacketReceiver, SimpleComponent, CompatHandler.OCComponent { @@ -44,6 +46,8 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece public boolean setUpCrane = false; + public int craneRotationOffset = 0; + public double lastTiltFront = 0; public double lastTiltLeft = 0; public double tiltFront = 0; @@ -169,6 +173,7 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece nbt.setBoolean("crane", setUpCrane); if(setUpCrane) { //no need to send any of this if there's NO FUCKING CRANE THERE + nbt.setInteger("craneRotationOffset", craneRotationOffset); nbt.setInteger("centerX", centerX); nbt.setInteger("centerY", centerY); nbt.setInteger("centerZ", centerZ); @@ -250,6 +255,7 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece lastProgress = progress; this.setUpCrane = nbt.getBoolean("crane"); + this.craneRotationOffset = nbt.getInteger("craneRotationOffset"); this.centerX = nbt.getInteger("centerX"); this.centerY = nbt.getInteger("centerY"); this.centerZ = nbt.getInteger("centerZ"); @@ -277,16 +283,33 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece this.spanR = 7; this.height = 7; + this.setUpCrane = true; this.markDirty(); } + + public int getCraneRotation() { + int result = craneRotationOffset; + switch(this.getBlockMetadata() - BlockDummyable.offset) { + case 2: result += 90; break; + case 4: result += 180; break; + case 3: result += 270; break; + case 5: result += 0; break; + } + return result % 360; + } + + public void cycleCraneRotation() { + this.craneRotationOffset = (this.craneRotationOffset + 90) % 360; + } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.setUpCrane = nbt.getBoolean("crane"); + this.craneRotationOffset = nbt.getInteger("craneRotationOffset"); this.centerX = nbt.getInteger("centerX"); this.centerY = nbt.getInteger("centerY"); this.centerZ = nbt.getInteger("centerZ"); @@ -307,6 +330,7 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece super.writeToNBT(nbt); nbt.setBoolean("crane", setUpCrane); + nbt.setInteger("craneRotationOffset", craneRotationOffset); nbt.setInteger("centerX", centerX); nbt.setInteger("centerY", centerY); nbt.setInteger("centerZ", centerZ);