From 5944999cf94bde58e9a129d696456dd303a3f46e Mon Sep 17 00:00:00 2001 From: abel1502 Date: Wed, 2 Oct 2024 16:21:33 +0300 Subject: [PATCH] Fix rbmk crane rotation --- .../blocks/machine/rbmk/RBMKCraneConsole.java | 5 ++- .../render/tileentity/RenderCraneConsole.java | 37 ++++++++++++++++--- .../machine/rbmk/TileEntityCraneConsole.java | 11 ------ 3 files changed, 35 insertions(+), 18 deletions(-) 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 b181f5b35..a996595fe 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKCraneConsole.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKCraneConsole.java @@ -81,8 +81,9 @@ public class RBMKCraneConsole extends BlockDummyable implements IToolable { if(tool == ToolType.SCREWDRIVER) { if(world.isRemote) return true; - - TileEntityCraneConsole tile = (TileEntityCraneConsole) world.getTileEntity(x, y, z); + + int[] pos = findCore(world, x, y, z); + TileEntityCraneConsole tile = (TileEntityCraneConsole) world.getTileEntity(pos[0], pos[1], pos[2]); tile.cycleCraneRotation(); tile.markDirty(); return true; diff --git a/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java b/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java index c4a54fe6d..467f1fc22 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java +++ b/src/main/java/com/hbm/render/tileentity/RenderCraneConsole.java @@ -99,22 +99,49 @@ public class RenderCraneConsole extends TileEntitySpecialRenderer { double cranePosZ = (-te.zCoord + console.centerZ); GL11.glTranslated(cranePosX, cranePosY, cranePosZ); - GL11.glRotatef(((TileEntityCraneConsole)te).getCraneRotation(), 0F, 1F, 0F); + 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; + } double posX = (console.lastPosFront + (console.posFront - console.lastPosFront) * interp); double posZ = (console.lastPosLeft + (console.posLeft - console.lastPosLeft) * interp); - GL11.glTranslated(0, 0, posZ); + GL11.glTranslated(-posX, 0, posZ); + + int craneRotationOffset = ((TileEntityCraneConsole)te).craneRotationOffset; + GL11.glRotatef(craneRotationOffset, 0F, 1F, 0F); GL11.glPushMatrix(); - GL11.glTranslated(-console.spanL, height - 1, 0); + int girderSpan = 0; + GL11.glRotatef(-craneRotationOffset, 0F, 1F, 0F); + switch(craneRotationOffset) { + case 0: + girderSpan = console.spanL + console.spanR + 1; + GL11.glTranslated(posX - console.spanL, 0, 0); + break; + case 90: + girderSpan = console.spanF + console.spanB + 1; + GL11.glTranslated(0, 0, -posZ + console.spanB); + break; + case 180: + girderSpan = console.spanL + console.spanR + 1; + GL11.glTranslated(posX + console.spanR, 0, 0); + break; + case 270: + girderSpan = console.spanF + console.spanB + 1; + GL11.glTranslated(0, 0, -posZ - console.spanF); + break; + } + GL11.glRotatef(craneRotationOffset, 0F, 1F, 0F); - for(int i = -console.spanL; i <= console.spanR; i++) { + for(int i = 0; i < girderSpan; i++) { ResourceManager.rbmk_crane.renderPart("Girder"); GL11.glTranslated(1, 0, 0); } GL11.glPopMatrix(); - GL11.glTranslated(-posX, 0, 0); ResourceManager.rbmk_crane.renderPart("Main"); GL11.glPushMatrix(); 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 e672372dc..c98c229ae 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityCraneConsole.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityCraneConsole.java @@ -289,17 +289,6 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece 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; }