@Override public void readData(ByteBuf data) { super.readData(data); state = Unpooled.buffer(); int length = data.readInt(); state.writeBytes(data.readBytes(length)); }
@Override public void readData(DataInputStream data) throws IOException { super.readData(data); slot = data.readInt(); final int id = data.readInt(); if (id != 0) { stack = new ItemStack(id, data.readInt(), data.readInt()); } else { stack = null; } }
@Override public void writeData(DataOutputStream data) throws IOException { super.writeData(data); data.writeInt(slot); if (stack != null) { data.writeInt(stack.itemID); data.writeInt(stack.stackSize); data.writeInt(stack.getItemDamage()); } else { data.writeInt(0); } }
@Override public void writeData(ByteBuf data) { super.writeData(data); ByteBuf tmpState = Unpooled.buffer(); tmpState.writeByte(stateList.size()); for (StateWithId stateWithId : stateList) { tmpState.writeByte(stateWithId.stateId); stateWithId.state.writeData(tmpState); } data.writeInt(tmpState.readableBytes()); data.writeBytes(tmpState.readBytes(tmpState.readableBytes())); }