Relics

Relics

10M Downloads

Infinity Ham if equipped in backpack with feeding upgrade

C0WB0Y-Ducky opened this issue ยท 3 comments

commented

Versions:
Relics: 0.9.03
Sophisticated Backpacks: 3.20.17
NeoForge 1.21
Modpack: Craftoria 1.5.0

Observed Behavior:
If the Infinity Ham is tagged is in a backpack with a feeding upgrade, the backpack does not see it as food, so will not auto feed.

Expected Behavior:
The Infinity Ham to be eaten straight from the backpack.

Steps to Reproduce:
Create a Backpack, add either feeding upgrade, place infinity ham inside backpack. Then go to the filter for the upgrade, you are unable to place it in the filter to allow/block. If nothing is blocked you do not eat. Finally lose some saturation and test with another piece of food.

commented

I also have this problem. In 1.18.2
Mod pack: Chroma Endless 2 (latest version)

commented

I'm not sure if this is the correct place
This is the logic from the Sophisticated mods:

https://github.com/P3pp3rF1y/SophisticatedCore/blob/42394d4f8f006d7bc6cb24ce180db2c3a75ae62e/src/main/java/net/p3pp3rf1y/sophisticatedcore/upgrades/feeding/FeedingUpgradeWrapper.java#L77

The item needs to be edible and have food properties
The relic item isn't a food item though, it's a custom item which feeds the player on right click


Let's say you mixin to bypass the isEdible check, you'd then need to:

@Override
public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level world, Player player, @NotNull InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
if (stack.getOrDefault(CHARGE, 0) > 0
&& (player.getFoodData().needsFood() || player.isCreative()))
player.startUsingItem(hand);
return super.use(world, player, hand);
}

return with InteractionResult.CONSUME if startUsingItem is triggered

At this point the feeding wrapper calls ForgeEventFactory.onItemUseFinish (or EventHooks.onItemUseFinish for 1.21) - if an item is edible thats when LivingEntity#eat is triggered - but thats not the case for the relic item

So you either add another mixin point to eat the relic item here, or you implement finishUsingItem for the relic item and potentially trigger 1 tick of eating it (if it has charges left)


Instead of a mixin to bypass the check you might be able to return custom food properties when they're queried and implement a custom isEdible check depending on charges left

Then skip the super call on use to not trigger the vanilla eating logic

commented

Same issue on 1.19.2