--- a/net/minecraft/network/FriendlyByteBuf.java
+++ b/net/minecraft/network/FriendlyByteBuf.java
@@ -37,6 +37,7 @@
 import java.util.Collection;
 import java.util.Date;
 import java.util.EnumSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -63,6 +64,7 @@
 import net.minecraft.nbt.NbtIo;
 import net.minecraft.nbt.Tag;
 import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
 import net.minecraft.resources.ResourceKey;
 import net.minecraft.resources.ResourceLocation;
 import net.minecraft.util.Crypt;
@@ -78,10 +80,14 @@
 import org.joml.Quaternionf;
 import org.joml.Vector3f;
 
+import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack; // CraftBukkit
+
 public class FriendlyByteBuf extends ByteBuf {
+
     public static final int DEFAULT_NBT_QUOTA = 2097152;
     private final ByteBuf source;
-    public static final short MAX_STRING_LENGTH = Short.MAX_VALUE;
+    public java.util.Locale adventure$locale; // Paper
+    public static final short MAX_STRING_LENGTH = 32767;
     public static final int MAX_COMPONENT_STRING_LENGTH = 262144;
     private static final int PUBLIC_KEY_SIZE = 256;
     private static final int MAX_PUBLIC_KEY_HEADER_SIZE = 256;
@@ -101,39 +107,44 @@
     /** @deprecated */
     @Deprecated
     public <T> T readWithCodec(DynamicOps<Tag> ops, Codec<T> codec, NbtAccounter sizeTracker) {
-        Tag tag = this.readNbt(sizeTracker);
-        return Util.getOrThrow(codec.parse(ops, tag), (error) -> {
-            return new DecoderException("Failed to decode: " + error + " " + tag);
+        Tag nbtbase = this.readNbt(sizeTracker);
+
+        return Util.getOrThrow(codec.parse(ops, nbtbase), (s) -> {
+            return new DecoderException("Failed to decode: " + s + " " + nbtbase);
         });
     }
 
     /** @deprecated */
     @Deprecated
     public <T> FriendlyByteBuf writeWithCodec(DynamicOps<Tag> ops, Codec<T> codec, T value) {
-        Tag tag = Util.getOrThrow(codec.encodeStart(ops, value), (error) -> {
-            return new EncoderException("Failed to encode: " + error + " " + value);
+        Tag nbtbase = (Tag) Util.getOrThrow(codec.encodeStart(ops, value), (s) -> {
+            return new EncoderException("Failed to encode: " + s + " " + value);
         });
-        this.writeNbt(tag);
+
+        this.writeNbt(nbtbase);
         return this;
     }
 
     public <T> T readJsonWithCodec(Codec<T> codec) {
-        JsonElement jsonElement = GsonHelper.fromJson(GSON, this.readUtf(), JsonElement.class);
-        DataResult<T> dataResult = codec.parse(JsonOps.INSTANCE, jsonElement);
-        return Util.getOrThrow(dataResult, (error) -> {
-            return new DecoderException("Failed to decode json: " + error);
+        JsonElement jsonelement = (JsonElement) GsonHelper.fromJson(FriendlyByteBuf.GSON, this.readUtf(), JsonElement.class);
+        DataResult<T> dataresult = codec.parse(JsonOps.INSTANCE, jsonelement);
+
+        return Util.getOrThrow(dataresult, (s) -> {
+            return new DecoderException("Failed to decode json: " + s);
         });
     }
 
     public <T> void writeJsonWithCodec(Codec<T> codec, T value) {
-        DataResult<JsonElement> dataResult = codec.encodeStart(JsonOps.INSTANCE, value);
-        this.writeUtf(GSON.toJson(Util.getOrThrow(dataResult, (error) -> {
-            return new EncoderException("Failed to encode: " + error + " " + value);
+        DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value);
+
+        this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> {
+            return new EncoderException("Failed to encode: " + s + " " + value);
         })));
     }
 
     public <T> void writeId(IdMap<T> registry, T value) {
         int i = registry.getId(value);
+
         if (i == -1) {
             throw new IllegalArgumentException("Can't find id for '" + value + "' in map " + registry);
         } else {
@@ -145,8 +156,11 @@
         switch (entry.kind()) {
             case REFERENCE:
                 int i = registryEntries.getId(entry);
+
                 if (i == -1) {
-                    throw new IllegalArgumentException("Can't find id for '" + entry.value() + "' in map " + registryEntries);
+                    Object object = entry.value();
+
+                    throw new IllegalArgumentException("Can't find id for '" + object + "' in map " + registryEntries);
                 }
 
                 this.writeVarInt(i + 1);
@@ -161,15 +175,18 @@
     @Nullable
     public <T> T readById(IdMap<T> registry) {
         int i = this.readVarInt();
+
         return registry.byId(i);
     }
 
     public <T> Holder<T> readById(IdMap<Holder<T>> registryEntries, FriendlyByteBuf.Reader<T> reader) {
         int i = this.readVarInt();
+
         if (i == 0) {
             return Holder.direct(reader.apply(this));
         } else {
-            Holder<T> holder = registryEntries.byId(i - 1);
+            Holder<T> holder = (Holder) registryEntries.byId(i - 1);
+
             if (holder == null) {
                 throw new IllegalArgumentException("Can't find element with id " + i);
             } else {
@@ -179,66 +196,70 @@
     }
 
     public static <T> IntFunction<T> limitValue(IntFunction<T> applier, int max) {
-        return (value) -> {
-            if (value > max) {
-                throw new DecoderException("Value " + value + " is larger than limit " + max);
+        return (j) -> {
+            if (j > max) {
+                throw new DecoderException("Value " + j + " is larger than limit " + max);
             } else {
-                return applier.apply(value);
+                return applier.apply(j);
             }
         };
     }
 
     public <T, C extends Collection<T>> C readCollection(IntFunction<C> collectionFactory, FriendlyByteBuf.Reader<T> reader) {
         int i = this.readVarInt();
-        C collection = collectionFactory.apply(i);
+        C c0 = collectionFactory.apply(i); // CraftBukkit - decompile error
 
-        for(int j = 0; j < i; ++j) {
-            collection.add(reader.apply(this));
+        for (int j = 0; j < i; ++j) {
+            c0.add(reader.apply(this));
         }
 
-        return collection;
+        return c0;
     }
 
     public <T> void writeCollection(Collection<T> collection, FriendlyByteBuf.Writer<T> writer) {
         this.writeVarInt(collection.size());
+        Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
 
-        for(T object : collection) {
-            writer.accept(this, object);
+        while (iterator.hasNext()) {
+            T t0 = iterator.next();
+
+            writer.accept(this, t0);
         }
 
     }
 
     public <T> List<T> readList(FriendlyByteBuf.Reader<T> reader) {
-        return this.readCollection(Lists::newArrayListWithCapacity, reader);
+        return (List) this.readCollection(Lists::newArrayListWithCapacity, reader);
     }
 
     public IntList readIntIdList() {
         int i = this.readVarInt();
-        IntList intList = new IntArrayList();
+        IntArrayList intarraylist = new IntArrayList();
 
-        for(int j = 0; j < i; ++j) {
-            intList.add(this.readVarInt());
+        for (int j = 0; j < i; ++j) {
+            intarraylist.add(this.readVarInt());
         }
 
-        return intList;
+        return intarraylist;
     }
 
     public void writeIntIdList(IntList list) {
         this.writeVarInt(list.size());
-        list.forEach(this::writeVarInt);
+        list.forEach((java.util.function.IntConsumer) this::writeVarInt); // CraftBukkit - decompile error
     }
 
     public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> mapFactory, FriendlyByteBuf.Reader<K> keyReader, FriendlyByteBuf.Reader<V> valueReader) {
         int i = this.readVarInt();
-        M map = mapFactory.apply(i);
+        M m0 = mapFactory.apply(i); // CraftBukkit - decompile error
 
-        for(int j = 0; j < i; ++j) {
-            K object = keyReader.apply(this);
-            V object2 = valueReader.apply(this);
-            map.put(object, object2);
+        for (int j = 0; j < i; ++j) {
+            K k0 = keyReader.apply(this);
+            V v0 = valueReader.apply(this);
+
+            m0.put(k0, v0);
         }
 
-        return map;
+        return m0;
     }
 
     public <K, V> Map<K, V> readMap(FriendlyByteBuf.Reader<K> keyReader, FriendlyByteBuf.Reader<V> valueReader) {
@@ -247,44 +268,44 @@
 
     public <K, V> void writeMap(Map<K, V> map, FriendlyByteBuf.Writer<K> keyWriter, FriendlyByteBuf.Writer<V> valueWriter) {
         this.writeVarInt(map.size());
-        map.forEach((key, value) -> {
-            keyWriter.accept(this, key);
-            valueWriter.accept(this, value);
+        map.forEach((object, object1) -> {
+            keyWriter.accept(this, object);
+            valueWriter.accept(this, object1);
         });
     }
 
     public void readWithCount(Consumer<FriendlyByteBuf> consumer) {
         int i = this.readVarInt();
 
-        for(int j = 0; j < i; ++j) {
+        for (int j = 0; j < i; ++j) {
             consumer.accept(this);
         }
 
     }
 
     public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumSet, Class<E> type) {
-        E[] enums = type.getEnumConstants();
-        BitSet bitSet = new BitSet(enums.length);
+        E[] ae = type.getEnumConstants(); // CraftBukkit - decompile error
+        BitSet bitset = new BitSet(ae.length);
 
-        for(int i = 0; i < enums.length; ++i) {
-            bitSet.set(i, enumSet.contains(enums[i]));
+        for (int i = 0; i < ae.length; ++i) {
+            bitset.set(i, enumSet.contains(ae[i]));
         }
 
-        this.writeFixedBitSet(bitSet, enums.length);
+        this.writeFixedBitSet(bitset, ae.length);
     }
 
     public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> type) {
-        E[] enums = type.getEnumConstants();
-        BitSet bitSet = this.readFixedBitSet(enums.length);
-        EnumSet<E> enumSet = EnumSet.noneOf(type);
+        E[] ae = type.getEnumConstants(); // CraftBukkit - decompile error
+        BitSet bitset = this.readFixedBitSet(ae.length);
+        EnumSet<E> enumset = EnumSet.noneOf(type);
 
-        for(int i = 0; i < enums.length; ++i) {
-            if (bitSet.get(i)) {
-                enumSet.add(enums[i]);
+        for (int i = 0; i < ae.length; ++i) {
+            if (bitset.get(i)) {
+                enumset.add(ae[i]);
             }
         }
 
-        return enumSet;
+        return enumset;
     }
 
     public <T> void writeOptional(Optional<T> value, FriendlyByteBuf.Writer<T> writer) {
@@ -303,7 +324,7 @@
 
     @Nullable
     public <T> T readNullable(FriendlyByteBuf.Reader<T> reader) {
-        return (T)(this.readBoolean() ? reader.apply(this) : null);
+        return this.readBoolean() ? reader.apply(this) : null;
     }
 
     public <T> void writeNullable(@Nullable T value, FriendlyByteBuf.Writer<T> writer) {
@@ -341,21 +362,27 @@
     }
 
     public byte[] readByteArray(int maxSize) {
-        int i = this.readVarInt();
-        if (i > maxSize) {
-            throw new DecoderException("ByteArray with size " + i + " is bigger than allowed " + maxSize);
+        int j = this.readVarInt();
+
+        if (j > maxSize) {
+            throw new DecoderException("ByteArray with size " + j + " is bigger than allowed " + maxSize);
         } else {
-            byte[] bs = new byte[i];
-            this.readBytes(bs);
-            return bs;
+            byte[] abyte = new byte[j];
+
+            this.readBytes(abyte);
+            return abyte;
         }
     }
 
     public FriendlyByteBuf writeVarIntArray(int[] array) {
         this.writeVarInt(array.length);
+        int[] aint1 = array;
+        int i = array.length;
 
-        for(int i : array) {
-            this.writeVarInt(i);
+        for (int j = 0; j < i; ++j) {
+            int k = aint1[j];
+
+            this.writeVarInt(k);
         }
 
         return this;
@@ -366,32 +393,37 @@
     }
 
     public int[] readVarIntArray(int maxSize) {
-        int i = this.readVarInt();
-        if (i > maxSize) {
-            throw new DecoderException("VarIntArray with size " + i + " is bigger than allowed " + maxSize);
+        int j = this.readVarInt();
+
+        if (j > maxSize) {
+            throw new DecoderException("VarIntArray with size " + j + " is bigger than allowed " + maxSize);
         } else {
-            int[] is = new int[i];
+            int[] aint = new int[j];
 
-            for(int j = 0; j < is.length; ++j) {
-                is[j] = this.readVarInt();
+            for (int k = 0; k < aint.length; ++k) {
+                aint[k] = this.readVarInt();
             }
 
-            return is;
+            return aint;
         }
     }
 
     public FriendlyByteBuf writeLongArray(long[] array) {
         this.writeVarInt(array.length);
+        long[] along1 = array;
+        int i = array.length;
 
-        for(long l : array) {
-            this.writeLong(l);
+        for (int j = 0; j < i; ++j) {
+            long k = along1[j];
+
+            this.writeLong(k);
         }
 
         return this;
     }
 
     public long[] readLongArray() {
-        return this.readLongArray((long[])null);
+        return this.readLongArray((long[]) null);
     }
 
     public long[] readLongArray(@Nullable long[] toArray) {
@@ -399,17 +431,18 @@
     }
 
     public long[] readLongArray(@Nullable long[] toArray, int maxSize) {
-        int i = this.readVarInt();
-        if (toArray == null || toArray.length != i) {
-            if (i > maxSize) {
-                throw new DecoderException("LongArray with size " + i + " is bigger than allowed " + maxSize);
+        int j = this.readVarInt();
+
+        if (toArray == null || toArray.length != j) {
+            if (j > maxSize) {
+                throw new DecoderException("LongArray with size " + j + " is bigger than allowed " + maxSize);
             }
 
-            toArray = new long[i];
+            toArray = new long[j];
         }
 
-        for(int j = 0; j < toArray.length; ++j) {
-            toArray[j] = this.readLong();
+        for (int k = 0; k < toArray.length; ++k) {
+            toArray[k] = this.readLong();
         }
 
         return toArray;
@@ -443,9 +476,10 @@
     }
 
     public GlobalPos readGlobalPos() {
-        ResourceKey<Level> resourceKey = this.readResourceKey(Registries.DIMENSION);
-        BlockPos blockPos = this.readBlockPos();
-        return GlobalPos.of(resourceKey, blockPos);
+        ResourceKey<Level> resourcekey = this.readResourceKey(Registries.DIMENSION);
+        BlockPos blockposition = this.readBlockPos();
+
+        return GlobalPos.of(resourcekey, blockposition);
     }
 
     public void writeGlobalPos(GlobalPos pos) {
@@ -485,20 +519,33 @@
     }
 
     public Component readComponent() {
-        Component component = Component.Serializer.fromJson(this.readUtf(262144));
-        if (component == null) {
+        MutableComponent ichatmutablecomponent = Component.Serializer.fromJson(this.readUtf(262144));
+
+        if (ichatmutablecomponent == null) {
             throw new DecoderException("Received unexpected null component");
         } else {
-            return component;
+            return ichatmutablecomponent;
         }
     }
 
+    // Paper start
+    public FriendlyByteBuf writeComponent(final net.kyori.adventure.text.Component component) {
+        return this.writeUtf(io.papermc.paper.adventure.PaperAdventure.asJsonString(component, this.adventure$locale), 262144);
+    }
+
+    @Deprecated
+    public FriendlyByteBuf writeComponent(final net.md_5.bungee.api.chat.BaseComponent[] component) {
+        return this.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(component), 262144);
+    }
+    // Paper end
+
     public FriendlyByteBuf writeComponent(Component text) {
-        return this.writeUtf(Component.Serializer.toJson(text), 262144);
+        //return this.a(IChatBaseComponent.ChatSerializer.a(ichatbasecomponent), 262144); // Paper - comment
+        return this.writeUtf(io.papermc.paper.adventure.PaperAdventure.asJsonString(text, this.adventure$locale), 262144); // Paper
     }
 
     public <T extends Enum<T>> T readEnum(Class<T> enumClass) {
-        return (enumClass.getEnumConstants())[this.readVarInt()];
+        return ((T[]) enumClass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error
     }
 
     public FriendlyByteBuf writeEnum(Enum<?> instance) {
@@ -507,11 +554,13 @@
 
     public <T> T readById(IntFunction<T> idToValue) {
         int i = this.readVarInt();
+
         return idToValue.apply(i);
     }
 
     public <T> FriendlyByteBuf writeById(ToIntFunction<T> valueToId, T value) {
         int i = valueToId.applyAsInt(value);
+
         return this.writeVarInt(i);
     }
 
@@ -549,47 +598,55 @@
         }
 
         try {
-            NbtIo.writeAnyTag(nbt, new ByteBufOutputStream(this));
+            NbtIo.writeAnyTag((Tag) nbt, new ByteBufOutputStream(this));
             return this;
-        } catch (IOException var3) {
-            throw new EncoderException(var3);
+        } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
+            throw new EncoderException(ioexception);
         }
     }
 
     @Nullable
     public CompoundTag readNbt() {
-        Tag tag = this.readNbt(NbtAccounter.create(2097152L));
-        if (tag != null && !(tag instanceof CompoundTag)) {
-            throw new DecoderException("Not a compound tag: " + tag);
+        Tag nbtbase = this.readNbt(NbtAccounter.create(2097152L));
+
+        if (nbtbase != null && !(nbtbase instanceof CompoundTag)) {
+            throw new DecoderException("Not a compound tag: " + nbtbase);
         } else {
-            return (CompoundTag)tag;
+            return (CompoundTag) nbtbase;
         }
     }
 
     @Nullable
     public Tag readNbt(NbtAccounter sizeTracker) {
         try {
-            Tag tag = NbtIo.readAnyTag(new ByteBufInputStream(this), sizeTracker);
-            return tag.getId() == 0 ? null : tag;
-        } catch (IOException var3) {
-            throw new EncoderException(var3);
+            Tag nbtbase = NbtIo.readAnyTag(new ByteBufInputStream(this), sizeTracker);
+
+            return nbtbase.getId() == 0 ? null : nbtbase;
+        } catch (IOException ioexception) {
+            throw new EncoderException(ioexception);
         }
     }
 
     public FriendlyByteBuf writeItem(ItemStack stack) {
-        if (stack.isEmpty()) {
+        if (stack.isEmpty() || stack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
             this.writeBoolean(false);
         } else {
             this.writeBoolean(true);
             Item item = stack.getItem();
+
             this.writeId(BuiltInRegistries.ITEM, item);
             this.writeByte(stack.getCount());
-            CompoundTag compoundTag = null;
+            CompoundTag nbttagcompound = null;
+
             if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) {
-                compoundTag = stack.getTag();
+                // Spigot start - filter
+                stack = stack.copy();
+                // CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); // Paper - This is no longer with raw NBT being handled in metadata
+                // Spigot end
+                nbttagcompound = stack.getTag();
             }
 
-            this.writeNbt(compoundTag);
+            this.writeNbt(nbttagcompound);
         }
 
         return this;
@@ -599,11 +656,17 @@
         if (!this.readBoolean()) {
             return ItemStack.EMPTY;
         } else {
-            Item item = this.readById(BuiltInRegistries.ITEM);
-            int i = this.readByte();
-            ItemStack itemStack = new ItemStack(item, i);
-            itemStack.setTag(this.readNbt());
-            return itemStack;
+            Item item = (Item) this.readById((IdMap) BuiltInRegistries.ITEM);
+            byte b0 = this.readByte();
+            ItemStack itemstack = new ItemStack(item, b0);
+
+            itemstack.setTag(this.readNbt());
+            // CraftBukkit start
+            if (false && itemstack.getTag() != null) { // Paper - This is no longer needed with raw NBT being handled in metadata
+                CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+            }
+            // CraftBukkit end
+            return itemstack;
         }
     }
 
@@ -619,8 +682,8 @@
         return this.writeUtf(string, 32767);
     }
 
-    public FriendlyByteBuf writeUtf(String string, int maxLength) {
-        Utf8String.write(this.source, string, maxLength);
+    public FriendlyByteBuf writeUtf(String s, int maxLength) {
+        Utf8String.write(this.source, s, maxLength);
         return this;
     }
 
@@ -634,8 +697,9 @@
     }
 
     public <T> ResourceKey<T> readResourceKey(ResourceKey<? extends Registry<T>> registryRef) {
-        ResourceLocation resourceLocation = this.readResourceLocation();
-        return ResourceKey.create(registryRef, resourceLocation);
+        ResourceLocation minecraftkey = this.readResourceLocation();
+
+        return ResourceKey.create(registryRef, minecraftkey);
     }
 
     public void writeResourceKey(ResourceKey<?> key) {
@@ -643,8 +707,9 @@
     }
 
     public <T> ResourceKey<? extends Registry<T>> readRegistryKey() {
-        ResourceLocation resourceLocation = this.readResourceLocation();
-        return ResourceKey.createRegistryKey(resourceLocation);
+        ResourceLocation minecraftkey = this.readResourceLocation();
+
+        return ResourceKey.createRegistryKey(minecraftkey);
     }
 
     public Date readDate() {
@@ -667,8 +732,8 @@
     public PublicKey readPublicKey() {
         try {
             return Crypt.byteToPublicKey(this.readByteArray(512));
-        } catch (CryptException var2) {
-            throw new DecoderException("Malformed public key bytes", var2);
+        } catch (CryptException cryptographyexception) {
+            throw new DecoderException("Malformed public key bytes", cryptographyexception);
         }
     }
 
@@ -678,23 +743,26 @@
     }
 
     public BlockHitResult readBlockHitResult() {
-        BlockPos blockPos = this.readBlockPos();
-        Direction direction = this.readEnum(Direction.class);
+        BlockPos blockposition = this.readBlockPos();
+        Direction enumdirection = (Direction) this.readEnum(Direction.class);
         float f = this.readFloat();
-        float g = this.readFloat();
-        float h = this.readFloat();
-        boolean bl = this.readBoolean();
-        return new BlockHitResult(new Vec3((double)blockPos.getX() + (double)f, (double)blockPos.getY() + (double)g, (double)blockPos.getZ() + (double)h), direction, blockPos, bl);
+        float f1 = this.readFloat();
+        float f2 = this.readFloat();
+        boolean flag = this.readBoolean();
+
+        return new BlockHitResult(new Vec3((double) blockposition.getX() + (double) f, (double) blockposition.getY() + (double) f1, (double) blockposition.getZ() + (double) f2), enumdirection, blockposition, flag);
     }
 
     public void writeBlockHitResult(BlockHitResult hitResult) {
-        BlockPos blockPos = hitResult.getBlockPos();
-        this.writeBlockPos(blockPos);
+        BlockPos blockposition = hitResult.getBlockPos();
+
+        this.writeBlockPos(blockposition);
         this.writeEnum(hitResult.getDirection());
-        Vec3 vec3 = hitResult.getLocation();
-        this.writeFloat((float)(vec3.x - (double)blockPos.getX()));
-        this.writeFloat((float)(vec3.y - (double)blockPos.getY()));
-        this.writeFloat((float)(vec3.z - (double)blockPos.getZ()));
+        Vec3 vec3d = hitResult.getLocation();
+
+        this.writeFloat((float) (vec3d.x - (double) blockposition.getX()));
+        this.writeFloat((float) (vec3d.y - (double) blockposition.getY()));
+        this.writeFloat((float) (vec3d.z - (double) blockposition.getZ()));
         this.writeBoolean(hitResult.isInside());
     }
 
@@ -707,26 +775,31 @@
     }
 
     public BitSet readFixedBitSet(int size) {
-        byte[] bs = new byte[Mth.positiveCeilDiv(size, 8)];
-        this.readBytes(bs);
-        return BitSet.valueOf(bs);
+        byte[] abyte = new byte[Mth.positiveCeilDiv(size, 8)];
+
+        this.readBytes(abyte);
+        return BitSet.valueOf(abyte);
     }
 
     public void writeFixedBitSet(BitSet bitSet, int size) {
         if (bitSet.length() > size) {
-            throw new EncoderException("BitSet is larger than expected size (" + bitSet.length() + ">" + size + ")");
+            int j = bitSet.length();
+
+            throw new EncoderException("BitSet is larger than expected size (" + j + ">" + size + ")");
         } else {
-            byte[] bs = bitSet.toByteArray();
-            this.writeBytes(Arrays.copyOf(bs, Mth.positiveCeilDiv(size, 8)));
+            byte[] abyte = bitSet.toByteArray();
+
+            this.writeBytes(Arrays.copyOf(abyte, Mth.positiveCeilDiv(size, 8)));
         }
     }
 
     public GameProfile readGameProfile() {
-        UUID uUID = this.readUUID();
-        String string = this.readUtf(16);
-        GameProfile gameProfile = new GameProfile(uUID, string);
-        gameProfile.getProperties().putAll(this.readGameProfileProperties());
-        return gameProfile;
+        UUID uuid = this.readUUID();
+        String s = this.readUtf(16);
+        GameProfile gameprofile = new GameProfile(uuid, s);
+
+        gameprofile.getProperties().putAll(this.readGameProfileProperties());
+        return gameprofile;
     }
 
     public void writeGameProfile(GameProfile gameProfile) {
@@ -736,12 +809,14 @@
     }
 
     public PropertyMap readGameProfileProperties() {
-        PropertyMap propertyMap = new PropertyMap();
-        this.readWithCount((buf) -> {
+        PropertyMap propertymap = new PropertyMap();
+
+        this.readWithCount((packetdataserializer) -> {
             Property property = this.readProperty();
-            propertyMap.put(property.name(), property);
+
+            propertymap.put(property.name(), property);
         });
-        return propertyMap;
+        return propertymap;
     }
 
     public void writeGameProfileProperties(PropertyMap propertyMap) {
@@ -749,10 +824,11 @@
     }
 
     public Property readProperty() {
-        String string = this.readUtf();
-        String string2 = this.readUtf();
-        String string3 = this.readNullable(FriendlyByteBuf::readUtf);
-        return new Property(string, string2, string3);
+        String s = this.readUtf();
+        String s1 = this.readUtf();
+        String s2 = (String) this.readNullable(FriendlyByteBuf::readUtf);
+
+        return new Property(s, s1, s2);
     }
 
     public void writeProperty(Property property) {
@@ -790,8 +866,8 @@
         return this.source.order();
     }
 
-    public ByteBuf order(ByteOrder byteOrder) {
-        return this.source.order(byteOrder);
+    public ByteBuf order(ByteOrder byteorder) {
+        return this.source.order(byteorder);
     }
 
     public ByteBuf unwrap() {
@@ -901,8 +977,8 @@
         return this;
     }
 
-    public int ensureWritable(int i, boolean bl) {
-        return this.source.ensureWritable(i, bl);
+    public int ensureWritable(int i, boolean flag) {
+        return this.source.ensureWritable(i, flag);
     }
 
     public boolean getBoolean(int i) {
@@ -985,55 +1061,55 @@
         return this.source.getDouble(i);
     }
 
-    public FriendlyByteBuf getBytes(int i, ByteBuf byteBuf) {
-        this.source.getBytes(i, byteBuf);
+    public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf) {
+        this.source.getBytes(i, bytebuf);
         return this;
     }
 
-    public FriendlyByteBuf getBytes(int i, ByteBuf byteBuf, int j) {
-        this.source.getBytes(i, byteBuf, j);
+    public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf, int j) {
+        this.source.getBytes(i, bytebuf, j);
         return this;
     }
 
-    public FriendlyByteBuf getBytes(int i, ByteBuf byteBuf, int j, int k) {
-        this.source.getBytes(i, byteBuf, j, k);
+    public FriendlyByteBuf getBytes(int i, ByteBuf bytebuf, int j, int k) {
+        this.source.getBytes(i, bytebuf, j, k);
         return this;
     }
 
-    public FriendlyByteBuf getBytes(int i, byte[] bs) {
-        this.source.getBytes(i, bs);
+    public FriendlyByteBuf getBytes(int i, byte[] abyte) {
+        this.source.getBytes(i, abyte);
         return this;
     }
 
-    public FriendlyByteBuf getBytes(int i, byte[] bs, int j, int k) {
-        this.source.getBytes(i, bs, j, k);
+    public FriendlyByteBuf getBytes(int i, byte[] abyte, int j, int k) {
+        this.source.getBytes(i, abyte, j, k);
         return this;
     }
 
-    public FriendlyByteBuf getBytes(int i, ByteBuffer byteBuffer) {
-        this.source.getBytes(i, byteBuffer);
+    public FriendlyByteBuf getBytes(int i, ByteBuffer bytebuffer) {
+        this.source.getBytes(i, bytebuffer);
         return this;
     }
 
-    public FriendlyByteBuf getBytes(int i, OutputStream outputStream, int j) throws IOException {
-        this.source.getBytes(i, outputStream, j);
+    public FriendlyByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException {
+        this.source.getBytes(i, outputstream, j);
         return this;
     }
 
-    public int getBytes(int i, GatheringByteChannel gatheringByteChannel, int j) throws IOException {
-        return this.source.getBytes(i, gatheringByteChannel, j);
+    public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException {
+        return this.source.getBytes(i, gatheringbytechannel, j);
     }
 
-    public int getBytes(int i, FileChannel fileChannel, long l, int j) throws IOException {
-        return this.source.getBytes(i, fileChannel, l, j);
+    public int getBytes(int i, FileChannel filechannel, long j, int k) throws IOException {
+        return this.source.getBytes(i, filechannel, j, k);
     }
 
     public CharSequence getCharSequence(int i, int j, Charset charset) {
         return this.source.getCharSequence(i, j, charset);
     }
 
-    public FriendlyByteBuf setBoolean(int i, boolean bl) {
-        this.source.setBoolean(i, bl);
+    public FriendlyByteBuf setBoolean(int i, boolean flag) {
+        this.source.setBoolean(i, flag);
         return this;
     }
 
@@ -1072,13 +1148,13 @@
         return this;
     }
 
-    public FriendlyByteBuf setLong(int i, long l) {
-        this.source.setLong(i, l);
+    public FriendlyByteBuf setLong(int i, long j) {
+        this.source.setLong(i, j);
         return this;
     }
 
-    public FriendlyByteBuf setLongLE(int i, long l) {
-        this.source.setLongLE(i, l);
+    public FriendlyByteBuf setLongLE(int i, long j) {
+        this.source.setLongLE(i, j);
         return this;
     }
 
@@ -1092,51 +1168,51 @@
         return this;
     }
 
-    public FriendlyByteBuf setDouble(int i, double d) {
-        this.source.setDouble(i, d);
+    public FriendlyByteBuf setDouble(int i, double d0) {
+        this.source.setDouble(i, d0);
         return this;
     }
 
-    public FriendlyByteBuf setBytes(int i, ByteBuf byteBuf) {
-        this.source.setBytes(i, byteBuf);
+    public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf) {
+        this.source.setBytes(i, bytebuf);
         return this;
     }
 
-    public FriendlyByteBuf setBytes(int i, ByteBuf byteBuf, int j) {
-        this.source.setBytes(i, byteBuf, j);
+    public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf, int j) {
+        this.source.setBytes(i, bytebuf, j);
         return this;
     }
 
-    public FriendlyByteBuf setBytes(int i, ByteBuf byteBuf, int j, int k) {
-        this.source.setBytes(i, byteBuf, j, k);
+    public FriendlyByteBuf setBytes(int i, ByteBuf bytebuf, int j, int k) {
+        this.source.setBytes(i, bytebuf, j, k);
         return this;
     }
 
-    public FriendlyByteBuf setBytes(int i, byte[] bs) {
-        this.source.setBytes(i, bs);
+    public FriendlyByteBuf setBytes(int i, byte[] abyte) {
+        this.source.setBytes(i, abyte);
         return this;
     }
 
-    public FriendlyByteBuf setBytes(int i, byte[] bs, int j, int k) {
-        this.source.setBytes(i, bs, j, k);
+    public FriendlyByteBuf setBytes(int i, byte[] abyte, int j, int k) {
+        this.source.setBytes(i, abyte, j, k);
         return this;
     }
 
-    public FriendlyByteBuf setBytes(int i, ByteBuffer byteBuffer) {
-        this.source.setBytes(i, byteBuffer);
+    public FriendlyByteBuf setBytes(int i, ByteBuffer bytebuffer) {
+        this.source.setBytes(i, bytebuffer);
         return this;
     }
 
-    public int setBytes(int i, InputStream inputStream, int j) throws IOException {
-        return this.source.setBytes(i, inputStream, j);
+    public int setBytes(int i, InputStream inputstream, int j) throws IOException {
+        return this.source.setBytes(i, inputstream, j);
     }
 
-    public int setBytes(int i, ScatteringByteChannel scatteringByteChannel, int j) throws IOException {
-        return this.source.setBytes(i, scatteringByteChannel, j);
+    public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException {
+        return this.source.setBytes(i, scatteringbytechannel, j);
     }
 
-    public int setBytes(int i, FileChannel fileChannel, long l, int j) throws IOException {
-        return this.source.setBytes(i, fileChannel, l, j);
+    public int setBytes(int i, FileChannel filechannel, long j, int k) throws IOException {
+        return this.source.setBytes(i, filechannel, j, k);
     }
 
     public FriendlyByteBuf setZero(int i, int j) {
@@ -1144,8 +1220,8 @@
         return this;
     }
 
-    public int setCharSequence(int i, CharSequence charSequence, Charset charset) {
-        return this.source.setCharSequence(i, charSequence, charset);
+    public int setCharSequence(int i, CharSequence charsequence, Charset charset) {
+        return this.source.setCharSequence(i, charsequence, charset);
     }
 
     public boolean readBoolean() {
@@ -1240,51 +1316,51 @@
         return this.source.readRetainedSlice(i);
     }
 
-    public FriendlyByteBuf readBytes(ByteBuf byteBuf) {
-        this.source.readBytes(byteBuf);
+    public FriendlyByteBuf readBytes(ByteBuf bytebuf) {
+        this.source.readBytes(bytebuf);
         return this;
     }
 
-    public FriendlyByteBuf readBytes(ByteBuf byteBuf, int i) {
-        this.source.readBytes(byteBuf, i);
+    public FriendlyByteBuf readBytes(ByteBuf bytebuf, int i) {
+        this.source.readBytes(bytebuf, i);
         return this;
     }
 
-    public FriendlyByteBuf readBytes(ByteBuf byteBuf, int i, int j) {
-        this.source.readBytes(byteBuf, i, j);
+    public FriendlyByteBuf readBytes(ByteBuf bytebuf, int i, int j) {
+        this.source.readBytes(bytebuf, i, j);
         return this;
     }
 
-    public FriendlyByteBuf readBytes(byte[] bs) {
-        this.source.readBytes(bs);
+    public FriendlyByteBuf readBytes(byte[] abyte) {
+        this.source.readBytes(abyte);
         return this;
     }
 
-    public FriendlyByteBuf readBytes(byte[] bs, int i, int j) {
-        this.source.readBytes(bs, i, j);
+    public FriendlyByteBuf readBytes(byte[] abyte, int i, int j) {
+        this.source.readBytes(abyte, i, j);
         return this;
     }
 
-    public FriendlyByteBuf readBytes(ByteBuffer byteBuffer) {
-        this.source.readBytes(byteBuffer);
+    public FriendlyByteBuf readBytes(ByteBuffer bytebuffer) {
+        this.source.readBytes(bytebuffer);
         return this;
     }
 
-    public FriendlyByteBuf readBytes(OutputStream outputStream, int i) throws IOException {
-        this.source.readBytes(outputStream, i);
+    public FriendlyByteBuf readBytes(OutputStream outputstream, int i) throws IOException {
+        this.source.readBytes(outputstream, i);
         return this;
     }
 
-    public int readBytes(GatheringByteChannel gatheringByteChannel, int i) throws IOException {
-        return this.source.readBytes(gatheringByteChannel, i);
+    public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException {
+        return this.source.readBytes(gatheringbytechannel, i);
     }
 
     public CharSequence readCharSequence(int i, Charset charset) {
         return this.source.readCharSequence(i, charset);
     }
 
-    public int readBytes(FileChannel fileChannel, long l, int i) throws IOException {
-        return this.source.readBytes(fileChannel, l, i);
+    public int readBytes(FileChannel filechannel, long i, int j) throws IOException {
+        return this.source.readBytes(filechannel, i, j);
     }
 
     public FriendlyByteBuf skipBytes(int i) {
@@ -1292,8 +1368,8 @@
         return this;
     }
 
-    public FriendlyByteBuf writeBoolean(boolean bl) {
-        this.source.writeBoolean(bl);
+    public FriendlyByteBuf writeBoolean(boolean flag) {
+        this.source.writeBoolean(flag);
         return this;
     }
 
@@ -1332,13 +1408,13 @@
         return this;
     }
 
-    public FriendlyByteBuf writeLong(long l) {
-        this.source.writeLong(l);
+    public FriendlyByteBuf writeLong(long i) {
+        this.source.writeLong(i);
         return this;
     }
 
-    public FriendlyByteBuf writeLongLE(long l) {
-        this.source.writeLongLE(l);
+    public FriendlyByteBuf writeLongLE(long i) {
+        this.source.writeLongLE(i);
         return this;
     }
 
@@ -1352,51 +1428,51 @@
         return this;
     }
 
-    public FriendlyByteBuf writeDouble(double d) {
-        this.source.writeDouble(d);
+    public FriendlyByteBuf writeDouble(double d0) {
+        this.source.writeDouble(d0);
         return this;
     }
 
-    public FriendlyByteBuf writeBytes(ByteBuf byteBuf) {
-        this.source.writeBytes(byteBuf);
+    public FriendlyByteBuf writeBytes(ByteBuf bytebuf) {
+        this.source.writeBytes(bytebuf);
         return this;
     }
 
-    public FriendlyByteBuf writeBytes(ByteBuf byteBuf, int i) {
-        this.source.writeBytes(byteBuf, i);
+    public FriendlyByteBuf writeBytes(ByteBuf bytebuf, int i) {
+        this.source.writeBytes(bytebuf, i);
         return this;
     }
 
-    public FriendlyByteBuf writeBytes(ByteBuf byteBuf, int i, int j) {
-        this.source.writeBytes(byteBuf, i, j);
+    public FriendlyByteBuf writeBytes(ByteBuf bytebuf, int i, int j) {
+        this.source.writeBytes(bytebuf, i, j);
         return this;
     }
 
-    public FriendlyByteBuf writeBytes(byte[] bs) {
-        this.source.writeBytes(bs);
+    public FriendlyByteBuf writeBytes(byte[] abyte) {
+        this.source.writeBytes(abyte);
         return this;
     }
 
-    public FriendlyByteBuf writeBytes(byte[] bs, int i, int j) {
-        this.source.writeBytes(bs, i, j);
+    public FriendlyByteBuf writeBytes(byte[] abyte, int i, int j) {
+        this.source.writeBytes(abyte, i, j);
         return this;
     }
 
-    public FriendlyByteBuf writeBytes(ByteBuffer byteBuffer) {
-        this.source.writeBytes(byteBuffer);
+    public FriendlyByteBuf writeBytes(ByteBuffer bytebuffer) {
+        this.source.writeBytes(bytebuffer);
         return this;
     }
 
-    public int writeBytes(InputStream inputStream, int i) throws IOException {
-        return this.source.writeBytes(inputStream, i);
+    public int writeBytes(InputStream inputstream, int i) throws IOException {
+        return this.source.writeBytes(inputstream, i);
     }
 
-    public int writeBytes(ScatteringByteChannel scatteringByteChannel, int i) throws IOException {
-        return this.source.writeBytes(scatteringByteChannel, i);
+    public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException {
+        return this.source.writeBytes(scatteringbytechannel, i);
     }
 
-    public int writeBytes(FileChannel fileChannel, long l, int i) throws IOException {
-        return this.source.writeBytes(fileChannel, l, i);
+    public int writeBytes(FileChannel filechannel, long i, int j) throws IOException {
+        return this.source.writeBytes(filechannel, i, j);
     }
 
     public FriendlyByteBuf writeZero(int i) {
@@ -1404,40 +1480,40 @@
         return this;
     }
 
-    public int writeCharSequence(CharSequence charSequence, Charset charset) {
-        return this.source.writeCharSequence(charSequence, charset);
+    public int writeCharSequence(CharSequence charsequence, Charset charset) {
+        return this.source.writeCharSequence(charsequence, charset);
     }
 
-    public int indexOf(int i, int j, byte b) {
-        return this.source.indexOf(i, j, b);
+    public int indexOf(int i, int j, byte b0) {
+        return this.source.indexOf(i, j, b0);
     }
 
-    public int bytesBefore(byte b) {
-        return this.source.bytesBefore(b);
+    public int bytesBefore(byte b0) {
+        return this.source.bytesBefore(b0);
     }
 
-    public int bytesBefore(int i, byte b) {
-        return this.source.bytesBefore(i, b);
+    public int bytesBefore(int i, byte b0) {
+        return this.source.bytesBefore(i, b0);
     }
 
-    public int bytesBefore(int i, int j, byte b) {
-        return this.source.bytesBefore(i, j, b);
+    public int bytesBefore(int i, int j, byte b0) {
+        return this.source.bytesBefore(i, j, b0);
     }
 
-    public int forEachByte(ByteProcessor byteProcessor) {
-        return this.source.forEachByte(byteProcessor);
+    public int forEachByte(ByteProcessor byteprocessor) {
+        return this.source.forEachByte(byteprocessor);
     }
 
-    public int forEachByte(int i, int j, ByteProcessor byteProcessor) {
-        return this.source.forEachByte(i, j, byteProcessor);
+    public int forEachByte(int i, int j, ByteProcessor byteprocessor) {
+        return this.source.forEachByte(i, j, byteprocessor);
     }
 
-    public int forEachByteDesc(ByteProcessor byteProcessor) {
-        return this.source.forEachByteDesc(byteProcessor);
+    public int forEachByteDesc(ByteProcessor byteprocessor) {
+        return this.source.forEachByteDesc(byteprocessor);
     }
 
-    public int forEachByteDesc(int i, int j, ByteProcessor byteProcessor) {
-        return this.source.forEachByteDesc(i, j, byteProcessor);
+    public int forEachByteDesc(int i, int j, ByteProcessor byteprocessor) {
+        return this.source.forEachByteDesc(i, j, byteprocessor);
     }
 
     public ByteBuf copy() {
@@ -1532,8 +1608,8 @@
         return this.source.equals(object);
     }
 
-    public int compareTo(ByteBuf byteBuf) {
-        return this.source.compareTo(byteBuf);
+    public int compareTo(ByteBuf bytebuf) {
+        return this.source.compareTo(bytebuf);
     }
 
     public String toString() {
@@ -1573,19 +1649,21 @@
     }
 
     @FunctionalInterface
-    public interface Reader<T> extends Function<FriendlyByteBuf, T> {
-        default FriendlyByteBuf.Reader<Optional<T>> asOptional() {
-            return (buf) -> {
-                return buf.readOptional(this);
+    public interface Writer<T> extends BiConsumer<FriendlyByteBuf, T> {
+
+        default FriendlyByteBuf.Writer<Optional<T>> asOptional() {
+            return (packetdataserializer, optional) -> {
+                packetdataserializer.writeOptional(optional, this);
             };
         }
     }
 
     @FunctionalInterface
-    public interface Writer<T> extends BiConsumer<FriendlyByteBuf, T> {
-        default FriendlyByteBuf.Writer<Optional<T>> asOptional() {
-            return (buf, value) -> {
-                buf.writeOptional(value, this);
+    public interface Reader<T> extends Function<FriendlyByteBuf, T> {
+
+        default FriendlyByteBuf.Reader<Optional<T>> asOptional() {
+            return (packetdataserializer) -> {
+                return packetdataserializer.readOptional(this);
             };
         }
     }
