public SetWindowSlotMessage decode(ChannelBuffer buffer) throws IOException {
int id = buffer.readUnsignedByte();
int slot = buffer.readUnsignedShort();
int item = buffer.readUnsignedShort();
if (item == 0xFFFF) {
return new SetWindowSlotMessage(id, slot);
} else {
int count = buffer.readUnsignedByte();
int damage = buffer.readUnsignedByte();
return new SetWindowSlotMessage(id, slot, item, count, damage);
}
}