Properly read/write food components (#843)

This commit is contained in:
Eclipse 2024-07-25 01:30:06 +00:00 committed by GitHub
parent 30309cefe2
commit ab9bcbe151
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<FoodProperties.PossibleEffect> 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());