Java Code Examples for net.minecraftforge.fml.common.network.ByteBufUtils#readTag()

The following examples show how to use net.minecraftforge.fml.common.network.ByteBufUtils#readTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PacketUpdateGui.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
public static Object readField(ByteBuf buf, int type){

        switch(type){
            case 0:
                return buf.readInt();
            case 1:
                return buf.readFloat();
            case 2:
                return buf.readDouble();
            case 3:
                return buf.readBoolean();
            case 4:
                return ByteBufUtils.readUTF8String(buf);
            case 5:
                return buf.readByte();
            case 6:
                return ByteBufUtils.readItemStack(buf);
            case 7:
                if(!buf.readBoolean()) return null;
                return new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), ByteBufUtils.readTag(buf));
            default:
                throw new IllegalArgumentException("Invalid sync type! " + type);
        }
    }
 
Example 2
Source File: BlockStorage.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void fromBuf(ByteBuf buf, World world) {
	blockstate = Block.getStateById(buf.readInt());
	light = buf.readInt();
	NBTTagCompound tag = ByteBufUtils.readTag(buf); 
	if(tag != null) {
		tileentity = TileEntity.create(world, tag);
	}
}
 
Example 3
Source File: PacketSyncContainerFluid.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
    windowId = buf.readByte();
    tank = buf.readByte();

    NBTTagCompound fluidNbt = ByteBufUtils.readTag(buf);
    fluid = FluidStack.loadFluidStackFromNBT(fluidNbt);
}
 
Example 4
Source File: MessageNBTUpdate.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
	this.x = buf.readInt();
	this.y = buf.readInt();
	this.z = buf.readInt();
	this.tag = ByteBufUtils.readTag(buf);
}
 
Example 5
Source File: PacketDescription.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf){

    super.fromBytes(buf);
    type = IDescSynced.Type.values()[buf.readByte()];
    int dataAmount = buf.readInt();
    types = new byte[dataAmount];
    values = new Object[dataAmount];
    for(int i = 0; i < dataAmount; i++) {
        types[i] = buf.readByte();
        values[i] = PacketUpdateGui.readField(buf, types[i]);
    }
    extraData = ByteBufUtils.readTag(buf);
}
 
Example 6
Source File: MerchantRecipes.java    From HoloInventory with MIT License 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
    super.fromBytes(buf);
    name = ByteBufUtils.readUTF8String(buf);
    tag = ByteBufUtils.readTag(buf);
}
 
Example 7
Source File: MessageProcessorUpdate.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
  processorData = ByteBufUtils.readTag(buf);
  pos = BlockPos.fromLong(buf.readLong());
  name = ByteBufUtils.readUTF8String(buf);
}
 
Example 8
Source File: SyncHudDataPacket.java    From Cyberware with MIT License 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
	comp = ByteBufUtils.readTag(buf);
}
 
Example 9
Source File: CyberwareSyncPacket.java    From Cyberware with MIT License 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
	entityId = buf.readInt();
	data = ByteBufUtils.readTag(buf);
}
 
Example 10
Source File: MessagePipeContentUpdate.java    From Logistics-Pipes-2 with MIT License 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
	tag = ByteBufUtils.readTag(buf);
}
 
Example 11
Source File: MessageBase.java    From Production-Line with MIT License 4 votes vote down vote up
/**
 * Convert from the supplied buffer into your specific message type
 */
@Override
public final void fromBytes(ByteBuf buf) {
    this.nbt = ByteBufUtils.readTag(buf);
}