mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 15:00:48 +00:00
Merge pull request #2719 from ItalianDudes/master
Added zirnox reactor redstone support on/off
This commit is contained in:
commit
ad72c71082
@ -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;
|
||||||
@ -87,4 +88,43 @@ 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) {
|
||||||
|
super.onNeighborBlockChange(world, x, y, z, neighbor);
|
||||||
|
if (world.isRemote) return;
|
||||||
|
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. Scan multiblock
|
||||||
|
for (int dx = -2; dx <= 2 && !powered; dx++) {
|
||||||
|
for (int dy = 0; dy <= 4 && !powered; dy++) {
|
||||||
|
for (int dz = -2; dz <= 2 && !powered; dz++) {
|
||||||
|
// Get only surface blocks
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
if (!powered && this.redstonePowered) {
|
||||||
|
isOn = false;
|
||||||
|
}
|
||||||
|
this.redstonePowered = powered;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -115,6 +122,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
steam.readFromNBT(nbt, "steam");
|
steam.readFromNBT(nbt, "steam");
|
||||||
carbonDioxide.readFromNBT(nbt, "carbondioxide");
|
carbonDioxide.readFromNBT(nbt, "carbondioxide");
|
||||||
water.readFromNBT(nbt, "water");
|
water.readFromNBT(nbt, "water");
|
||||||
|
redstonePowered = nbt.getBoolean("redstonePowered");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -126,6 +134,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
steam.writeToNBT(nbt, "steam");
|
steam.writeToNBT(nbt, "steam");
|
||||||
carbonDioxide.writeToNBT(nbt, "carbondioxide");
|
carbonDioxide.writeToNBT(nbt, "carbondioxide");
|
||||||
water.writeToNBT(nbt, "water");
|
water.writeToNBT(nbt, "water");
|
||||||
|
nbt.setBoolean("redstonePowered", redstonePowered);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +185,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) {
|
||||||
@ -228,6 +239,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
buf.writeInt(this.heat);
|
buf.writeInt(this.heat);
|
||||||
buf.writeInt(this.pressure);
|
buf.writeInt(this.pressure);
|
||||||
buf.writeBoolean(this.isOn);
|
buf.writeBoolean(this.isOn);
|
||||||
|
buf.writeBoolean(this.redstonePowered);
|
||||||
steam.serialize(buf);
|
steam.serialize(buf);
|
||||||
carbonDioxide.serialize(buf);
|
carbonDioxide.serialize(buf);
|
||||||
water.serialize(buf);
|
water.serialize(buf);
|
||||||
@ -239,6 +251,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
|||||||
this.heat = buf.readInt();
|
this.heat = buf.readInt();
|
||||||
this.pressure = buf.readInt();
|
this.pressure = buf.readInt();
|
||||||
this.isOn = buf.readBoolean();
|
this.isOn = buf.readBoolean();
|
||||||
|
this.redstonePowered = buf.readBoolean();
|
||||||
steam.deserialize(buf);
|
steam.deserialize(buf);
|
||||||
carbonDioxide.deserialize(buf);
|
carbonDioxide.deserialize(buf);
|
||||||
water.deserialize(buf);
|
water.deserialize(buf);
|
||||||
@ -429,7 +442,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