void DataWatcher::read(PacketBuffer &buffer) { byte_t item, index; do { buffer.getByte(item); if (item == 0x7f) break; index = item & 0x1f; switch (item >> 5) { case BYTE: { byte_t b; buffer.getByte(b); setByte(index, b); break; } case SHORT: { short_t s; buffer.getShort(s); setShort(index, s); break; } case INT: { int_t i; buffer.getInt(i); setInt(index, i); break; } case FLOAT: { float_t f; buffer.getFloat(f); setFloat(index, f); break; } case STRING: { string_t str; buffer.getString(str); setString(index, str); break; } case ITEMSTACK: { std::shared_ptr<ItemStack> stack; buffer.getItemStack(stack); setItemStack(index, stack); break; } } } while (true); }
void PacketLoginStart::read(PacketBuffer &buffer) { buffer.getString(name); }