-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 1.12, 20w07a, 20w51a, 1.20.1, 23w32a
-
Confirmed
-
(Unassigned)
The bug
Arrows use two separate fields to track how long they have been in the ground. The one which is used to remove the effects is not stored in NBT and therefore reset when loading the arrow again.
How to reproduce
- Give yourself a tipped arrow with effects
/give @p tipped_arrow{Potion:"leaping",custom_potion_effects:[{id:"speed",amplifier:1b,duration:1200}]}
- Shoot it in the ground
- Wait 30 seconds
→ The arrow loses its effects, additionally /data should show a life value above 600 - Repeat steps 1 and 2 but this time wait less than 30 seconds and reopen the world
- Inspect the NBT data of the arrow
/data get entity @e[type=arrow,limit=1] life
→ It shows a life value higher than 600 but the arrow still has its effects
Code analysis
Based on 1.12 decompiled using MCP 9.40 PRE 1
The net.minecraft.entity.projectile.EntityArrow has two fields which both track how long the arrow is stuck in the ground. ticksInGround is used to remove the arrow after one minute and is written to NBT (life tag). timeInGround is used to remove the effects but is not written to NBT.
Since both fields are apparently tracking the same thing timeInGround should probably be removed and the life tag should be renamed to ticksInGround.
Additionally there are some situations in which ticksInGround is reset (methods EntityArrow.setThrowableHeading(double, double, double, float, float) and EntityArrow.setVelocity(double, double, double)) where inGround is not necessarily false.