How to change the base hunger rate?

Started by LorenzoHowar on

Topic category: Help with modding (Java Edition)

Last seen on 16:46, 17. Dec 2021
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to change the base hunger rate?

Hello!

I'm beginning my journey into mod making, I already covered the basics and so, but now I want to add something I have not idea how to do it.

How do I change the player base hunger rate?

I want to hunger to take longer to affect the player, but I don't know how to do it.

I've read about java Mixins to change the default game classes, but I don't have enough knowledge of the Minecraft code base to know what to tweak.

Thanks in advance!

Last seen on 16:46, 17. Dec 2021
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I found "FoodStats.java"…
Fri, 12/17/2021 - 16:32

I found "FoodStats.java" that contains the code of how the food level is decreased, is any way of changing that function?

public void tick(PlayerEntity player) {
      Difficulty difficulty = player.world.getDifficulty();
      this.prevFoodLevel = this.foodLevel;
      if (this.foodExhaustionLevel > 4.0F) {
         this.foodExhaustionLevel -= 4.0F;
         if (this.foodSaturationLevel > 0.0F) {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
         } else if (difficulty != Difficulty.PEACEFUL) {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
         }
      }
...

 

Last seen on 15:51, 16. Jan 2024
Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you can use /attribute
Sat, 12/18/2021 - 00:30

you can use /attribute