mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Make RBMK crane rotatable visually
This commit is contained in:
parent
75df8fb945
commit
8da78f6895
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user