mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Added rbmk console view rotation support
This commit is contained in:
parent
3e35f0ac47
commit
bbc27820f1
@ -1,5 +1,6 @@
|
|||||||
package com.hbm.blocks.machine.rbmk;
|
package com.hbm.blocks.machine.rbmk;
|
||||||
|
|
||||||
|
import api.hbm.block.IToolable;
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
import com.hbm.handler.BossSpawnHandler;
|
import com.hbm.handler.BossSpawnHandler;
|
||||||
import com.hbm.handler.MultiblockHandlerXR;
|
import com.hbm.handler.MultiblockHandlerXR;
|
||||||
@ -17,7 +18,7 @@ import net.minecraft.util.Vec3;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class RBMKConsole extends BlockDummyable {
|
public class RBMKConsole extends BlockDummyable implements IToolable {
|
||||||
|
|
||||||
public RBMKConsole() {
|
public RBMKConsole() {
|
||||||
super(Material.iron);
|
super(Material.iron);
|
||||||
@ -121,4 +122,18 @@ public class RBMKConsole extends BlockDummyable {
|
|||||||
|
|
||||||
return super.checkRequirement(world, x, y, z, dir, o);
|
return super.checkRequirement(world, x, y, z, dir, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
return false;
|
||||||
|
if(!world.isRemote) {
|
||||||
|
int[] pos = findCore(world, x, y, z);
|
||||||
|
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||||
|
if (tile instanceof TileEntityRBMKConsole) {
|
||||||
|
((TileEntityRBMKConsole) tile).rotate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,8 @@ public class TileEntityRBMKConsole extends TileEntityMachineBase implements ICon
|
|||||||
private int targetY;
|
private int targetY;
|
||||||
private int targetZ;
|
private int targetZ;
|
||||||
|
|
||||||
|
private byte rotation;
|
||||||
|
|
||||||
public static final int fluxDisplayBuffer = 60;
|
public static final int fluxDisplayBuffer = 60;
|
||||||
public int[] fluxBuffer = new int[fluxDisplayBuffer];
|
public int[] fluxBuffer = new int[fluxDisplayBuffer];
|
||||||
|
|
||||||
@ -89,8 +91,23 @@ public class TileEntityRBMKConsole extends TileEntityMachineBase implements ICon
|
|||||||
|
|
||||||
for(int i = -7; i <= 7; i++) {
|
for(int i = -7; i <= 7; i++) {
|
||||||
for(int j = -7; j <= 7; j++) {
|
for(int j = -7; j <= 7; j++) {
|
||||||
|
int rx = i, rz = j;
|
||||||
|
switch (rotation) {
|
||||||
|
case 1: // 90°
|
||||||
|
rx = -j;
|
||||||
|
rz = i;
|
||||||
|
break;
|
||||||
|
case 2: // 180°
|
||||||
|
rx = -i;
|
||||||
|
rz = -j;
|
||||||
|
break;
|
||||||
|
case 3: // 270°
|
||||||
|
rx = j;
|
||||||
|
rz = -i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
TileEntity te = Compat.getTileStandard(worldObj, targetX + i, targetY, targetZ + j);
|
TileEntity te = Compat.getTileStandard(worldObj, targetX + rx, targetY, targetZ + rz);
|
||||||
int index = (i + 7) + (j + 7) * 15;
|
int index = (i + 7) + (j + 7) * 15;
|
||||||
|
|
||||||
if(te instanceof TileEntityRBMKBase) {
|
if(te instanceof TileEntityRBMKBase) {
|
||||||
@ -365,6 +382,7 @@ public class TileEntityRBMKConsole extends TileEntityMachineBase implements ICon
|
|||||||
this.screens[i].type = ScreenType.values()[nbt.getByte("t" + i)];
|
this.screens[i].type = ScreenType.values()[nbt.getByte("t" + i)];
|
||||||
this.screens[i].columns = Arrays.stream(nbt.getIntArray("s" + i)).boxed().toArray(Integer[]::new);
|
this.screens[i].columns = Arrays.stream(nbt.getIntArray("s" + i)).boxed().toArray(Integer[]::new);
|
||||||
}
|
}
|
||||||
|
rotation = nbt.getByte("rotation");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -379,6 +397,11 @@ public class TileEntityRBMKConsole extends TileEntityMachineBase implements ICon
|
|||||||
nbt.setByte("t" + i, (byte) this.screens[i].type.ordinal());
|
nbt.setByte("t" + i, (byte) this.screens[i].type.ordinal());
|
||||||
nbt.setIntArray("s" + i, Arrays.stream(this.screens[i].columns).mapToInt(Integer::intValue).toArray());
|
nbt.setIntArray("s" + i, Arrays.stream(this.screens[i].columns).mapToInt(Integer::intValue).toArray());
|
||||||
}
|
}
|
||||||
|
nbt.setByte("rotation", rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate() {
|
||||||
|
rotation = (byte)((rotation + 1) % 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RBMKColumn {
|
public static class RBMKColumn {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user