Fixed display power sync, liquid sync still broken
This commit is contained in:
parent
24e342abbc
commit
ef3f12d333
7 changed files with 90 additions and 39 deletions
|
@ -21,6 +21,7 @@ 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.PipeRenderState;
|
||||||
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
|
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
|
||||||
|
import net.minecraft.src.buildcraft.transport.PipeTransportPower;
|
||||||
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,6 +43,11 @@ public class PacketHandler implements IPacketHandler {
|
||||||
packetN.readData(data);
|
packetN.readData(data);
|
||||||
onDiamondContents(packetN);
|
onDiamondContents(packetN);
|
||||||
break;
|
break;
|
||||||
|
case PacketIds.PIPE_POWER:
|
||||||
|
PacketPowerUpdate packetPower= new PacketPowerUpdate();
|
||||||
|
packetPower.readData(data);
|
||||||
|
onPacketPower(packetPower);
|
||||||
|
break;
|
||||||
case PacketIds.PIPE_DESCRIPTION:
|
case PacketIds.PIPE_DESCRIPTION:
|
||||||
PipeRenderStatePacket descPacket = new PipeRenderStatePacket();
|
PipeRenderStatePacket descPacket = new PipeRenderStatePacket();
|
||||||
descPacket.readData(data);
|
descPacket.readData(data);
|
||||||
|
@ -167,6 +173,32 @@ public class PacketHandler implements IPacketHandler {
|
||||||
((PipeTransportItems) pipe.pipe.transport).handleItemPacket(packet);
|
((PipeTransportItems) pipe.pipe.transport).handleItemPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the display power on a power pipe
|
||||||
|
* @param packetPower
|
||||||
|
*/
|
||||||
|
private void onPacketPower(PacketPowerUpdate packetPower) {
|
||||||
|
World world = ModLoader.getMinecraftInstance().theWorld;
|
||||||
|
if (!world.blockExists(packetPower.posX, packetPower.posY, packetPower.posZ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
TileEntity entity = world.getBlockTileEntity(packetPower.posX, packetPower.posY, packetPower.posZ);
|
||||||
|
if (!(entity instanceof TileGenericPipe))
|
||||||
|
return;
|
||||||
|
|
||||||
|
TileGenericPipe pipe = (TileGenericPipe) entity;
|
||||||
|
if (pipe.pipe == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(pipe.pipe.transport instanceof PipeTransportPower))
|
||||||
|
return;
|
||||||
|
|
||||||
|
((PipeTransportPower) pipe.pipe.transport).handlePowerPacket(packetPower);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates contents of a diamond pipe.
|
* Updates contents of a diamond pipe.
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,6 +5,8 @@ public class PacketIds {
|
||||||
public static final int TILE_UPDATE = 0;
|
public static final int TILE_UPDATE = 0;
|
||||||
public static final int PIPE_DESCRIPTION = 1;
|
public static final int PIPE_DESCRIPTION = 1;
|
||||||
public static final int PIPE_CONTENTS = 2;
|
public static final int PIPE_CONTENTS = 2;
|
||||||
|
public static final int PIPE_LIQUID = 3;
|
||||||
|
public static final int PIPE_POWER = 4;
|
||||||
public static final int SELECTION_ASSEMBLY_GET = 20;
|
public static final int SELECTION_ASSEMBLY_GET = 20;
|
||||||
public static final int SELECTION_ASSEMBLY = 21;
|
public static final int SELECTION_ASSEMBLY = 21;
|
||||||
public static final int DIAMOND_PIPE_CONTENTS = 30;
|
public static final int DIAMOND_PIPE_CONTENTS = 30;
|
||||||
|
|
|
@ -283,8 +283,6 @@ public class PipeTransportLiquids extends PipeTransport implements ILiquidContai
|
||||||
return;
|
return;
|
||||||
|
|
||||||
moveLiquids();
|
moveLiquids();
|
||||||
|
|
||||||
this.container.synchronizeIfDelay(1 * BuildCraftCore.updateFactor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,9 +23,13 @@ import net.minecraft.src.buildcraft.core.CoreProxy;
|
||||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||||
import net.minecraft.src.buildcraft.core.IMachine;
|
import net.minecraft.src.buildcraft.core.IMachine;
|
||||||
import net.minecraft.src.buildcraft.core.Utils;
|
import net.minecraft.src.buildcraft.core.Utils;
|
||||||
|
import net.minecraft.src.buildcraft.transport.network.PacketPowerUpdate;
|
||||||
|
|
||||||
public class PipeTransportPower extends PipeTransport {
|
public class PipeTransportPower extends PipeTransport {
|
||||||
|
|
||||||
|
@TileNetworkData(staticSize = 6)
|
||||||
|
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
public int[] powerQuery = new int[6];
|
public int[] powerQuery = new int[6];
|
||||||
public int[] nextPowerQuery = new int[6];
|
public int[] nextPowerQuery = new int[6];
|
||||||
public long currentDate;
|
public long currentDate;
|
||||||
|
@ -33,9 +37,6 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
public double[] internalPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
public double[] internalPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
||||||
public double[] internalNextPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
public double[] internalNextPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
||||||
|
|
||||||
@TileNetworkData(staticSize = 6)
|
|
||||||
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
public double powerResitance = 0.01;
|
public double powerResitance = 0.01;
|
||||||
|
|
||||||
public PipeTransportPower() {
|
public PipeTransportPower() {
|
||||||
|
@ -151,9 +152,13 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (APIProxy.isServerSide())
|
if (APIProxy.isServerSide())
|
||||||
if (tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor))
|
if (tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)){
|
||||||
CoreProxy.sendToPlayers(this.container.getUpdatePacket(), worldObj, xCoord, yCoord, zCoord,
|
|
||||||
|
PacketPowerUpdate packet = new PacketPowerUpdate(xCoord, yCoord, zCoord);
|
||||||
|
packet.displayPower = displayPower;
|
||||||
|
CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
|
||||||
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
|
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,4 +235,12 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
return with instanceof PipeTransportPower;
|
return with instanceof PipeTransportPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client-side handler for receiving power updates from the server;
|
||||||
|
* @param packetPower
|
||||||
|
*/
|
||||||
|
public void handlePowerPacket(PacketPowerUpdate packetPower) {
|
||||||
|
displayPower = packetPower.displayPower;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,13 +101,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void synchronizeIfDelay(int delay) {
|
|
||||||
if (APIProxy.isServerSide())
|
|
||||||
if (networkSyncTracker.markTimeIfDelay(worldObj, delay))
|
|
||||||
CoreProxy.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE,
|
|
||||||
mod_BuildCraftCore.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
initialized = false;
|
initialized = false;
|
||||||
|
@ -369,30 +362,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
||||||
|
|
||||||
|
|
||||||
return;
|
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
|
|
||||||
public void handleUpdatePacket(PacketUpdate packet) {
|
|
||||||
if (BlockGenericPipe.isValid(pipe))
|
|
||||||
pipe.handlePacket(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
//@Override
|
|
||||||
public Packet getUpdatePacket() {
|
|
||||||
return null;
|
|
||||||
//return new PacketTileUpdate(this).getPacket();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Packet getDescriptionPacket() {
|
public Packet getDescriptionPacket() {
|
||||||
|
@ -495,7 +464,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
||||||
Position pos = new Position(xCoord, yCoord, zCoord, Orientations.values()[i]);
|
Position pos = new Position(xCoord, yCoord, zCoord, Orientations.values()[i]);
|
||||||
pos.moveForwards(1.0);
|
pos.moveForwards(1.0);
|
||||||
scheduleRenderUpdate();
|
scheduleRenderUpdate();
|
||||||
//worldObj.markBlockAsNeedsUpdate((int) pos.x, (int) pos.y, (int) pos.z);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package net.minecraft.src.buildcraft.transport.network;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.src.buildcraft.core.network.PacketCoordinates;
|
||||||
|
import net.minecraft.src.buildcraft.core.network.PacketIds;
|
||||||
|
|
||||||
|
public class PacketPowerUpdate extends PacketCoordinates {
|
||||||
|
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
public PacketPowerUpdate(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketPowerUpdate(int x, int y, int z) {
|
||||||
|
super(PacketIds.PIPE_POWER, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readData(DataInputStream data) throws IOException {
|
||||||
|
super.readData(data);
|
||||||
|
for (int i = 0; i < displayPower.length; i++){
|
||||||
|
displayPower[i] = data.readShort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeData(DataOutputStream data) throws IOException {
|
||||||
|
super.writeData(data);
|
||||||
|
for (int i = 0; i < displayPower.length; i++){
|
||||||
|
data.writeShort(displayPower[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -99,6 +99,7 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
||||||
|
|
||||||
pow.receiveEnergy(o.reverse(), energyUsed);
|
pow.receiveEnergy(o.reverse(), energyUsed);
|
||||||
|
|
||||||
|
if (worldObj.isRemote) return;
|
||||||
((PipeTransportPower) transport).displayPower[o.ordinal()] += energyUsed;
|
((PipeTransportPower) transport).displayPower[o.ordinal()] += energyUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue