Search in sources :

Example 56 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project TUMAT by canitzp.

the class PacketSyncEnergyClient method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    PacketBuffer buffer = new PacketBuffer(buf);
    buffer.writeBlockPos(this.pos);
    buffer.writeInt(this.currentEnergy);
    buffer.writeInt(this.capEnergy);
    buffer.writeInt(this.side.ordinal());
}
Also used : PacketBuffer(net.minecraft.network.PacketBuffer)

Example 57 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project TUMAT by canitzp.

the class PacketUpdateTileEntity method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    PacketBuffer buffer = new PacketBuffer(buf);
    this.pos = buffer.readBlockPos();
    int size = buffer.readInt();
    String[] nbtKeys = new String[size];
    for (int i = 0; i < size; i++) {
        nbtKeys[i] = buffer.readString(Short.MAX_VALUE);
    }
    this.nbtKeys = nbtKeys;
}
Also used : PacketBuffer(net.minecraft.network.PacketBuffer)

Example 58 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project TUMAT by canitzp.

the class PacketUpdateTileEntity method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    PacketBuffer buffer = new PacketBuffer(buf);
    buffer.writeBlockPos(this.pos);
    buffer.writeInt(this.nbtKeys.length);
    for (String s : this.nbtKeys) {
        buffer.writeString(s);
    }
}
Also used : PacketBuffer(net.minecraft.network.PacketBuffer)

Example 59 with PacketBuffer

use of net.minecraft.network.PacketBuffer in project Galacticraft by micdoodle8.

the class ConnectionPacket method createConfigPacket.

public static FMLProxyPacket createConfigPacket(List<Object> data) {
    PacketBuffer payload = new PacketBuffer(Unpooled.buffer());
    payload.writeByte(103);
    try {
        NetworkUtil.encodeData(payload, data);
    } catch (IOException e) {
        e.printStackTrace();
    }
    // signature
    payload.writeInt(3519);
    return new FMLProxyPacket(payload, CHANNEL);
}
Also used : FMLProxyPacket(net.minecraftforge.fml.common.network.internal.FMLProxyPacket) IOException(java.io.IOException) PacketBuffer(net.minecraft.network.PacketBuffer)

Example 60 with PacketBuffer

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

the class ByteBufUtils method writeItemStack.

/**
     * Write an {@link ItemStack} using minecraft compatible encoding.
     *
     * @param to The buffer to write to
     * @param stack The itemstack to write
     */
public static void writeItemStack(ByteBuf to, ItemStack stack) {
    PacketBuffer pb = new PacketBuffer(to);
    pb.writeItemStack(stack);
}
Also used : PacketBuffer(net.minecraft.network.PacketBuffer)

Aggregations

PacketBuffer (net.minecraft.network.PacketBuffer)105 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)20 IOException (java.io.IOException)14 FMLProxyPacket (net.minecraftforge.fml.common.network.internal.FMLProxyPacket)14 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