MineColonies

MineColonies

65M Downloads

[Bug] citizen's saturation is not increases when food stacksize is 1

gisellevonbingen opened this issue ยท 1 comments

commented

Is there an existing issue for this?

  • I have searched the existing issues.

Are you using the latest MineColonies Version?

  • I am running the latest beta/release version of MineColonies for my Minecraft version.
    I am also running the latest versions of other mods that are part of my problem.

Did you check on the Wiki? or ask on Discord?

  • I checked the MineColonies Wiki and made sure my issue is not covered there. Or I was sent from discord to open an issue here.

What were you playing at the time? Were you able to reproduce it in both settings?

  • Single Player
  • Multi Player

Minecraft Version

1.20.1

MineColonies Version

1.20.1-1.1.800

Structurize Version

1.20.1-1.0.759

Related Mods and their Versions

No response

Current Behavior

  1. Does not increases citizens's saturation.
  2. But food item was consumed.

Expected Behavior

  1. Increases citizens's saturation.

Reproduction Steps

  1. Check citizens's saturation first.
  2. Give just a food what stack size is 1 to citizen.
  3. Watch citizen eat it.
  4. Check saturation again.
2025-01-31.17-57-58.mp4

Logs

No needed.

Anything else?

final ICitizenData citizenData = citizen.getCitizenData();
ItemStack itemUseReturn = foodStack.finishUsingItem(citizen.level(), citizen);
final double satIncrease = FoodUtils.getFoodValue(foodStack, citizen);

The cause of this bug is foodStack.finishUsingItem was called before calling FoodUtils.getFoodValue.
During the process of calling ItemStack#finishUsingItem, LivingEntity#eat is called internally, which shrink the count of ItemStack by 1.
If the food ItemStack's count was 1, shrinked size will be 0, so ItemStack will be processed like a empty.
Finally, the return value of Food Utils.get Food Value became 0.

Footer


Viewers

  • Add a thumbs-up to the bug report if you are also affected. This helps the bug report become more visible to the team and doesn't clutter the comments.
  • Add a comment if you have any insights or background information that isn't already part of the conversation.
commented

We have these issues on several places, I'll make a PR for this really quickly