Added zirnox reactor redstone support on/off

This commit is contained in:
Hacker6329 2026-02-21 17:35:35 +01:00
parent 22bd62f789
commit 08d12bceb3
2 changed files with 63 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityReactorZirnox;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
@ -39,7 +40,7 @@ public class ReactorZirnox extends BlockDummyable {
return true;
} else if(!player.isSneaking()) {
BossSpawnHandler.markFBI(player);
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
@ -54,7 +55,7 @@ public class ReactorZirnox extends BlockDummyable {
@Override
public int[] getDimensions() {
return new int[] {1, 0, 2, 2, 2, 2,};
return new int[] {1, 0, 2, 2, 2, 2,};
}
@Override
@ -87,4 +88,52 @@ public class ReactorZirnox extends BlockDummyable {
this.makeExtra(world, x + dir.offsetX * o, y + 4, z + dir.offsetZ * o);
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) {
if (world.isRemote) return;
// 1. Trova il controller
int[] core = this.findCore(world, x, y, z);
if (core == null) return;
int cx = core[0];
int cy = core[1];
int cz = core[2];
TileEntity te = world.getTileEntity(cx, cy, cz);
if (!(te instanceof TileEntityReactorZirnox)) return;
TileEntityReactorZirnox reactor = (TileEntityReactorZirnox) te;
boolean powered = false;
// 2. Scansiona la superficie del multiblock 5x5x5
for (int dx = -2; dx <= 2 && !powered; dx++) {
for (int dy = 0; dy <= 4 && !powered; dy++) {
for (int dz = -2; dz <= 2 && !powered; dz++) {
// Solo superficie
if (dx == -2 || dx == 2 ||
dy == 0 || dy == 4 ||
dz == -2 || dz == 2) {
int sx = cx + dx;
int sy = cy + dy;
int sz = cz + dz;
if (world.isBlockIndirectlyGettingPowered(sx, sy, sz) ||
world.getBlockPowerInput(sx, sy, sz) > 0) {
powered = true;
break;
}
}
}
}
}
// 3. Aggiorna la TileEntity
reactor.setRedstonePowered(powered);
}
}

View File

@ -53,6 +53,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
public int heat;
public static final int maxHeat = 100000;
public boolean redstonePowered = false;
public int pressure;
public static final int maxPressure = 100000;
public boolean isOn = false;
@ -85,6 +86,12 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
carbonDioxide = new FluidTank(Fluids.CARBONDIOXIDE, 16000);
water = new FluidTank(Fluids.WATER, 32000);
}
public void setRedstonePowered(boolean powered) {
this.redstonePowered = powered;
if (!powered) {
isOn = false;
}
}
@Override
public String getName() {
@ -176,7 +183,9 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
public void updateEntity() {
if(!worldObj.isRemote) {
if (redstonePowered) {
isOn = true;
}
this.output = 0;
if(worldObj.getTotalWorldTime() % 20 == 0) {
@ -429,7 +438,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("control")) {
if(data.hasKey("control") && !redstonePowered) {
this.isOn = !this.isOn;
}