Adds sync to renderstate (works in SMP), however, pipe-content sync is now broken, as are any gate interfaces for gates that you have not placed yourself. Also fixes autarchic gates being converted to non-autarchic gates.
This commit is contained in:
parent
68a911f36a
commit
24e342abbc
11 changed files with 101 additions and 63 deletions
|
@ -19,6 +19,7 @@ import net.minecraft.src.buildcraft.core.network.PacketPipeTransportContent;
|
||||||
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
||||||
import net.minecraft.src.buildcraft.transport.CraftingGateInterface;
|
import net.minecraft.src.buildcraft.transport.CraftingGateInterface;
|
||||||
import net.minecraft.src.buildcraft.transport.PipeLogicDiamond;
|
import net.minecraft.src.buildcraft.transport.PipeLogicDiamond;
|
||||||
|
import net.minecraft.src.buildcraft.transport.PipeRenderState;
|
||||||
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
|
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
|
||||||
import net.minecraft.src.buildcraft.transport.TileGenericPipe;
|
import net.minecraft.src.buildcraft.transport.TileGenericPipe;
|
||||||
import net.minecraft.src.forge.IPacketHandler;
|
import net.minecraft.src.forge.IPacketHandler;
|
||||||
|
@ -42,9 +43,12 @@ public class PacketHandler implements IPacketHandler {
|
||||||
onDiamondContents(packetN);
|
onDiamondContents(packetN);
|
||||||
break;
|
break;
|
||||||
case PacketIds.PIPE_DESCRIPTION:
|
case PacketIds.PIPE_DESCRIPTION:
|
||||||
PacketPipeDescription packetU = new PacketPipeDescription();
|
PipeRenderStatePacket descPacket = new PipeRenderStatePacket();
|
||||||
packetU.readData(data);
|
descPacket.readData(data);
|
||||||
onPipeDescription(packetU);
|
onPipeDescription(descPacket);
|
||||||
|
// PacketPipeDescription packetU = new PacketPipeDescription();
|
||||||
|
// packetU.readData(data);
|
||||||
|
// onPipeDescription(packetU);
|
||||||
break;
|
break;
|
||||||
case PacketIds.PIPE_CONTENTS:
|
case PacketIds.PIPE_CONTENTS:
|
||||||
PacketPipeTransportContent packetC = new PacketPipeTransportContent();
|
PacketPipeTransportContent packetC = new PacketPipeTransportContent();
|
||||||
|
@ -116,20 +120,26 @@ public class PacketHandler implements IPacketHandler {
|
||||||
* Handles a pipe description packet. (Creates the pipe object client side
|
* Handles a pipe description packet. (Creates the pipe object client side
|
||||||
* if needed.)
|
* if needed.)
|
||||||
*
|
*
|
||||||
* @param packet
|
* @param descPacket
|
||||||
*/
|
*/
|
||||||
private void onPipeDescription(PacketPipeDescription packet) {
|
private void onPipeDescription(PipeRenderStatePacket descPacket) {
|
||||||
World world = ModLoader.getMinecraftInstance().theWorld;
|
World world = ModLoader.getMinecraftInstance().theWorld;
|
||||||
|
|
||||||
if (!world.blockExists(packet.posX, packet.posY, packet.posZ))
|
if (!world.blockExists(descPacket.posX, descPacket.posY, descPacket.posZ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileEntity entity = world.getBlockTileEntity(packet.posX, packet.posY, packet.posZ);
|
TileEntity entity = world.getBlockTileEntity(descPacket.posX, descPacket.posY, descPacket.posZ);
|
||||||
if (!(entity instanceof ISynchronizedTile))
|
if (entity == null){
|
||||||
|
return;
|
||||||
|
// entity = new TileGenericPipeProxy();
|
||||||
|
// world.setBlockTileEntity(descPacket.posX, descPacket.posY, descPacket.posZ, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(entity instanceof TileGenericPipe))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ISynchronizedTile tile = (ISynchronizedTile) entity;
|
TileGenericPipe tile = (TileGenericPipe) entity;
|
||||||
tile.handleDescriptionPacket(packet);
|
tile.handleDescriptionPacket(descPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -94,9 +94,9 @@ public class mod_BuildCraftTransport extends NetworkMod {
|
||||||
|
|
||||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tile instanceof TileGenericPipe){
|
if (tile instanceof IPipeRenderState){
|
||||||
TileGenericPipe pipeTile = (TileGenericPipe) tile;
|
IPipeRenderState pipeTile = (IPipeRenderState) tile;
|
||||||
pipeWorldRenderer.renderPipe(renderer, world, block, ((IPipeRenderState)tile).getRenderState(), pipeTile.xCoord, pipeTile.yCoord, pipeTile.zCoord);
|
pipeWorldRenderer.renderPipe(renderer, world, block, pipeTile.getRenderState(), x, y, z);
|
||||||
}
|
}
|
||||||
// if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
|
// if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
|
||||||
// pipeWorldRenderer.renderPipe(renderer, world, tile, block);
|
// pipeWorldRenderer.renderPipe(renderer, world, tile, block);
|
||||||
|
|
|
@ -16,6 +16,4 @@ public class PacketIds {
|
||||||
public static final int GATE_SELECTION_CHANGE = 44;
|
public static final int GATE_SELECTION_CHANGE = 44;
|
||||||
public static final int GATE_TRIGGERS = 45;
|
public static final int GATE_TRIGGERS = 45;
|
||||||
public static final int REFINERY_FILTER_SET = 50;
|
public static final int REFINERY_FILTER_SET = 50;
|
||||||
|
|
||||||
public static final int PIPE_RENDER_STATE = 60;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,6 +510,7 @@ public class BlockGenericPipe extends BlockContainer implements ITextureProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean placePipe(Pipe pipe, World world, int i, int j, int k, int blockId, int meta) {
|
public static boolean placePipe(Pipe pipe, World world, int i, int j, int k, int blockId, int meta) {
|
||||||
|
if (world.isRemote) return true;
|
||||||
|
|
||||||
boolean placed = world.setBlockAndMetadataWithNotify(i, j, k, blockId, meta);
|
boolean placed = world.setBlockAndMetadataWithNotify(i, j, k, blockId, meta);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class EnergyPulser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if (powerReceptor == null) return;
|
||||||
|
|
||||||
// Set current pulse speed
|
// Set current pulse speed
|
||||||
pulseSpeed = getPulseSpeed();
|
pulseSpeed = getPulseSpeed();
|
||||||
|
|
|
@ -118,9 +118,10 @@ public class GateVanilla extends Gate {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean addEnergyPulser(Pipe pipe) {
|
private boolean addEnergyPulser(Pipe pipe) {
|
||||||
if (!(pipe instanceof IPowerReceptor))
|
if (!(pipe instanceof IPowerReceptor)){
|
||||||
|
pulser = new EnergyPulser(null);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
pulser = new EnergyPulser((IPowerReceptor) pipe);
|
pulser = new EnergyPulser((IPowerReceptor) pipe);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -88,16 +88,22 @@ public class PipeRenderState {
|
||||||
|
|
||||||
public void writeData(DataOutputStream data) throws IOException {
|
public void writeData(DataOutputStream data) throws IOException {
|
||||||
data.writeUTF(textureFile);
|
data.writeUTF(textureFile);
|
||||||
|
data.writeBoolean(hasGate);
|
||||||
|
data.writeInt(gateTextureIndex);
|
||||||
pipeConnectionMatrix.writeData(data);
|
pipeConnectionMatrix.writeData(data);
|
||||||
textureMatrix.writeData(data);
|
textureMatrix.writeData(data);
|
||||||
wireMatrix.writeData(data);
|
wireMatrix.writeData(data);
|
||||||
|
facadeMatrix.writeData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readData(DataInputStream data) throws IOException {
|
public void readData(DataInputStream data) throws IOException {
|
||||||
textureFile = data.readUTF();
|
textureFile = data.readUTF();
|
||||||
|
hasGate = data.readBoolean();
|
||||||
|
gateTextureIndex = data.readInt();
|
||||||
pipeConnectionMatrix.readData(data);
|
pipeConnectionMatrix.readData(data);
|
||||||
textureMatrix.readData(data);
|
textureMatrix.readData(data);
|
||||||
wireMatrix.readData(data);
|
wireMatrix.readData(data);
|
||||||
|
facadeMatrix.readData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,17 +42,17 @@ import net.minecraft.src.buildcraft.core.IDropControlInventory;
|
||||||
import net.minecraft.src.buildcraft.core.ITileBufferHolder;
|
import net.minecraft.src.buildcraft.core.ITileBufferHolder;
|
||||||
import net.minecraft.src.buildcraft.core.TileBuffer;
|
import net.minecraft.src.buildcraft.core.TileBuffer;
|
||||||
import net.minecraft.src.buildcraft.core.Utils;
|
import net.minecraft.src.buildcraft.core.Utils;
|
||||||
import net.minecraft.src.buildcraft.core.network.ISynchronizedTile;
|
|
||||||
import net.minecraft.src.buildcraft.core.network.IndexInPayload;
|
import net.minecraft.src.buildcraft.core.network.IndexInPayload;
|
||||||
import net.minecraft.src.buildcraft.core.network.PacketPayload;
|
import net.minecraft.src.buildcraft.core.network.PacketPayload;
|
||||||
import net.minecraft.src.buildcraft.core.network.PacketPipeDescription;
|
import net.minecraft.src.buildcraft.core.network.PacketPipeDescription;
|
||||||
import net.minecraft.src.buildcraft.core.network.PacketTileUpdate;
|
import net.minecraft.src.buildcraft.core.network.PacketTileUpdate;
|
||||||
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
||||||
|
import net.minecraft.src.buildcraft.transport.network.PipeRenderStatePacket;
|
||||||
|
|
||||||
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiquidContainer, IPipeEntry,
|
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiquidContainer, IPipeEntry,
|
||||||
IPipeTile, ISynchronizedTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory, IPipeRenderState {
|
IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory, IPipeRenderState {
|
||||||
|
|
||||||
private final PipeRenderState renderState = new PipeRenderState();
|
private PipeRenderState renderState = new PipeRenderState();
|
||||||
|
|
||||||
public TileBuffer[] tileBuffer;
|
public TileBuffer[] tileBuffer;
|
||||||
public boolean[] pipeConnectionsBuffer = new boolean[6];
|
public boolean[] pipeConnectionsBuffer = new boolean[6];
|
||||||
|
@ -357,57 +357,50 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void handleDescriptionPacket(PipeRenderStatePacket packet) {
|
||||||
* Description packets and update packets are handled differently. They
|
if (worldObj.isRemote){
|
||||||
* should be unified.
|
if (pipe == null && packet.getPipeId() != 0){
|
||||||
*/
|
initialize(BlockGenericPipe.createPipe(packet.getPipeId()));
|
||||||
@Override
|
}
|
||||||
public void handleDescriptionPacket(PacketUpdate packet) {
|
renderState = packet.getRenderState();
|
||||||
|
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
|
||||||
if (pipe == null && packet.payload.intPayload[0] != 0) {
|
|
||||||
|
|
||||||
initialize(BlockGenericPipe.createPipe(packet.payload.intPayload[0]));
|
|
||||||
|
|
||||||
// Check for wire information
|
|
||||||
pipe.handleWirePayload(packet.payload, new IndexInPayload(1, 0, 0));
|
|
||||||
// Check for gate information
|
|
||||||
if (packet.payload.intPayload.length > 5)
|
|
||||||
pipe.handleGatePayload(packet.payload, new IndexInPayload(5, 0, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
// if (pipe == null && packet.payload.intPayload[0] != 0) {
|
||||||
|
//
|
||||||
|
// initialize(BlockGenericPipe.createPipe(packet.payload.intPayload[0]));
|
||||||
|
//
|
||||||
|
// // Check for wire information
|
||||||
|
// pipe.handleWirePayload(packet.payload, new IndexInPayload(1, 0, 0));
|
||||||
|
// // Check for gate information
|
||||||
|
// if (packet.payload.intPayload.length > 5)
|
||||||
|
// pipe.handleGatePayload(packet.payload, new IndexInPayload(5, 0, 0));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
//@Override
|
||||||
public void handleUpdatePacket(PacketUpdate packet) {
|
public void handleUpdatePacket(PacketUpdate packet) {
|
||||||
if (BlockGenericPipe.isValid(pipe))
|
if (BlockGenericPipe.isValid(pipe))
|
||||||
pipe.handlePacket(packet);
|
pipe.handlePacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
//@Override
|
||||||
public void postPacketHandling(PacketUpdate packet) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet getUpdatePacket() {
|
public Packet getUpdatePacket() {
|
||||||
return new PacketTileUpdate(this).getPacket();
|
return null;
|
||||||
|
//return new PacketTileUpdate(this).getPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet getDescriptionPacket() {
|
public Packet getDescriptionPacket() {
|
||||||
bindPipe();
|
bindPipe();
|
||||||
|
PipeRenderStatePacket packet = new PipeRenderStatePacket(this.renderState, this.pipeId, xCoord, yCoord, zCoord);
|
||||||
PacketPipeDescription packet;
|
|
||||||
if (pipe != null)
|
|
||||||
packet = new PacketPipeDescription(xCoord, yCoord, zCoord, pipe);
|
|
||||||
else
|
|
||||||
packet = new PacketPipeDescription(xCoord, yCoord, zCoord, null);
|
|
||||||
|
|
||||||
return packet.getPacket();
|
return packet.getPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PacketPayload getPacketPayload() {
|
|
||||||
return pipe.getNetworkPacket();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int powerRequest() {
|
public int powerRequest() {
|
||||||
return getPowerProvider().maxEnergyReceived;
|
return getPowerProvider().maxEnergyReceived;
|
||||||
|
@ -535,7 +528,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
||||||
|
|
||||||
this.facadeBlocks[direction.ordinal()] = blockid;
|
this.facadeBlocks[direction.ordinal()] = blockid;
|
||||||
this.facadeMeta[direction.ordinal()] = meta;
|
this.facadeMeta[direction.ordinal()] = meta;
|
||||||
refreshRenderState();
|
scheduleRenderUpdate();
|
||||||
|
//refreshRenderState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +544,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
||||||
Utils.dropItems(worldObj, new ItemStack(BuildCraftTransport.facadeItem, 1, ItemFacade.encode(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()])), this.xCoord, this.yCoord, this.zCoord);
|
Utils.dropItems(worldObj, new ItemStack(BuildCraftTransport.facadeItem, 1, ItemFacade.encode(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()])), this.xCoord, this.yCoord, this.zCoord);
|
||||||
this.facadeBlocks[direction.ordinal()] = 0;
|
this.facadeBlocks[direction.ordinal()] = 0;
|
||||||
this.facadeMeta[direction.ordinal()] = 0;
|
this.facadeMeta[direction.ordinal()] = 0;
|
||||||
refreshRenderState();
|
scheduleRenderUpdate();
|
||||||
|
//refreshRenderState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** IPipeRenderState implementation **/
|
/** IPipeRenderState implementation **/
|
||||||
|
|
|
@ -11,26 +11,50 @@ import net.minecraft.src.buildcraft.transport.PipeRenderState;
|
||||||
public class PipeRenderStatePacket extends PacketCoordinates {
|
public class PipeRenderStatePacket extends PacketCoordinates {
|
||||||
|
|
||||||
private PipeRenderState renderState;
|
private PipeRenderState renderState;
|
||||||
|
public int pipeId;
|
||||||
|
|
||||||
public PipeRenderStatePacket(PipeRenderState renderState, int x, int y, int z) {
|
|
||||||
super(PacketIds.PIPE_RENDER_STATE, x, y, z);
|
public PipeRenderStatePacket(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public PipeRenderStatePacket(PipeRenderState renderState, int pipeId, int x, int y, int z) {
|
||||||
|
super(PacketIds.PIPE_DESCRIPTION, x, y, z);
|
||||||
|
this.pipeId = pipeId;
|
||||||
|
this.isChunkDataPacket = true;
|
||||||
this.renderState = renderState;
|
this.renderState = renderState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PipeRenderState getRenderState(){
|
||||||
|
return this.renderState;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeData(DataOutputStream data) throws IOException {
|
public void writeData(DataOutputStream data) throws IOException {
|
||||||
|
super.writeData(data);
|
||||||
|
data.writeInt(pipeId);
|
||||||
renderState.writeData(data);
|
renderState.writeData(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readData(DataInputStream data) throws IOException {
|
public void readData(DataInputStream data) throws IOException {
|
||||||
|
super.readData(data);
|
||||||
|
pipeId = data.readInt();
|
||||||
|
renderState = new PipeRenderState();
|
||||||
renderState.readData(data);
|
renderState.readData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getID() {
|
public int getID() {
|
||||||
return PacketIds.PIPE_RENDER_STATE;
|
return PacketIds.PIPE_DESCRIPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPipeId(int pipeId){
|
||||||
|
this.pipeId = pipeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPipeId() {
|
||||||
|
return pipeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,13 @@ public class TextureMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeData(DataOutputStream data) throws IOException {
|
public void writeData(DataOutputStream data) throws IOException {
|
||||||
for(int i = 0; i < Orientations.dirs().length; i++){
|
for(int i = 0; i < Orientations.values().length; i++){
|
||||||
data.writeInt(_textureIndexes[i]);
|
data.writeInt(_textureIndexes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readData(DataInputStream data) throws IOException {
|
public void readData(DataInputStream data) throws IOException {
|
||||||
for (int i = 0; i < Orientations.dirs().length; i++){
|
for (int i = 0; i < Orientations.values().length; i++){
|
||||||
_textureIndexes[i] = data.readInt();
|
_textureIndexes[i] = data.readInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class WireMatrix {
|
||||||
for (int i = 0; i < IPipe.WireColor.values().length; i++){
|
for (int i = 0; i < IPipe.WireColor.values().length; i++){
|
||||||
data.writeBoolean(_hasWire[i]);
|
data.writeBoolean(_hasWire[i]);
|
||||||
_wires[i].writeData(data);
|
_wires[i].writeData(data);
|
||||||
|
data.writeInt(_wireTextureIndex[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +79,7 @@ public class WireMatrix {
|
||||||
for (int i = 0; i < IPipe.WireColor.values().length; i++){
|
for (int i = 0; i < IPipe.WireColor.values().length; i++){
|
||||||
_hasWire[i] = data.readBoolean();
|
_hasWire[i] = data.readBoolean();
|
||||||
_wires[i].readData(data);
|
_wires[i].readData(data);
|
||||||
|
_wireTextureIndex[i] = data.readInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue