Skip to content

Commit

Permalink
Remove properties from food properties that no longer exist (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipseisoffline authored Oct 31, 2024
1 parent 3b4afeb commit b3df351
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,4 @@ public class FoodProperties {
private final int nutrition;
private final float saturationModifier;
private final boolean canAlwaysEat;
private final float eatSeconds;
private final @Nullable ItemStack usingConvertsTo;
private final List<PossibleEffect> effects;

@Data
@AllArgsConstructor
public static class PossibleEffect {
private final MobEffectInstance effect;
private final float probability;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;

import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.nbt.NbtList;
Expand All @@ -13,7 +11,6 @@
import org.geysermc.mcprotocollib.protocol.data.game.entity.Effect;
import org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot;
import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOperation;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.BuiltinSound;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.CustomSound;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;
Expand Down Expand Up @@ -236,29 +233,14 @@ public FoodProperties readFoodProperties(ByteBuf buf) {
int nutrition = this.readVarInt(buf);
float saturationModifier = buf.readFloat();
boolean canAlwaysEat = buf.readBoolean();
float eatSeconds = buf.readFloat();
ItemStack usingConvertsTo = this.readNullable(buf, this::readOptionalItemStack);

List<FoodProperties.PossibleEffect> effects = this.readList(buf, (input) -> {
MobEffectInstance effect = this.readEffectInstance(input);
float probability = input.readFloat();
return new FoodProperties.PossibleEffect(effect, probability);
});

return new FoodProperties(nutrition, saturationModifier, canAlwaysEat, eatSeconds, usingConvertsTo, effects);
return new FoodProperties(nutrition, saturationModifier, canAlwaysEat);
}

public void writeFoodProperties(ByteBuf buf, FoodProperties properties) {
this.writeVarInt(buf, properties.getNutrition());
buf.writeFloat(properties.getSaturationModifier());
buf.writeBoolean(properties.isCanAlwaysEat());
buf.writeFloat(properties.getEatSeconds());
this.writeNullable(buf, properties.getUsingConvertsTo(), this::writeOptionalItemStack);

this.writeList(buf, properties.getEffects(), (output, effect) -> {
this.writeEffectInstance(output, effect.getEffect());
output.writeFloat(effect.getProbability());
});
}

public Consumable readConsumable(ByteBuf buf) {
Expand Down

0 comments on commit b3df351

Please sign in to comment.