List of usage examples for io.netty.buffer ByteBuf readInt
public abstract int readInt();
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 www . jav a2 s . 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 {//w w w . j a v a2 s .c o m return Block.getBlockById(data.readInt()); } }
From source file:buildcraft.core.network.serializers.SerializerInteger.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { return new Integer(data.readInt()); }
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 {/* www . j a v a 2 s . c o m*/ return Item.getItemById(data.readInt()); } }
From source file:buildcraft.core.network.TilePacketWrapper.java
License:Minecraft Mod Public
public void fromPayload(TileEntity tile, PacketPayload packet) { try {/*from ww w . ja va2 s . c om*/ ByteBuf data = packet.stream; data.readInt(); data.readInt(); data.readInt(); SerializationContext context = new SerializationContext(); rootMappings[0].read(data, tile, context); } catch (Exception e) { e.printStackTrace(); } }
From source file:buildcraft.core.network.TilePacketWrapper.java
License:Minecraft Mod Public
public void fromPayload(Object[] obj, PacketPayload packet) { try {/*from www . j a va2s . co m*/ ByteBuf data = packet.stream; data.readInt(); data.readInt(); data.readInt(); for (int i = 0; i < rootMappings.length; ++i) { SerializationContext context = new SerializationContext(); rootMappings[i].read(data, obj[i], context); } } catch (Exception e) { e.printStackTrace(); } }
From source file:buildcraft.core.utils.Utils.java
License:Minecraft Mod Public
public static String readUTF(ByteBuf data) { try {/*from w w w. j av a 2s .c o m*/ int len = data.readInt(); byte[] b = new byte[len]; data.readBytes(b); return new String(b, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; } }
From source file:buildcraft.core.utils.Utils.java
License:Minecraft Mod Public
public static NBTTagCompound readNBT(ByteBuf data) { try {/*from w w w . ja v a 2 s.c o m*/ int length = data.readInt(); byte[] compressed = new byte[length]; data.readBytes(compressed); return CompressedStreamTools.func_152457_a(compressed, NBTSizeTracker.field_152451_a); } catch (IOException e) { e.printStackTrace(); return null; } }
From source file:buildcraft.core.ZonePlan.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { chunkMapping.clear();/*from ww w . ja v a 2s .c o m*/ int size = stream.readInt(); for (int i = 0; i < size; i++) { ChunkIndex key = new ChunkIndex(); ZoneChunk value = new ZoneChunk(); key.readData(stream); value.readData(stream); chunkMapping.put(key, value); } }
From source file:buildcraft.factory.TilePump.java
License:Minecraft Mod Public
@Override public void handleUpdatePacket(PacketUpdate packet) throws IOException { PacketPayload payload = packet.payload; ByteBuf data = payload.stream; aimY = data.readInt(); tubeY = data.readFloat();// w w w . j a v a 2s . c o m powered = data.readBoolean(); setTubePosition(); }