Fix rbmk crane rotation

This commit is contained in:
abel1502 2024-10-02 16:21:33 +03:00
parent 8da78f6895
commit 5944999cf9
No known key found for this signature in database
GPG Key ID: 076926596A536338
3 changed files with 35 additions and 18 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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;
}