Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-99073

Traveling by boat or raft doesn't cause food exhaustion

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.9, Minecraft 1.14, 1.15.1, 1.16.1, 1.16.3, 1.16.4, 20w48a, 21w05b, 1.17, 1.17.1 Pre-release 1, 1.18.1, 1.18.2, 22w17a, 1.19, 1.19.2, 22w43a, 1.19.3, 1.19.4, 1.20, 1.20.1, 24w11a
    • Confirmed
    • Player

      The Bug:

      Traveling by boat or raft doesn't cause food exhaustion.

      I believe this is a problem because you can travel thousands of blocks by boat without your hunger depleting and this seems rather illogical.

      Steps to Reproduce:

      1. Locate a large body of water and summon a boat on it.
      2. Enter the boat and check what the value of your "foodExhaustionLevel" NBT data by using the command provided below.
        /data get entity @s foodExhaustionLevel
      3. Take note of this value and begin paddling around in the boat for around twenty seconds.
      4. Check the value of your "foodExhaustionLevel" NBT data once again by using the command provided below.
        /data get entity @s foodExhaustionLevel
      5. Take note as to whether or not your "foodExhaustionLevel" value is the same as when you first entered the boat. (If this value didn't change, no hunger was consumed when paddling in the boat).

      Observed Behavior:

      Hunger isn't consumed.

      Expected Behavior:

      Traveling by boat or raft would cause food exhaustion.

      Code Analysis:

      Code analysis by Avoma can be found below.

      The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

      net.minecraft.world.entity.player.Player.java
      public abstract class Player extends LivingEntity {
         ...
         private void checkRidingStatistics(double $d0, double $d1, double $d2) {
            if (this.isPassenger()) {
               int i = Math.round((float)Math.sqrt($d0 * $d0 + $d1 * $d1 + $d2 * $d2) * 100.0F);
               if (i > 0) {
                  Entity entity = this.getVehicle();
                  if (entity instanceof AbstractMinecart) {
                     this.awardStat(Stats.MINECART_ONE_CM, i);
                  } else if (entity instanceof Boat) {
                     this.awardStat(Stats.BOAT_ONE_CM, i);
                  } ...

      If we look at the above class, we can see that food exhaustion isn't applied to the player when they travel by boat. The causeFoodExhaustion() method (the method responsible for applying food exhaustion to the player), isn't present anywhere within this piece of code, resulting in this problem occurring.

      Potential Fix:

      Simply calling the causeFoodExhaustion() method within this piece of code where appropriate, should resolve this problem. The following line of code could be used in order to fix this:

      this.causeFoodExhaustion(XF * (float)i * XF)

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            10 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              CHK: