Skip to content

Commit

Permalink
Merge pull request #1021 from booky10/fix/food-properties
Browse files Browse the repository at this point in the history
Fix order of reading fields in food properties
  • Loading branch information
retrooper authored Oct 6, 2024
2 parents fea6e90 + 1f86c65 commit 487bcc3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public static FoodProperties read(PacketWrapper<?> wrapper) {
float saturation = wrapper.readFloat();
boolean canAlwaysEat = wrapper.readBoolean();
float eatSeconds = wrapper.readFloat();
List<PossibleEffect> effects = wrapper.readList(PossibleEffect::read);
ItemStack usingConvertsTo = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21)
? wrapper.readOptional(PacketWrapper::readItemStack) : null;
List<PossibleEffect> effects = wrapper.readList(PossibleEffect::read);
return new FoodProperties(nutrition, saturation, canAlwaysEat, eatSeconds, effects, usingConvertsTo);
}

Expand All @@ -71,10 +71,10 @@ public static void write(PacketWrapper<?> wrapper, FoodProperties props) {
wrapper.writeFloat(props.saturation);
wrapper.writeBoolean(props.canAlwaysEat);
wrapper.writeFloat(props.eatSeconds);
wrapper.writeList(props.effects, PossibleEffect::write);
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21)) {
wrapper.writeOptional(props.usingConvertsTo, PacketWrapper::writeItemStack);
}
wrapper.writeList(props.effects, PossibleEffect::write);
}

public int getNutrition() {
Expand Down

0 comments on commit 487bcc3

Please sign in to comment.