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

Field to track time before tipped arrow loses effects is not normal arrow in ground time and not written to NBT


    • Icon: Bug 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

      1. Give yourself a tipped arrow with effects
        /give @p tipped_arrow{Potion:"leaping",custom_potion_effects:[{id:"speed",amplifier:1b,duration:1200}]}
      2. Shoot it in the ground
      3. Wait 30 seconds
        → The arrow loses its effects, additionally /data should show a life value above 600
      4. Repeat steps 1 and 2 but this time wait less than 30 seconds and reopen the world
      5. 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.

            Unassigned Unassigned
            marcono1234 Marcono1234
            3 Vote for this issue
            4 Start watching this issue