use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class PipeFlowFluids method writePayload.
@Override
public void writePayload(int id, PacketBuffer buf, Side side) {
PacketBufferBC buffer = PacketBufferBC.asPacketBufferBc(buf);
if (side == Side.SERVER) {
if (id == NET_FLUID_AMOUNTS || id == NET_ID_FULL_STATE) {
boolean full = id == NET_ID_FULL_STATE;
if (currentFluid == null) {
buffer.writeBoolean(false);
} else {
buffer.writeBoolean(true);
buffer.writeInt(BuildCraftObjectCaches.CACHE_FLUIDS.server().store(currentFluid));
}
for (EnumPipePart part : EnumPipePart.VALUES) {
Section section = sections.get(part);
if (full) {
buffer.writeShort(section.amount);
} else if (section.amount == section.lastSentAmount) {
buffer.writeBoolean(false);
} else {
buffer.writeBoolean(true);
buffer.writeShort(section.amount);
section.lastSentAmount = section.amount;
}
Dir should = Dir.get(section.ticksInDirection);
// This writes out 2 bits so don't bother with a boolean flag
buffer.writeEnumValue(should);
section.lastSentDirection = should;
}
}
}
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class PluggablePulsar method writeData.
private void writeData(PacketBuffer b) {
PacketBufferBC buffer = PacketBufferBC.asPacketBufferBc(b);
buffer.writeBoolean(isPulsing());
buffer.writeBoolean(gateEnabledTicks > 0 || gateSinglePulses > 0);
buffer.writeBoolean(manuallyEnabled);
buffer.writeByte(pulseStage);
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class PluggablePulsar method readData.
private void readData(PacketBuffer b) {
PacketBufferBC buffer = PacketBufferBC.asPacketBufferBc(b);
isPulsing = buffer.readBoolean();
autoEnabled = buffer.readBoolean();
manuallyEnabled = buffer.readBoolean();
pulseStage = buffer.readByte();
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class ContainerBC_Neptune method sendMessage.
public final void sendMessage(int id, IPayloadWriter writer) {
PacketBufferBC payload = PacketBufferBC.write(writer);
MessageContainer message = new MessageContainer(windowId, id, payload);
if (player.world.isRemote) {
MessageManager.sendToServer(message);
} else {
MessageManager.sendTo(message, (EntityPlayerMP) player);
}
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class PacketBufferBcTest method testAmongst.
@Test
public void testAmongst() {
PacketBufferBC buffer = new PrintingByteBuf(Unpooled.buffer());
buffer.writeInt(49);
buffer.writeBoolean(true);
buffer.writeShort(95);
buffer.writeBoolean(false);
buffer.writeByte(11);
buffer.writeBoolean(true);
byte[] expected = { // writeInt(49)
0, 0, 0, 49, // flag(true, false, true)
1 + 4, // writeShort(95)
0, 95, // writeByte(11)
11 };
byte[] read = new byte[expected.length];
buffer.getBytes(0, read);
Assert.assertArrayEquals(expected, read);
Assert.assertEquals(49, buffer.readInt());
Assert.assertTrue(buffer.readBoolean());
Assert.assertEquals(95, buffer.readShort());
Assert.assertFalse(buffer.readBoolean());
Assert.assertEquals(11, buffer.readByte());
Assert.assertTrue(buffer.readBoolean());
}
Aggregations