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

"projectile_spawned" Enchantment component triggers the enchantment effects BEFORE setting the projectile's default NBT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w19a
    • 24w18a
    • None
    • Unconfirmed
    • (Unassigned)

      If you detect a projectile with the "projectile_spawned" enchantment component, you won't be able to detect certain properties of that projectile, because those properties are set by the game immediately AFTER the enchantment effect is called. I've provided an example datapack which highlights this bug.

      The datapack provides an enchantment for Bows which detects when you fire an arrow, and tries to determine whether that arrow is a crit arrow. If it is, a message will appear saying it is a crit arrow, and if not, another message will appear saying it's not. Finally, the function sets the arrow's NBT so it is no longer a crit arrow.

      So, the expected behavior is the following: if you don't fully draw the bow back, the "not a crit" message will appear, and if you DO fully draw it, the "crit" message will appear instead. In either case, because of the last command, the arrow should NOT display crit particles.

      The observed behavior is the following: no matter how far back you draw the bow, the "not a crit" message appears, and if you DO draw it back all the way, the arrow still displays crit particles despite the last command removing the crit tag.

      You can see this behavior by installing the provided datapack and enchanting a bow with "test:arrow_crit_detection".

            Unassigned Unassigned
            stormconure Conure
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: