From 25ef0ae94c972c0bb2adc18b5e66b2cc8e404ce3 Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Sat, 17 Aug 2024 19:49:46 +0200 Subject: [PATCH] Fixed foods having the wrong saturation values and not calculating the modifiers properly, closes #46 --- build.gradle | 1 + gradle.properties | 2 +- .../java/com/buuz135/sushigocrafting/item/FoodItem.java | 9 ++++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 9690b50..0589658 100644 --- a/build.gradle +++ b/build.gradle @@ -102,6 +102,7 @@ dependencies { //runtimeOnly fg.deobf("curse.maven:appleskin-248787:3395800") implementation fg.deobf("curse.maven:patchouli-306770:4636277") compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-forge-1.20.1:14.0.12") + implementation fg.deobf("curse.maven:appleskin-248787:4770828") //runtimeOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-forge-1.18.2:9.1.103") } diff --git a/gradle.properties b/gradle.properties index 8e29866..067673e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx2G modGroup=com.buuz135 -modVersion=0.5.2 +modVersion=0.5.3 modBaseName=sushigocrafting minecraftVersion=1.20.1 diff --git a/src/main/java/com/buuz135/sushigocrafting/item/FoodItem.java b/src/main/java/com/buuz135/sushigocrafting/item/FoodItem.java index 78b0be1..397f224 100644 --- a/src/main/java/com/buuz135/sushigocrafting/item/FoodItem.java +++ b/src/main/java/com/buuz135/sushigocrafting/item/FoodItem.java @@ -19,7 +19,6 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -154,10 +153,10 @@ public ItemStack finishUsingItem(ItemStack stack, Level worldIn, LivingEntity en return entity.eat(worldIn, stack); } - @Nullable @Override - public FoodProperties getFoodProperties() { - return new FoodProperties.Builder().nutrition(getIngredientList().stream().mapToInt(IFoodIngredient::getHungerValue).sum()).saturationMod(getIngredientList().stream().mapToInt(IFoodIngredient::getSaturationValue).sum()).build(); + public @org.jetbrains.annotations.Nullable FoodProperties getFoodProperties(ItemStack stack, @org.jetbrains.annotations.Nullable LivingEntity entity) { + var info = new Info(stack, true); + return new FoodProperties.Builder().nutrition((int) Math.floor(info.getHunger())).saturationMod(info.getSaturation()).build(); } public static class Info { @@ -186,7 +185,7 @@ public Info(ItemStack stack, boolean calculateEffects) { } FoodItem foodItem = (FoodItem) stack.getItem(); this.hunger = foodItem.getIngredientList().stream().map(IFoodIngredient::getHungerValue).mapToInt(Integer::intValue).sum() * getFoodModifierValue(negative, positive); - this.saturation = foodItem.getIngredientList().stream().map(IFoodIngredient::getSaturationValue).mapToInt(Integer::intValue).sum() * getFoodModifierValue(negative, positive); + this.saturation = (foodItem.getIngredientList().stream().map(IFoodIngredient::getSaturationValue).mapToInt(Integer::intValue).sum() * getFoodModifierValue(negative, positive)) / (foodItem.ingredientList.size() + 2); if (calculateEffects) { List foodIngredients = new ArrayList<>(foodItem.getIngredientList()); if (stack.hasTag() && stack.getTagElement(FoodItem.SPICES_TAG) != null) {