From 4c2ecc1ab92c868c9dfa461a30b579955165fe0a Mon Sep 17 00:00:00 2001 From: basaigh <53559772+basaigh@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:42:53 +0100 Subject: [PATCH] 1.21.2-pre1 --- .../protocol/codec/MinecraftCodec.java | 4 +- .../protocol/codec/MinecraftCodecHelper.java | 63 ++++++++++++------- .../data/game/item/component/Equippable.java | 4 +- .../game/item/component/ItemCodecHelper.java | 3 +- .../DustColorTransitionParticleData.java | 12 ++-- .../game/level/particle/DustParticleData.java | 4 +- .../data/game/level/sound/BuiltinSound.java | 1 + .../game/recipe/BasicRecipeBookCategory.java | 23 ------- .../recipe/display/FurnaceRecipeDisplay.java | 3 +- .../recipe/display/RecipeDisplayEntry.java | 3 +- .../recipe/display/SmithingRecipeDisplay.java | 3 +- .../display/StonecutterRecipeDisplay.java | 2 +- .../recipe/display/slot/RecipeSlotType.java | 3 +- .../slot/SmithingTrimDemoSlotDisplay.java | 2 +- .../slot/WithRemainderSlotDisplay.java | 8 +++ .../ClientboundRecipeBookAddPacket.java | 9 +-- 16 files changed, 72 insertions(+), 75 deletions(-) delete mode 100644 protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/BasicRecipeBookCategory.java create mode 100644 protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/WithRemainderSlotDisplay.java diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java index ff17f63da..86f1f916e 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java @@ -214,9 +214,9 @@ public class MinecraftCodec { public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion((1 << 30) | 212) + .protocolVersion((1 << 30) | 213) .helper(MinecraftCodecHelper::new) - .minecraftVersion("24w40a") + .minecraftVersion("1.21.2-pre1") .state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder() .registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new) ) diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java index df2714fdf..756b10080 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java @@ -99,6 +99,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay; import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SmithingTrimDemoSlotDisplay; import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.TagSlotDisplay; +import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.WithRemainderSlotDisplay; import org.geysermc.mcprotocollib.protocol.data.game.statistic.StatisticCategory; import org.jetbrains.annotations.NotNull; @@ -710,21 +711,15 @@ public ParticleData readParticleData(ByteBuf buf, ParticleType type) { return switch (type) { case BLOCK, BLOCK_MARKER, FALLING_DUST, DUST_PILLAR, BLOCK_CRUMBLE -> new BlockParticleData(this.readVarInt(buf)); case DUST -> { - float red = buf.readFloat(); - float green = buf.readFloat(); - float blue = buf.readFloat(); + int color = buf.readInt(); float scale = buf.readFloat(); - yield new DustParticleData(red, green, blue, scale); + yield new DustParticleData(color, scale); } case DUST_COLOR_TRANSITION -> { - float red = buf.readFloat(); - float green = buf.readFloat(); - float blue = buf.readFloat(); - float newRed = buf.readFloat(); - float newGreen = buf.readFloat(); - float newBlue = buf.readFloat(); + int color = buf.readInt(); + int newColor = buf.readInt(); float scale = buf.readFloat(); - yield new DustColorTransitionParticleData(red, green, blue, scale, newRed, newGreen, newBlue); + yield new DustColorTransitionParticleData(color, scale, newColor); } case ENTITY_EFFECT -> new EntityEffectParticleData(buf.readInt()); case ITEM -> new ItemParticleData(this.readOptionalItemStack(buf)); @@ -744,19 +739,13 @@ public void writeParticleData(ByteBuf buf, ParticleType type, ParticleData data) } case DUST -> { DustParticleData dustData = (DustParticleData) data; - buf.writeFloat(dustData.getRed()); - buf.writeFloat(dustData.getGreen()); - buf.writeFloat(dustData.getBlue()); + buf.writeInt(dustData.getColor()); buf.writeFloat(dustData.getScale()); } case DUST_COLOR_TRANSITION -> { DustColorTransitionParticleData dustData = (DustColorTransitionParticleData) data; - buf.writeFloat(dustData.getRed()); - buf.writeFloat(dustData.getGreen()); - buf.writeFloat(dustData.getBlue()); - buf.writeFloat(dustData.getNewRed()); - buf.writeFloat(dustData.getNewGreen()); - buf.writeFloat(dustData.getNewBlue()); + buf.writeInt(dustData.getColor()); + buf.writeInt(dustData.getNewColor()); buf.writeFloat(dustData.getScale()); } case ENTITY_EFFECT -> { @@ -1032,20 +1021,26 @@ public RecipeDisplay readRecipeDisplay(ByteBuf buf) { SlotDisplay fuel = this.readSlotDisplay(buf); SlotDisplay result = this.readSlotDisplay(buf); SlotDisplay craftingStation = this.readSlotDisplay(buf); + int duration = this.readVarInt(buf); + float experience = buf.readFloat(); - display = new FurnaceRecipeDisplay(ingredient, fuel, result, craftingStation); + display = new FurnaceRecipeDisplay(ingredient, fuel, result, craftingStation, duration, experience); } case STONECUTTER -> { + SlotDisplay input = this.readSlotDisplay(buf); SlotDisplay result = this.readSlotDisplay(buf); SlotDisplay craftingStation = this.readSlotDisplay(buf); - display = new StonecutterRecipeDisplay(result, craftingStation); + display = new StonecutterRecipeDisplay(input, result, craftingStation); } case SMITHING -> { + SlotDisplay template = this.readSlotDisplay(buf); + SlotDisplay base = this.readSlotDisplay(buf); + SlotDisplay addition = this.readSlotDisplay(buf); SlotDisplay result = this.readSlotDisplay(buf); SlotDisplay craftingStation = this.readSlotDisplay(buf); - display = new SmithingRecipeDisplay(result, craftingStation); + display = new SmithingRecipeDisplay(template, base, addition, result, craftingStation); } default -> throw new IllegalStateException("Unexpected value: " + type); } @@ -1078,16 +1073,22 @@ public void writeRecipeDisplay(ByteBuf buf, RecipeDisplay display) { this.writeSlotDisplay(buf, furnaceDisplay.fuel()); this.writeSlotDisplay(buf, furnaceDisplay.result()); this.writeSlotDisplay(buf, furnaceDisplay.craftingStation()); + this.writeVarInt(buf, furnaceDisplay.duration()); + buf.writeFloat(furnaceDisplay.experience()); } case STONECUTTER -> { StonecutterRecipeDisplay stonecutterDisplay = (StonecutterRecipeDisplay) display; + this.writeSlotDisplay(buf, stonecutterDisplay.input()); this.writeSlotDisplay(buf, stonecutterDisplay.result()); this.writeSlotDisplay(buf, stonecutterDisplay.craftingStation()); } case SMITHING -> { SmithingRecipeDisplay smithingDisplay = (SmithingRecipeDisplay) display; + this.writeSlotDisplay(buf, smithingDisplay.template()); + this.writeSlotDisplay(buf, smithingDisplay.base()); + this.writeSlotDisplay(buf, smithingDisplay.addition()); this.writeSlotDisplay(buf, smithingDisplay.result()); this.writeSlotDisplay(buf, smithingDisplay.craftingStation()); } @@ -1103,7 +1104,8 @@ public SlotDisplay readSlotDisplay(ByteBuf buf) { case ITEM -> display = new ItemSlotDisplay(this.readVarInt(buf)); case ITEM_STACK -> display = new ItemStackSlotDisplay(this.readItemStack(buf)); case TAG -> display = new TagSlotDisplay(this.readResourceLocation(buf)); - case SMITHING_TRIM -> display = new SmithingTrimDemoSlotDisplay(); + case SMITHING_TRIM -> display = new SmithingTrimDemoSlotDisplay(this.readSlotDisplay(buf), this.readSlotDisplay(buf), this.readSlotDisplay(buf)); + case WITH_REMAINDER -> display = new WithRemainderSlotDisplay(this.readSlotDisplay(buf), this.readSlotDisplay(buf)); case COMPOSITE -> display = new CompositeSlotDisplay(this.readList(buf, this::readSlotDisplay)); default -> throw new IllegalStateException("Unexpected value: " + type); } @@ -1116,6 +1118,19 @@ public void writeSlotDisplay(ByteBuf buf, SlotDisplay display) { case ITEM -> this.writeVarInt(buf, ((ItemSlotDisplay)display).item()); case ITEM_STACK -> this.writeItemStack(buf, ((ItemStackSlotDisplay)display).itemStack()); case TAG -> this.writeResourceLocation(buf, ((TagSlotDisplay)display).tag()); + case SMITHING_TRIM -> { + SmithingTrimDemoSlotDisplay smithingSlotDisplay = (SmithingTrimDemoSlotDisplay) display; + + this.writeSlotDisplay(buf, smithingSlotDisplay.base()); + this.writeSlotDisplay(buf, smithingSlotDisplay.material()); + this.writeSlotDisplay(buf, smithingSlotDisplay.pattern()); + } + case WITH_REMAINDER -> { + WithRemainderSlotDisplay remainderSlotDisplay = (WithRemainderSlotDisplay) display; + + this.writeSlotDisplay(buf, remainderSlotDisplay.input()); + this.writeSlotDisplay(buf, remainderSlotDisplay.remainder()); + } case COMPOSITE -> this.writeList(buf, ((CompositeSlotDisplay)display).contents(), this::writeSlotDisplay); } } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java index 6dbdacfc7..7fce6b7c7 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/Equippable.java @@ -5,6 +5,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot; import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound; -public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable HolderSet allowedEntities, - boolean dispensable, boolean swappable, boolean damageOnHurt) { +public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable Key cameraOverlay, + @Nullable HolderSet allowedEntities, boolean dispensable, boolean swappable, boolean damageOnHurt) { } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java index a512ac27b..121f7009a 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/item/component/ItemCodecHelper.java @@ -143,11 +143,12 @@ public Equippable readEquippable(ByteBuf buf) { EquipmentSlot slot = EquipmentSlot.from(this.readVarInt(buf)); Sound equipSound = this.readById(buf, BuiltinSound::from, this::readSoundEvent); Key model = this.readNullable(buf, this::readResourceLocation); + Key cameraOverlay = this.readNullable(buf, this::readResourceLocation); HolderSet allowedEntities = this.readNullable(buf, this::readHolderSet); boolean dispensable = buf.readBoolean(); boolean swappable = buf.readBoolean(); boolean damageOnHurt = buf.readBoolean(); - return new Equippable(slot, equipSound, model, allowedEntities, dispensable, swappable, damageOnHurt); + return new Equippable(slot, equipSound, model, cameraOverlay, allowedEntities, dispensable, swappable, damageOnHurt); } public void writeEquippable(ByteBuf buf, Equippable equippable) { diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustColorTransitionParticleData.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustColorTransitionParticleData.java index 951460095..7f4402fb7 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustColorTransitionParticleData.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustColorTransitionParticleData.java @@ -4,14 +4,10 @@ @Getter public class DustColorTransitionParticleData extends DustParticleData { - private final float newRed; - private final float newGreen; - private final float newBlue; + private final int newColor; - public DustColorTransitionParticleData(float red, float green, float blue, float scale, float newRed, float newGreen, float newBlue) { - super(red, green, blue, scale); - this.newRed = newRed; - this.newGreen = newGreen; - this.newBlue = newBlue; + public DustColorTransitionParticleData(int color, float scale, int newColor) { + super(color, scale); + this.newColor = newColor; } } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustParticleData.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustParticleData.java index 33127fd17..76da6c233 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustParticleData.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/particle/DustParticleData.java @@ -6,8 +6,6 @@ @Data @AllArgsConstructor public class DustParticleData implements ParticleData { - private final float red; // 0 - 1 - private final float green; // 0 - 1 - private final float blue; // 0 - 1 + private final int color; private final float scale; // clamped between 0.01 and 4 } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java index 2e65f8e57..3f17016ea 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java @@ -217,6 +217,7 @@ public enum BuiltinSound implements Sound { BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"), BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT("block.bubble_column.whirlpool_ambient"), BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE("block.bubble_column.whirlpool_inside"), + UI_HUD_BUBBLE_POP("ui.hud.bubble_pop"), ITEM_BUCKET_EMPTY("item.bucket.empty"), ITEM_BUCKET_EMPTY_AXOLOTL("item.bucket.empty_axolotl"), ITEM_BUCKET_EMPTY_FISH("item.bucket.empty_fish"), diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/BasicRecipeBookCategory.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/BasicRecipeBookCategory.java deleted file mode 100644 index 7ad2d3363..000000000 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/BasicRecipeBookCategory.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.geysermc.mcprotocollib.protocol.data.game.recipe; - -public enum BasicRecipeBookCategory { - CRAFTING_BUILDING_BLOCKS, - CRAFTING_REDSTONE, - CRAFTING_EQUIPMENT, - CRAFTING_MISC, - FURNACE_FOOD, - FURNACE_BLOCKS, - FURNACE_MISC, - BLAST_FURNACE_BLOCKS, - BLAST_FURNACE_MISC, - SMOKER_FOOD, - STONECUTTER, - SMITHING, - CAMPFIRE; - - private static final BasicRecipeBookCategory[] VALUES = values(); - - public static BasicRecipeBookCategory from(int id) { - return VALUES[id]; - } -} diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/FurnaceRecipeDisplay.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/FurnaceRecipeDisplay.java index e1ccd2cfb..b15d64634 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/FurnaceRecipeDisplay.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/FurnaceRecipeDisplay.java @@ -2,7 +2,8 @@ import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay; -public record FurnaceRecipeDisplay(SlotDisplay ingredient, SlotDisplay fuel, SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay { +public record FurnaceRecipeDisplay(SlotDisplay ingredient, SlotDisplay fuel, SlotDisplay result, SlotDisplay craftingStation, + int duration, float experience) implements RecipeDisplay { @Override public RecipeDisplayType getType() { return RecipeDisplayType.FURNACE; diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/RecipeDisplayEntry.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/RecipeDisplayEntry.java index 6f080fccb..95e6c26f9 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/RecipeDisplayEntry.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/RecipeDisplayEntry.java @@ -2,11 +2,10 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet; -import org.geysermc.mcprotocollib.protocol.data.game.recipe.BasicRecipeBookCategory; import java.util.List; import java.util.OptionalInt; public record RecipeDisplayEntry(int id, RecipeDisplay display, OptionalInt group, - BasicRecipeBookCategory category, @Nullable List craftingRequirements) { + int category, @Nullable List craftingRequirements) { } diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/SmithingRecipeDisplay.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/SmithingRecipeDisplay.java index 39fd29dd9..50c4fdee8 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/SmithingRecipeDisplay.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/SmithingRecipeDisplay.java @@ -2,7 +2,8 @@ import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay; -public record SmithingRecipeDisplay(SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay { +public record SmithingRecipeDisplay(SlotDisplay template, SlotDisplay base, SlotDisplay addition, + SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay { @Override public RecipeDisplayType getType() { return RecipeDisplayType.SMITHING; diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/StonecutterRecipeDisplay.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/StonecutterRecipeDisplay.java index 68e910d34..b3a11eb0b 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/StonecutterRecipeDisplay.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/StonecutterRecipeDisplay.java @@ -2,7 +2,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay; -public record StonecutterRecipeDisplay(SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay { +public record StonecutterRecipeDisplay(SlotDisplay input, SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay { @Override public RecipeDisplayType getType() { return RecipeDisplayType.STONECUTTER; diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/RecipeSlotType.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/RecipeSlotType.java index befb071f3..b9f9e7d00 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/RecipeSlotType.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/RecipeSlotType.java @@ -1,7 +1,5 @@ package org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot; -import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.RecipeDisplayType; - public enum RecipeSlotType { EMPTY, ANY_FUEL, @@ -9,6 +7,7 @@ public enum RecipeSlotType { ITEM_STACK, TAG, SMITHING_TRIM, + WITH_REMAINDER, COMPOSITE; private static final RecipeSlotType[] VALUES = values(); diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/SmithingTrimDemoSlotDisplay.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/SmithingTrimDemoSlotDisplay.java index 2f736da8f..2529432ef 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/SmithingTrimDemoSlotDisplay.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/SmithingTrimDemoSlotDisplay.java @@ -1,6 +1,6 @@ package org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot; -public record SmithingTrimDemoSlotDisplay() implements SlotDisplay { +public record SmithingTrimDemoSlotDisplay(SlotDisplay base, SlotDisplay material, SlotDisplay pattern) implements SlotDisplay { @Override public RecipeSlotType getType() { return RecipeSlotType.SMITHING_TRIM; diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/WithRemainderSlotDisplay.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/WithRemainderSlotDisplay.java new file mode 100644 index 000000000..5cac8dbdb --- /dev/null +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/recipe/display/slot/WithRemainderSlotDisplay.java @@ -0,0 +1,8 @@ +package org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot; + +public record WithRemainderSlotDisplay(SlotDisplay input, SlotDisplay remainder) implements SlotDisplay { + @Override + public RecipeSlotType getType() { + return RecipeSlotType.WITH_REMAINDER; + } +} diff --git a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundRecipeBookAddPacket.java b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundRecipeBookAddPacket.java index 07e2063f7..d354ee3b7 100644 --- a/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundRecipeBookAddPacket.java +++ b/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/ClientboundRecipeBookAddPacket.java @@ -7,8 +7,6 @@ import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper; import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket; import org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet; -import org.geysermc.mcprotocollib.protocol.data.game.recipe.BasicRecipeBookCategory; -import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient; import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.RecipeDisplay; import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.RecipeDisplayEntry; @@ -20,6 +18,7 @@ @AllArgsConstructor public class ClientboundRecipeBookAddPacket implements MinecraftPacket { private final List entries; + private final boolean replace; public ClientboundRecipeBookAddPacket(ByteBuf in, MinecraftCodecHelper helper) { this.entries = helper.readList(in, buf -> { @@ -28,7 +27,7 @@ public ClientboundRecipeBookAddPacket(ByteBuf in, MinecraftCodecHelper helper) { int optionalInt = helper.readVarInt(buf); OptionalInt group = optionalInt == 0 ? OptionalInt.empty() : OptionalInt.of(optionalInt - 1); - BasicRecipeBookCategory category = BasicRecipeBookCategory.from(helper.readVarInt(buf)); + int category = helper.readVarInt(buf); List craftingRequirements = helper.readNullable(in, buf1 -> helper.readList(buf1, helper::readHolderSet)); byte flags = buf.readByte(); @@ -36,6 +35,7 @@ public ClientboundRecipeBookAddPacket(ByteBuf in, MinecraftCodecHelper helper) { boolean highlight = (flags & 2) != 0; return new Entry(new RecipeDisplayEntry(id, display, group, category, craftingRequirements), notification, highlight); }); + this.replace = in.readBoolean(); } @Override @@ -44,7 +44,7 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeVarInt(buf, entry.contents().id()); helper.writeRecipeDisplay(buf, entry.contents().display()); helper.writeVarInt(buf, entry.contents().group().isEmpty() ? 0 : entry.contents().group().getAsInt()); - helper.writeVarInt(buf, entry.contents().category().ordinal()); + helper.writeVarInt(buf, entry.contents().category()); helper.writeNullable(buf, entry.contents().craftingRequirements(), (buf1, reqs) -> helper.writeList(buf1, reqs, helper::writeHolderSet)); int flags = 0; @@ -57,6 +57,7 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) { } buf.writeByte(flags); }); + out.writeBoolean(this.replace); } private record Entry(RecipeDisplayEntry contents, boolean notification, boolean highlight) {