diff --git a/src/main/java/com/minelittlepony/unicopia/diet/DietProfile.java b/src/main/java/com/minelittlepony/unicopia/diet/DietProfile.java index 46900f8f..104d6958 100644 --- a/src/main/java/com/minelittlepony/unicopia/diet/DietProfile.java +++ b/src/main/java/com/minelittlepony/unicopia/diet/DietProfile.java @@ -10,6 +10,7 @@ import java.util.stream.Collectors; import org.jetbrains.annotations.Nullable; +import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.ItemDuck; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; @@ -104,6 +105,7 @@ public record DietProfile( public void appendTooltip(ItemStack stack, @Nullable PlayerEntity user, List tooltip, TooltipContext context) { var food = stack.getItem().getFoodComponent(); + var ratios = getRatios(stack); if (food == null || isInedible(ratios)) { if (stack.getUseAction() != UseAction.DRINK) { @@ -115,15 +117,30 @@ public record DietProfile( float baseMultiplier = (isForaged(stack) ? foragingMultiplier() : defaultMultiplier()); if (context.isAdvanced()) { + var nonAdjustedFood = getNonAdjustedFoodComponent(stack, user).orElse(food); tooltip.add(Text.literal(" ").append(Text.translatable("unicopia.diet.base_multiplier", baseMultiplier).formatted(Formatting.DARK_GRAY))); - tooltip.add(Text.literal(" ").append(Text.translatable("unicopia.diet.hunger.detailed", Math.max(1, (int)(ratios.getFirst() * food.getHunger())), food.getHunger(), (int)(ratios.getFirst() * 100))).formatted(Formatting.DARK_GRAY)); - tooltip.add(Text.literal(" ").append(Text.translatable("unicopia.diet.saturation.detailed", String.format("%.2f", ratios.getSecond() * food.getSaturationModifier()), (int)(ratios.getSecond() * 100))).formatted(Formatting.DARK_GRAY)); + tooltip.add(Text.literal(" ").append(Text.translatable("unicopia.diet.hunger.detailed", food.getHunger(), nonAdjustedFood.getHunger(), (int)(ratios.getFirst() * 100))).formatted(Formatting.DARK_GRAY)); + tooltip.add(Text.literal(" ").append(Text.translatable("unicopia.diet.saturation.detailed", food.getSaturationModifier(), nonAdjustedFood.getSaturationModifier(), (int)(ratios.getSecond() * 100))).formatted(Formatting.DARK_GRAY)); } else { tooltip.add(Text.literal(" ").append(Text.translatable("unicopia.diet.hunger", (int)(ratios.getFirst() * 100))).formatted(Formatting.DARK_GRAY)); tooltip.add(Text.literal(" ").append(Text.translatable("unicopia.diet.saturation", (int)(ratios.getSecond() * 100))).formatted(Formatting.DARK_GRAY)); } } + private Optional getNonAdjustedFoodComponent(ItemStack stack, @Nullable PlayerEntity user) { + @Nullable + Pony pony = Pony.of(user); + Optional food = ((ItemDuck)stack.getItem()).getOriginalFoodComponent(); + + if (food.isEmpty() && pony.getObservedSpecies().hasIronGut()) { + return findEffect(stack) + .flatMap(Effect::foodComponent) + .or(() -> PonyDiets.getInstance().getEffects(stack).foodComponent()); + } + + return food; + } + public record Multiplier( Set> tags, float hunger, diff --git a/src/main/java/com/minelittlepony/unicopia/diet/PonyDiets.java b/src/main/java/com/minelittlepony/unicopia/diet/PonyDiets.java index a9b5459b..658cdf53 100644 --- a/src/main/java/com/minelittlepony/unicopia/diet/PonyDiets.java +++ b/src/main/java/com/minelittlepony/unicopia/diet/PonyDiets.java @@ -53,7 +53,7 @@ public class PonyDiets implements DietView { return Optional.ofNullable(diets.get(pony.getObservedSpecies())).orElse(DietProfile.EMPTY); } - private Effect getEffects(ItemStack stack) { + Effect getEffects(ItemStack stack) { return effects.stream().filter(effect -> effect.test(stack)).findFirst().orElse(Effect.EMPTY); } diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 24d06e29..a4a00c78 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -594,7 +594,7 @@ "unicopia.diet.not_edible": "Item is not edible", "unicopia.diet.base_multiplier": "Base Multiplier: %s%%", "unicopia.diet.hunger.detailed": "Hunger gained: %s of %s (%s%%)", - "unicopia.diet.saturation.detailed": "Saturation gained: %s (%s%%)", + "unicopia.diet.saturation.detailed": "Saturation gained: %s of %s (%s%%)", "unicopia.diet.hunger": "Hunger Ratio: %s%%", "unicopia.diet.saturation": "Saturation Ratio: %s%%",