Skip to content

Commit

Permalink
Fixed foods having the wrong saturation values and not calculating th…
Browse files Browse the repository at this point in the history
…e modifiers properly, closes #46
  • Loading branch information
Buuz135 committed Aug 17, 2024
1 parent cce2b06 commit 25ef0ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
9 changes: 4 additions & 5 deletions src/main/java/com/buuz135/sushigocrafting/item/FoodItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<IFoodIngredient> foodIngredients = new ArrayList<>(foodItem.getIngredientList());
if (stack.hasTag() && stack.getTagElement(FoodItem.SPICES_TAG) != null) {
Expand Down

0 comments on commit 25ef0ae

Please sign in to comment.