use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class PipeFlowFluids method readPayload.
@Override
public void readPayload(int id, PacketBuffer buf, Side side) throws IOException {
PacketBufferBC buffer = PacketBufferBC.asPacketBufferBc(buf);
if (side == Side.CLIENT) {
if (id == NET_FLUID_AMOUNTS || id == NET_ID_FULL_STATE) {
boolean full = id == NET_ID_FULL_STATE;
if (buffer.readBoolean()) {
int fluidId = buffer.readInt();
clientFluid = BuildCraftObjectCaches.CACHE_FLUIDS.client().retrieve(fluidId);
}
for (EnumPipePart part : EnumPipePart.VALUES) {
Section section = sections.get(part);
if (full || buffer.readBoolean()) {
section.target = buffer.readShort();
if (full) {
section.clientAmountLast = section.clientAmountThis = section.target;
}
}
Dir dir = buffer.readEnumValue(Dir.class);
section.ticksInDirection = dir == Dir.NONE ? 0 : dir == Dir.IN ? COOLDOWN_INPUT : COOLDOWN_OUTPUT;
}
lastMessageMinus1 = lastMessage;
lastMessage = pipe.getHolder().getPipeWorld().getTotalWorldTime();
}
}
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class PluggableGate method readPayload.
@Override
public void readPayload(PacketBuffer b, Side side, MessageContext ctx) throws IOException {
PacketBufferBC buffer = PacketBufferBC.asPacketBufferBc(b);
int id = buffer.readUnsignedByte();
logic.readPayload(id, buffer, side, ctx);
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class TileFiller method readPayload.
@Override
public void readPayload(int id, PacketBufferBC buffer, Side side, MessageContext ctx) throws IOException {
super.readPayload(id, buffer, side, ctx);
if (side == Side.CLIENT) {
if (id == NET_RENDER_DATA) {
builder.readFromByteBuf(buffer);
readPayload(NET_BOX, buffer, side, ctx);
} else if (id == NET_GUI_DATA || id == NET_GUI_TICK) {
readPayload(NET_CAN_EXCAVATE, buffer, side, ctx);
readPayload(NET_INVERT, buffer, side, ctx);
readPayload(NET_PATTERN, buffer, side, ctx);
builder.readFromByteBuf(buffer);
finished = buffer.readBoolean();
lockedTicks = buffer.readBoolean() ? (byte) 1 : (byte) 0;
mode = buffer.readEnumValue(Mode.class);
} else if (id == NET_BOX) {
box.readData(buffer);
markerBox = buffer.readBoolean();
if (buffer.readBoolean()) {
UUID volumeBoxId = buffer.readUniqueId();
VolumeBox volumeBox = world.isRemote ? ClientVolumeBoxes.INSTANCE.volumeBoxes.stream().filter(localVolumeBox -> localVolumeBox.id.equals(volumeBoxId)).findFirst().orElseThrow(NullPointerException::new) : WorldSavedDataVolumeBoxes.get(world).getVolumeBoxFromId(volumeBoxId);
addon = (AddonFillerPlanner) volumeBox.addons.get(buffer.readEnumValue(EnumAddonSlot.class));
}
} else if (id == NET_CAN_EXCAVATE) {
canExcavate = buffer.readBoolean();
} else if (id == NET_INVERT) {
inverted = buffer.readBoolean();
} else if (id == NET_PATTERN) {
patternStatement.readFromBuffer(buffer);
}
}
if (side == Side.SERVER) {
if (id == NET_CAN_EXCAVATE) {
canExcavate = buffer.readBoolean();
sendNetworkGuiUpdate(NET_CAN_EXCAVATE);
}
}
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class TileBC_Neptune method createMessage.
public final MessageUpdateTile createMessage(int id, IPayloadWriter writer) {
PacketBufferBC buffer = new PacketBufferBC(Unpooled.buffer());
buffer.writeShort(id);
writer.write(buffer);
return new MessageUpdateTile(pos, buffer);
}
use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.
the class TileBC_Neptune method getUpdateTag.
@Override
public NBTTagCompound getUpdateTag() {
ByteBuf buf = Unpooled.buffer();
buf.writeShort(NET_RENDER_DATA);
writePayload(NET_RENDER_DATA, new PacketBufferBC(buf), world.isRemote ? Side.CLIENT : Side.SERVER);
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
NBTTagCompound nbt = super.getUpdateTag();
nbt.setByteArray("d", bytes);
return nbt;
}
Aggregations