Track codec writing

This commit is contained in:
Nassim Jahnke
2025-02-25 21:44:51 +01:00
parent 9be4e07a3e
commit f12d33f04e
9 changed files with 146 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
--- a/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java
@@ -17,7 +_,7 @@
);
private static final int MAX_SLOT_COUNT = 128;
private static final StreamCodec<RegistryFriendlyByteBuf, Int2ObjectMap<ItemStack>> SLOTS_STREAM_CODEC = ByteBufCodecs.map(
- Int2ObjectOpenHashMap::new, ByteBufCodecs.SHORT.map(Short::intValue, Integer::shortValue), ItemStack.OPTIONAL_STREAM_CODEC, 128
+ Int2ObjectOpenHashMap::new, ByteBufCodecs.SHORT.map(Short::intValue, Integer::shortValue), ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs::trackDepth), 128 // Paper - Track codec depth
);
private final int containerId;
private final int stateId;
@@ -46,7 +_,7 @@
this.buttonNum = buffer.readByte();
this.clickType = buffer.readEnum(ClickType.class);
this.changedSlots = Int2ObjectMaps.unmodifiable(SLOTS_STREAM_CODEC.decode(buffer));
- this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer);
+ this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs::trackDepth).decode(buffer); // Paper - Track codec depth
}
private void write(RegistryFriendlyByteBuf buffer) {

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java
@@ -11,7 +_,7 @@
public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundSetCreativeModeSlotPacket> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.SHORT,
ServerboundSetCreativeModeSlotPacket::slotNum,
- ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_STREAM_CODEC),
+ ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_STREAM_CODEC).apply(ByteBufCodecs::trackDepth), // Paper - Track codec depth
ServerboundSetCreativeModeSlotPacket::itemStack,
ServerboundSetCreativeModeSlotPacket::new
);