Search in sources :

Example 41 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project BuildCraft by BuildCraft.

the class MessageUpdateTile method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    MessageUtil.writeBlockPos(new PacketBuffer(buf), pos);
    int length = payload.readableBytes();
    buf.writeMedium(length);
    buf.writeBytes(payload, 0, length);
}
Also used : PacketBuffer(net.minecraft.network.PacketBuffer)

Example 42 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project BuildCraft by BuildCraft.

the class Lock method toBytes.

public void toBytes(PacketBuffer buf) {
    new PacketBufferBC(buf).writeEnumValue(Cause.EnumCause.getForClass(cause.getClass()));
    cause.toBytes(buf);
    buf.writeInt(targets.size());
    targets.forEach(target -> {
        new PacketBuffer(buf).writeEnumValue(Target.EnumTarget.getForClass(target.getClass()));
        target.toBytes(buf);
    });
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC) PacketBuffer(net.minecraft.network.PacketBuffer)

Example 43 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project BuildCraft by BuildCraft.

the class Lock method fromBytes.

public void fromBytes(PacketBuffer buf) {
    cause = new PacketBufferBC(buf).readEnumValue(Cause.EnumCause.class).supplier.get();
    cause.fromBytes(buf);
    targets.clear();
    IntStream.range(0, buf.readInt()).mapToObj(i -> {
        Target target;
        target = new PacketBufferBC(buf).readEnumValue(Target.EnumTarget.class).supplier.get();
        target.fromBytes(buf);
        return target;
    }).forEach(targets::add);
}
Also used : IntStream(java.util.stream.IntStream) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketBufferBC(buildcraft.lib.net.PacketBufferBC) Arrays(java.util.Arrays) World(net.minecraft.world.World) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) BlockPos(net.minecraft.util.math.BlockPos) Supplier(java.util.function.Supplier) BuildCraftLaserManager(buildcraft.core.client.BuildCraftLaserManager) ArrayList(java.util.ArrayList) NBTUtilBC(buildcraft.lib.misc.NBTUtilBC) List(java.util.List) Block(net.minecraft.block.Block) Side(net.minecraftforge.fml.relauncher.Side) MessageUtil(buildcraft.lib.misc.MessageUtil) ResourceLocation(net.minecraft.util.ResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) NBTUtil(net.minecraft.nbt.NBTUtil) PacketBuffer(net.minecraft.network.PacketBuffer) PacketBufferBC(buildcraft.lib.net.PacketBufferBC)

Example 44 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project BuildCraft by BuildCraft.

the class MessageZoneMapResponse method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    key.toBytes(buf);
    data.write(new PacketBuffer(buf));
}
Also used : PacketBuffer(net.minecraft.network.PacketBuffer)

Example 45 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class MessagePlayerStoppedPiloting method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    PacketBuffer packetBuf = new PacketBuffer(buf);
    final boolean isBlockPos = packetBuf.readBoolean();
    final boolean isUUID = packetBuf.readBoolean();
    if (isBlockPos) {
        posToStopPiloting = new BlockPos(packetBuf.readInt(), packetBuf.readInt(), packetBuf.readInt());
    }
    if (isUUID) {
        shipIDToStopPiloting = packetBuf.readUniqueId();
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) PacketBuffer(net.minecraft.network.PacketBuffer)

Aggregations

PacketBuffer (net.minecraft.network.PacketBuffer)103 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)18 FMLProxyPacket (net.minecraftforge.fml.common.network.internal.FMLProxyPacket)14 IOException (java.io.IOException)13 ByteBuf (io.netty.buffer.ByteBuf)11 SPacketCustomPayload (net.minecraft.network.play.server.SPacketCustomPayload)7 BlockPos (net.minecraft.util.math.BlockPos)7 HashMap (java.util.HashMap)4 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)4 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)4 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)3 Test (org.junit.Test)3 PacketBufferBC (buildcraft.lib.net.PacketBufferBC)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 PacketCustomTileData (gregtech.api.net.PacketCustomTileData)2 PacketUIWidgetUpdate (gregtech.api.net.PacketUIWidgetUpdate)2 AbstractData (hellfirepvp.fracture.common.data.AbstractData)2