List of usage examples for io.netty.buffer ByteBuf readBoolean
public abstract boolean readBoolean();
From source file:buildcraft.core.network.serializers.SerializerArrayList.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { if (!data.readBoolean()) { return null; } else {/*from ww w . j a v a 2 s . c om*/ int size = data.readShort(); ArrayList list = new ArrayList(); for (int i = 0; i < size; ++i) { Object val = anonymousSerializer.read(data, null, context); list.add(val); } return list; } }
From source file:buildcraft.core.network.serializers.SerializerBitSet.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { if (!data.readBoolean()) { return null; }/*from w ww . ja v a 2s . c o m*/ int actualSize = data.readInt(); byte[] bytes = new byte[actualSize]; data.readBytes(bytes); BitSet set = BitSetUtils.fromByteArray(bytes); return set; }
From source file:buildcraft.core.network.serializers.SerializerBlock.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { if (!data.readBoolean()) { return null; } else {/*from w ww . j av a2 s . c o m*/ return Block.getBlockById(data.readInt()); } }
From source file:buildcraft.core.network.serializers.SerializerFluidStack.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { if (!data.readBoolean()) { return null; } else {/* w ww. j a v a 2 s . com*/ int id = data.readShort(); int amount = data.readerIndex(); NBTTagCompound nbt = null; if (data.readBoolean()) { nbt = Utils.readNBT(data); return new FluidStack(id, amount, nbt); } else { return new FluidStack(id, amount); } } }
From source file:buildcraft.core.network.serializers.SerializerHashMap.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { if (!data.readBoolean()) { return null; } else {/*ww w .j a va2s . c o m*/ int size = data.readShort(); HashMap map = new HashMap(); for (int i = 0; i < size; ++i) { Object key = anonymousSerializer.read(data, null, context); Object value = anonymousSerializer.read(data, null, context); map.put(key, value); } return map; } }
From source file:buildcraft.core.network.serializers.SerializerHashSet.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { if (!data.readBoolean()) { return null; } else {// w w w .j a va2s . c o m int size = data.readShort(); HashSet<Object> set = new HashSet<Object>(); for (int i = 0; i < size; ++i) { Object value = anonymousSerializer.read(data, null, context); set.add(value); } return set; } }
From source file:buildcraft.core.network.serializers.SerializerIStatementParameter.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { if (!data.readBoolean()) { return null; } else {//from www .ja v a 2 s .c om String kind = Utils.readUTF(data); IStatementParameter parameter = StatementManager.createParameter(kind); parameter.readFromNBT(Utils.readNBT(data)); return parameter; } }
From source file:buildcraft.core.network.serializers.SerializerItem.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { if (!data.readBoolean()) { return null; } else {//from ww w.j a v a 2s . c o m return Item.getItemById(data.readInt()); } }
From source file:buildcraft.core.network.serializers.SerializerItemStack.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { if (!data.readBoolean()) { return null; } else {//from w w w . j a v a 2 s. c o m return ItemStack.loadItemStackFromNBT(Utils.readNBT(data)); } }
From source file:buildcraft.core.network.serializers.SerializerLinkedList.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { if (!data.readBoolean()) { return null; } else {/*from ww w . j a v a2s.c o m*/ int size = data.readShort(); LinkedList list = new LinkedList(); for (int i = 0; i < size; ++i) { Object val = anonymousSerializer.read(data, null, context); list.add(val); } return list; } }