From 08d12bceb391b101a3048b8a1cdb211fe245afea Mon Sep 17 00:00:00 2001 From: Hacker6329 Date: Sat, 21 Feb 2026 17:35:35 +0100 Subject: [PATCH] Added zirnox reactor redstone support on/off --- .../com/hbm/blocks/machine/ReactorZirnox.java | 55 ++++++++++++++++++- .../machine/TileEntityReactorZirnox.java | 13 ++++- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/ReactorZirnox.java b/src/main/java/com/hbm/blocks/machine/ReactorZirnox.java index b9b448ef5..b6c8b53cb 100644 --- a/src/main/java/com/hbm/blocks/machine/ReactorZirnox.java +++ b/src/main/java/com/hbm/blocks/machine/ReactorZirnox.java @@ -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); } -} \ No newline at end of file + @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); + } + +} diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java b/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java index a7ec9973f..bcf571225 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java @@ -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; }