From ab9bcbe15182a8f65465b18c32f2c24a9515c332 Mon Sep 17 00:00:00 2001 From: Eclipse Date: Thu, 25 Jul 2024 01:30:06 +0000 Subject: [PATCH] Properly read/write food components (#843) --- .../protocol/data/game/item/component/ItemCodecHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 66047c39..5258053b 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 @@ -233,7 +233,7 @@ public class ItemCodecHelper extends MinecraftCodecHelper { float saturationModifier = buf.readFloat(); boolean canAlwaysEat = buf.readBoolean(); float eatSeconds = buf.readFloat(); - ItemStack usingConvertsTo = this.readOptionalItemStack(buf); + ItemStack usingConvertsTo = this.readNullable(buf, this::readOptionalItemStack); List effects = this.readList(buf, (input) -> { MobEffectInstance effect = this.readEffectInstance(input); @@ -249,7 +249,7 @@ public class ItemCodecHelper extends MinecraftCodecHelper { buf.writeFloat(properties.getSaturationModifier()); buf.writeBoolean(properties.isCanAlwaysEat()); buf.writeFloat(properties.getEatSeconds()); - this.writeOptionalItemStack(buf, properties.getUsingConvertsTo()); + this.writeNullable(buf, properties.getUsingConvertsTo(), this::writeOptionalItemStack); this.writeList(buf, properties.getEffects(), (output, effect) -> { this.writeEffectInstance(output, effect.getEffect());