105105import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .StonecutterRecipeDisplay ;
106106import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .AnyFuelSlotDisplay ;
107107import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .CompositeSlotDisplay ;
108+ import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .DyedSlotDisplay ;
108109import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .EmptySlotDisplay ;
109110import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .ItemSlotDisplay ;
110111import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .ItemStackSlotDisplay ;
112+ import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .OnlyWithComponentSlotDisplay ;
111113import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .RecipeSlotType ;
112114import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .SlotDisplay ;
113115import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .SmithingTrimDemoSlotDisplay ;
114116import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .TagSlotDisplay ;
117+ import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .WithAnyPotionSlotDisplay ;
115118import org .geysermc .mcprotocollib .protocol .data .game .recipe .display .slot .WithRemainderSlotDisplay ;
116119import org .geysermc .mcprotocollib .protocol .data .game .statistic .StatisticCategory ;
117120import org .geysermc .mcprotocollib .protocol .data .game .debug .DebugBeeInfo ;
@@ -522,6 +525,19 @@ public static void writeItemStack(ByteBuf buf, @NotNull ItemStack item) {
522525 MinecraftTypes .writeOptionalItemStack (buf , item );
523526 }
524527
528+ public static ItemStack readItemStackTemplate (ByteBuf buf ) {
529+ int id = MinecraftTypes .readVarInt (buf );
530+ int count = MinecraftTypes .readVarInt (buf );
531+ DataComponents components = MinecraftTypes .readDataComponentPatch (buf , false );
532+ return new ItemStack (id , count , components );
533+ }
534+
535+ public static void writeItemStackTemplate (ByteBuf buf , ItemStack template ) {
536+ MinecraftTypes .writeVarInt (buf , template .getId ());
537+ MinecraftTypes .writeVarInt (buf , template .getAmount ());
538+ MinecraftTypes .writeDataComponentPatch (buf , template .getDataComponentsPatch (), false );
539+ }
540+
525541 @ Nullable
526542 public static DataComponents readDataComponentPatch (ByteBuf buf , boolean untrusted ) {
527543 int nonNullComponents = MinecraftTypes .readVarInt (buf );
@@ -821,42 +837,6 @@ public static void writePose(ByteBuf buf, Pose pose) {
821837 MinecraftTypes .writeEnum (buf , pose );
822838 }
823839
824- public static Holder <Key > readChickenVariant (ByteBuf buf ) {
825- if (buf .readBoolean ()) {
826- return Holder .ofId (MinecraftTypes .readVarInt (buf ));
827- } else {
828- return Holder .ofCustom (MinecraftTypes .readResourceLocation (buf ));
829- }
830- }
831-
832- public static void writeChickenVariant (ByteBuf buf , Holder <Key > variant ) {
833- if (variant .isId ()) {
834- buf .writeBoolean (true );
835- MinecraftTypes .writeVarInt (buf , variant .id ());
836- } else {
837- buf .writeBoolean (false );
838- MinecraftTypes .writeResourceLocation (buf , variant .custom ());
839- }
840- }
841-
842- public static Holder <Key > readZombieNautilusVariant (ByteBuf buf ) {
843- if (buf .readBoolean ()) {
844- return Holder .ofId (MinecraftTypes .readVarInt (buf ));
845- } else {
846- return Holder .ofCustom (MinecraftTypes .readResourceLocation (buf ));
847- }
848- }
849-
850- public static void writeZombieNautilusVariant (ByteBuf buf , Holder <Key > variant ) {
851- if (variant .isId ()) {
852- buf .writeBoolean (true );
853- MinecraftTypes .writeVarInt (buf , variant .id ());
854- } else {
855- buf .writeBoolean (false );
856- MinecraftTypes .writeResourceLocation (buf , variant .custom ());
857- }
858- }
859-
860840 public static Holder <PaintingVariant > readPaintingVariant (ByteBuf buf ) {
861841 return MinecraftTypes .readHolder (buf , input -> {
862842 return new PaintingVariant (MinecraftTypes .readVarInt (input ), MinecraftTypes .readVarInt (input ), MinecraftTypes .readResourceLocation (input ),
@@ -1053,7 +1033,7 @@ public static ParticleData readParticleData(ByteBuf buf, ParticleType type) {
10531033 yield new SpellParticleData (color , power );
10541034 }
10551035 case ENTITY_EFFECT , TINTED_LEAVES , FLASH -> new ColorParticleData (buf .readInt ());
1056- case ITEM -> new ItemParticleData (MinecraftTypes .readItemStack (buf ));
1036+ case ITEM -> new ItemParticleData (MinecraftTypes .readItemStackTemplate (buf ));
10571037 case SCULK_CHARGE -> new SculkChargeParticleData (buf .readFloat ());
10581038 case SHRIEK -> new ShriekParticleData (MinecraftTypes .readVarInt (buf ));
10591039 case TRAIL -> new TrailParticleData (Vector3d .from (buf .readDouble (), buf .readDouble (), buf .readDouble ()), buf .readInt (), MinecraftTypes .readVarInt (buf ));
@@ -1433,13 +1413,15 @@ public static SlotDisplay readSlotDisplay(ByteBuf buf) {
14331413 switch (type ) {
14341414 case EMPTY -> display = EmptySlotDisplay .INSTANCE ;
14351415 case ANY_FUEL -> display = new AnyFuelSlotDisplay ();
1416+ case WITH_ANY_POTION -> display = new WithAnyPotionSlotDisplay (MinecraftTypes .readSlotDisplay (buf ));
1417+ case ONLY_WITH_COMPONENT -> display = new OnlyWithComponentSlotDisplay (MinecraftTypes .readSlotDisplay (buf ),
1418+ DataComponentTypes .from (MinecraftTypes .readVarInt (buf )));
14361419 case ITEM -> display = new ItemSlotDisplay (MinecraftTypes .readVarInt (buf ));
1437- case ITEM_STACK -> display = new ItemStackSlotDisplay (MinecraftTypes .readItemStack (buf ));
1420+ case ITEM_STACK -> display = new ItemStackSlotDisplay (MinecraftTypes .readItemStackTemplate (buf ));
14381421 case TAG -> display = new TagSlotDisplay (MinecraftTypes .readResourceLocation (buf ));
1439- case SMITHING_TRIM -> {
1440- display = new SmithingTrimDemoSlotDisplay (MinecraftTypes .readSlotDisplay (buf ), MinecraftTypes .readSlotDisplay (buf ),
1441- MinecraftTypes .readHolder (buf , ItemTypes ::readTrimPattern ));
1442- }
1422+ case DYED -> display = new DyedSlotDisplay (MinecraftTypes .readSlotDisplay (buf ), MinecraftTypes .readSlotDisplay (buf ));
1423+ case SMITHING_TRIM -> display = new SmithingTrimDemoSlotDisplay (MinecraftTypes .readSlotDisplay (buf ), MinecraftTypes .readSlotDisplay (buf ),
1424+ MinecraftTypes .readHolder (buf , ItemTypes ::readTrimPattern ));
14431425 case WITH_REMAINDER -> display = new WithRemainderSlotDisplay (MinecraftTypes .readSlotDisplay (buf ), MinecraftTypes .readSlotDisplay (buf ));
14441426 case COMPOSITE -> display = new CompositeSlotDisplay (MinecraftTypes .readList (buf , MinecraftTypes ::readSlotDisplay ));
14451427 default -> throw new IllegalStateException ("Unexpected value: " + type );
@@ -1450,9 +1432,22 @@ public static SlotDisplay readSlotDisplay(ByteBuf buf) {
14501432 public static void writeSlotDisplay (ByteBuf buf , SlotDisplay display ) {
14511433 MinecraftTypes .writeVarInt (buf , display .getType ().ordinal ());
14521434 switch (display .getType ()) {
1435+ case WITH_ANY_POTION -> MinecraftTypes .writeSlotDisplay (buf , ((WithAnyPotionSlotDisplay )display ).display ());
1436+ case ONLY_WITH_COMPONENT -> {
1437+ OnlyWithComponentSlotDisplay onlyWithComponentSlotDisplay = (OnlyWithComponentSlotDisplay ) display ;
1438+
1439+ MinecraftTypes .writeSlotDisplay (buf , onlyWithComponentSlotDisplay .source ());
1440+ MinecraftTypes .writeVarInt (buf , onlyWithComponentSlotDisplay .component ().getId ());
1441+ }
14531442 case ITEM -> MinecraftTypes .writeVarInt (buf , ((ItemSlotDisplay )display ).item ());
1454- case ITEM_STACK -> MinecraftTypes .writeItemStack (buf , ((ItemStackSlotDisplay )display ).itemStack ());
1443+ case ITEM_STACK -> MinecraftTypes .writeItemStackTemplate (buf , ((ItemStackSlotDisplay )display ).itemStack ());
14551444 case TAG -> MinecraftTypes .writeResourceLocation (buf , ((TagSlotDisplay )display ).tag ());
1445+ case DYED -> {
1446+ DyedSlotDisplay dyedSlotDisplay = (DyedSlotDisplay ) display ;
1447+
1448+ MinecraftTypes .writeSlotDisplay (buf , dyedSlotDisplay .dye ());
1449+ MinecraftTypes .writeSlotDisplay (buf , dyedSlotDisplay .target ());
1450+ }
14561451 case SMITHING_TRIM -> {
14571452 SmithingTrimDemoSlotDisplay smithingSlotDisplay = (SmithingTrimDemoSlotDisplay ) display ;
14581453
@@ -1783,14 +1778,16 @@ private static Palette readPalette(ByteBuf buf, PaletteType paletteType, int bit
17831778
17841779 public static ChunkSection readChunkSection (ByteBuf buf , int blockStateRegistrySize , int biomeRegistrySize ) {
17851780 int blockCount = buf .readShort ();
1781+ int fluidCount = buf .readShort ();
17861782
17871783 DataPalette blockStatePalette = MinecraftTypes .readDataPalette (buf , PaletteType .BLOCK_STATE , blockStateRegistrySize );
17881784 DataPalette biomePalette = MinecraftTypes .readDataPalette (buf , PaletteType .BIOME , biomeRegistrySize );
1789- return new ChunkSection (blockCount , blockStatePalette , biomePalette );
1785+ return new ChunkSection (blockCount , fluidCount , blockStatePalette , biomePalette );
17901786 }
17911787
17921788 public static void writeChunkSection (ByteBuf buf , ChunkSection section ) {
17931789 buf .writeShort (section .getBlockCount ());
1790+ buf .writeShort (section .getFluidCount ());
17941791 MinecraftTypes .writeDataPalette (buf , section .getBlockData ());
17951792 MinecraftTypes .writeDataPalette (buf , section .getBiomeData ());
17961793 }
0 commit comments