Merge pull request #1330 from taelnia/master

Fix for invalid gate type(pulser or not) for re-loaded worlds.
This commit is contained in:
CovertJaguar 2013-11-23 11:43:01 -08:00
commit d17fd45f27

View file

@ -62,17 +62,20 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
public int pipeId = -1; public int pipeId = -1;
public int gateKind = 0; public int gateKind = 0;
public boolean pulser = false;
@Override @Override
public void writeData(DataOutputStream data) throws IOException { public void writeData(DataOutputStream data) throws IOException {
data.writeInt(pipeId); data.writeInt(pipeId);
data.writeInt(gateKind); data.writeInt(gateKind);
data.writeBoolean(pulser);
} }
@Override @Override
public void readData(DataInputStream data) throws IOException { public void readData(DataInputStream data) throws IOException {
pipeId = data.readInt(); pipeId = data.readInt();
gateKind = data.readInt(); gateKind = data.readInt();
pulser = data.readBoolean();
} }
} }
private PipeRenderState renderState = new PipeRenderState(); private PipeRenderState renderState = new PipeRenderState();
@ -362,10 +365,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
bindPipe(); bindPipe();
PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord); PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord);
if (pipe != null && pipe.gate != null) if (pipe != null && pipe.gate != null) {
coreState.gateKind = pipe.gate.kind.ordinal(); coreState.gateKind = pipe.gate.kind.ordinal();
else coreState.pulser = pipe.gate instanceof GateVanilla && ((GateVanilla)pipe.gate).hasPulser() ? true : false;
} else {
coreState.gateKind = 0; coreState.gateKind = 0;
coreState.pulser = false;
}
if (pipe != null && pipe.transport != null) if (pipe != null && pipe.transport != null)
pipe.transport.sendDescriptionPacket(); pipe.transport.sendDescriptionPacket();
@ -635,8 +641,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
initialize(BlockGenericPipe.createPipe(coreState.pipeId)); initialize(BlockGenericPipe.createPipe(coreState.pipeId));
if (pipe != null && coreState.gateKind != GateKind.None.ordinal()) { if (pipe != null && coreState.gateKind != GateKind.None.ordinal()) {
if (pipe.gate == null) if (pipe.gate == null) {
pipe.gate = new GateVanilla(pipe); if (coreState.pulser) {
pipe.gate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, coreState.gateKind));
} else {
pipe.gate = new GateVanilla(pipe);
}
}
pipe.gate.kind = GateKind.values()[coreState.gateKind]; pipe.gate.kind = GateKind.values()[coreState.gateKind];
} }
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);