mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 15:00:48 +00:00
Added zirnox reactor redstone support on/off
This commit is contained in:
parent
22bd62f789
commit
08d12bceb3
@ -9,6 +9,7 @@ import com.hbm.tileentity.TileEntityProxyCombo;
|
|||||||
import com.hbm.tileentity.machine.TileEntityReactorZirnox;
|
import com.hbm.tileentity.machine.TileEntityReactorZirnox;
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@ -39,7 +40,7 @@ public class ReactorZirnox extends BlockDummyable {
|
|||||||
return true;
|
return true;
|
||||||
} else if(!player.isSneaking()) {
|
} else if(!player.isSneaking()) {
|
||||||
BossSpawnHandler.markFBI(player);
|
BossSpawnHandler.markFBI(player);
|
||||||
|
|
||||||
int[] pos = this.findCore(world, x, y, z);
|
int[] pos = this.findCore(world, x, y, z);
|
||||||
|
|
||||||
if(pos == null)
|
if(pos == null)
|
||||||
@ -54,7 +55,7 @@ public class ReactorZirnox extends BlockDummyable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getDimensions() {
|
public int[] getDimensions() {
|
||||||
return new int[] {1, 0, 2, 2, 2, 2,};
|
return new int[] {1, 0, 2, 2, 2, 2,};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,4 +88,52 @@ public class ReactorZirnox extends BlockDummyable {
|
|||||||
this.makeExtra(world, x + dir.offsetX * o, y + 4, z + dir.offsetZ * o);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -53,6 +53,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
|
|
||||||
public int heat;
|
public int heat;
|
||||||
public static final int maxHeat = 100000;
|
public static final int maxHeat = 100000;
|
||||||
|
public boolean redstonePowered = false;
|
||||||
public int pressure;
|
public int pressure;
|
||||||
public static final int maxPressure = 100000;
|
public static final int maxPressure = 100000;
|
||||||
public boolean isOn = false;
|
public boolean isOn = false;
|
||||||
@ -85,6 +86,12 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
carbonDioxide = new FluidTank(Fluids.CARBONDIOXIDE, 16000);
|
carbonDioxide = new FluidTank(Fluids.CARBONDIOXIDE, 16000);
|
||||||
water = new FluidTank(Fluids.WATER, 32000);
|
water = new FluidTank(Fluids.WATER, 32000);
|
||||||
}
|
}
|
||||||
|
public void setRedstonePowered(boolean powered) {
|
||||||
|
this.redstonePowered = powered;
|
||||||
|
if (!powered) {
|
||||||
|
isOn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -176,7 +183,9 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
if (redstonePowered) {
|
||||||
|
isOn = true;
|
||||||
|
}
|
||||||
this.output = 0;
|
this.output = 0;
|
||||||
|
|
||||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||||
@ -429,7 +438,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveControl(NBTTagCompound data) {
|
public void receiveControl(NBTTagCompound data) {
|
||||||
if(data.hasKey("control")) {
|
if(data.hasKey("control") && !redstonePowered) {
|
||||||
this.isOn = !this.isOn;
|
this.isOn = !this.isOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user