int slot = buffer.readUnsignedShort();
boolean rightClick = buffer.readUnsignedByte() != 0;
int transaction = buffer.readUnsignedShort();
int item = buffer.readUnsignedShort();
if (item == 0xFFFF) {
return new WindowClickMessage(id, slot, rightClick, transaction);
} else {
int count = buffer.readUnsignedByte();
int damage = buffer.readUnsignedByte();
return new WindowClickMessage(id, slot, rightClick, transaction, item, count, damage);
}
}