Search in sources :

Example 1 with PacketBufferBC

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();
        }
    }
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC) EnumPipePart(buildcraft.api.core.EnumPipePart)

Example 2 with PacketBufferBC

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);
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC)

Example 3 with PacketBufferBC

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);
        }
    }
}
Also used : EnumAccess(buildcraft.lib.tile.item.ItemHandlerManager.EnumAccess) IFillerPattern(buildcraft.api.filler.IFillerPattern) ItemHandlerSimple(buildcraft.lib.tile.item.ItemHandlerSimple) FillerType(buildcraft.builders.filler.FillerType) Side(net.minecraftforge.fml.relauncher.Side) TilesAPI(buildcraft.api.tiles.TilesAPI) EnumAddonSlot(buildcraft.core.marker.volume.EnumAddonSlot) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) Template(buildcraft.builders.snapshot.Template) IBox(buildcraft.api.core.IBox) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) AddonFillerPlanner(buildcraft.builders.addon.AddonFillerPlanner) PacketBufferBC(buildcraft.lib.net.PacketBufferBC) VolumeBox(buildcraft.core.marker.volume.VolumeBox) TileBC_Neptune(buildcraft.lib.tile.TileBC_Neptune) UUID(java.util.UUID) List(java.util.List) BlockBCBase_Neptune(buildcraft.lib.block.BlockBCBase_Neptune) MessageContext(net.minecraftforge.fml.common.network.simpleimpl.MessageContext) MjBattery(buildcraft.api.mj.MjBattery) Optional(java.util.Optional) ItemBlocks(buildcraft.builders.snapshot.ItemBlocks) IFillerStatementContainer(buildcraft.api.statements.containers.IFillerStatementContainer) MjAPI(buildcraft.api.mj.MjAPI) EnumPipePart(buildcraft.api.core.EnumPipePart) IntStream(java.util.stream.IntStream) Box(buildcraft.lib.misc.data.Box) TemplateBuilder(buildcraft.builders.snapshot.TemplateBuilder) IAreaProvider(buildcraft.api.core.IAreaProvider) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ITileForTemplateBuilder(buildcraft.builders.snapshot.ITileForTemplateBuilder) WorldSavedDataVolumeBoxes(buildcraft.core.marker.volume.WorldSavedDataVolumeBoxes) ItemStack(net.minecraft.item.ItemStack) NBTUtilBC(buildcraft.lib.misc.NBTUtilBC) MjBatteryReceiver(buildcraft.lib.mj.MjBatteryReceiver) BoundingBoxUtil(buildcraft.lib.misc.BoundingBoxUtil) IStatementParameter(buildcraft.api.statements.IStatementParameter) ITickable(net.minecraft.util.ITickable) BuildingInfo(buildcraft.builders.snapshot.Template.BuildingInfo) MessageManager(buildcraft.lib.net.MessageManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) FullStatement(buildcraft.lib.statement.FullStatement) FillerUtil(buildcraft.builders.filler.FillerUtil) IdAllocator(buildcraft.lib.misc.data.IdAllocator) World(net.minecraft.world.World) IDebuggable(buildcraft.api.tiles.IDebuggable) EnumFacing(net.minecraft.util.EnumFacing) MjCapabilityHelper(buildcraft.api.mj.MjCapabilityHelper) IOException(java.io.IOException) BlockPos(net.minecraft.util.math.BlockPos) ClientVolumeBoxes(buildcraft.core.marker.volume.ClientVolumeBoxes) IBlockState(net.minecraft.block.state.IBlockState) IControllable(buildcraft.api.tiles.IControllable) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Lock(buildcraft.core.marker.volume.Lock) TileEntity(net.minecraft.tileentity.TileEntity) SnapshotBuilder(buildcraft.builders.snapshot.SnapshotBuilder) IItemTransactor(buildcraft.api.inventory.IItemTransactor) VolumeBox(buildcraft.core.marker.volume.VolumeBox) EnumAddonSlot(buildcraft.core.marker.volume.EnumAddonSlot) UUID(java.util.UUID)

Example 4 with PacketBufferBC

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);
}
Also used : MessageUpdateTile(buildcraft.lib.net.MessageUpdateTile) PacketBufferBC(buildcraft.lib.net.PacketBufferBC)

Example 5 with PacketBufferBC

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;
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

PacketBufferBC (buildcraft.lib.net.PacketBufferBC)31 Test (org.junit.Test)6 EnumPipePart (buildcraft.api.core.EnumPipePart)4 IOException (java.io.IOException)4 List (java.util.List)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 NBTUtilBC (buildcraft.lib.misc.NBTUtilBC)3 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 IntStream (java.util.stream.IntStream)3 EnumDyeColor (net.minecraft.item.EnumDyeColor)3 EnumFacing (net.minecraft.util.EnumFacing)3 BlockPos (net.minecraft.util.math.BlockPos)3 World (net.minecraft.world.World)3 Side (net.minecraftforge.fml.relauncher.Side)3 Box (buildcraft.lib.misc.data.Box)2 ByteBuf (io.netty.buffer.ByteBuf)2 ItemStack (net.minecraft.item.ItemStack)2 NBTUtil (net.minecraft.nbt.NBTUtil)2 PacketBuffer (net.minecraft.network.PacketBuffer)2