Search in sources :

Example 6 with PacketBufferBC

use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.

the class TileBC_Neptune method handleUpdateTag.

@Override
public void handleUpdateTag(NBTTagCompound tag) {
    super.readFromNBT(tag);
    byte[] bytes = tag.getByteArray("d");
    ByteBuf buf = Unpooled.copiedBuffer(bytes);
    try {
        int id = buf.readUnsignedShort();
        PacketBufferBC buffer = new PacketBufferBC(buf);
        readPayload(id, buffer, world.isRemote ? Side.CLIENT : Side.SERVER, null);
        // Make sure that we actually read the entire message rather than just discarding it
        MessageUtil.ensureEmpty(buffer, world.isRemote, getClass() + ", id = " + getIdAllocator().getNameFor(id));
        spawnReceiveParticles(id);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC) IOException(java.io.IOException) ByteBuf(io.netty.buffer.ByteBuf)

Example 7 with PacketBufferBC

use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.

the class MessageUtil method writeEnumSet.

public static <E extends Enum<E>> void writeEnumSet(ByteBuf buffer, Set<E> set, Class<E> clazz) {
    PacketBufferBC buf = PacketBufferBC.asPacketBufferBc(buffer);
    E[] constants = clazz.getEnumConstants();
    if (constants == null)
        throw new IllegalArgumentException("Not an enum type " + clazz);
    for (E e : constants) {
        buf.writeBoolean(set.contains(e));
    }
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC)

Example 8 with PacketBufferBC

use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.

the class PipeBehaviourDirectional method writePayload.

@Override
public void writePayload(PacketBuffer buffer, Side side) {
    super.writePayload(buffer, side);
    PacketBufferBC bufBc = PacketBufferBC.asPacketBufferBc(buffer);
    bufBc.writeEnumValue(currentDir);
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC)

Example 9 with PacketBufferBC

use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.

the class PluggableFacade method writeCreationPayload.

@Override
public void writeCreationPayload(PacketBuffer buffer) {
    PacketBufferBC buf = PacketBufferBC.asPacketBufferBc(buffer);
    states.writeToBuffer(buf);
    buf.writeBoolean(isSideSolid);
    buf.writeEnumValue(blockFaceShape);
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC)

Example 10 with PacketBufferBC

use of buildcraft.lib.net.PacketBufferBC in project BuildCraft by BuildCraft.

the class PluggableLens method writeCreationPayload.

@Override
public void writeCreationPayload(PacketBuffer buffer) {
    PacketBufferBC buf = PacketBufferBC.asPacketBufferBc(buffer);
    MessageUtil.writeEnumOrNull(buf, colour);
    buf.writeBoolean(isFilter);
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC)

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