-
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, 1.21, 1.21.1, 1.21.2 Pre-Release 3, 1.21.3
-
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:
- Locate a large body of water and summon a boat on it.
- Enter the boat and check what the value of your "foodExhaustionLevel" NBT data by using the command provided below.
/data get entity @s foodExhaustionLevel
- Take note of this value and begin paddling around in the boat for around twenty seconds.
- Check the value of your "foodExhaustionLevel" NBT data once again by using the command provided below.
/data get entity @s foodExhaustionLevel
- 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.
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)
- is duplicated by
-
MC-151519 the hunger bar is not runs out in a boat
- Resolved