void DataWatcher::write(PacketBuffer &buffer) { for (byte_t index = 0; index < 23; ++index) { if (type[index] == NONE) continue; buffer.putByte(type[index] << 5 | (index & 0x1f)); switch (type[index]) { case BYTE: buffer.putByte(getByte(index)); break; case SHORT: buffer.putShort(getShort(index)); break; case INT: buffer.putInt(getInt(index)); break; case FLOAT: buffer.putFloat(getFloat(index)); break; case STRING: buffer.putString(getString(index)); break; case ITEMSTACK: buffer.putItemStack(getItemStack(index)); break; } } buffer.putByte(0x7f); }
void PacketSetSlot::write(PacketBuffer &buffer) { buffer.putByte(windowId); buffer.putShort(slot); buffer.putItemStack(stack); }