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

"projectile_spawned" Enchantment Component runs predicates and effects on projectiles before all of their data has been assigned

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w33a
    • 1.21 Release Candidate 1, 1.21
    • None
    • Confirmed
    • Data Packs, Enchantments, Projectiles
    • Normal
    • Platform

      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.

      Steps to reproduce:

      1. Install the provided datapack.
      2. Enchant a bow with "test:arrow_crit_detection":
        /enchant @s test:arrow_crit_detection
      3. Shoot the bow before fully charging it.
      4. Shoot the bow after fully charging it.

      Observed result:
      The message I am NOT a crit arrow appears twice. The first arrow does not display critical charge particles, while the second arrow does display critical charge particles.

      Expected result:
      The message I am NOT a crit arrow appears once and after it I AM a crit arrow appears once. Both arrows do not display critical charge particles.

      This is a re-report of MC-271562, which says it was fixed, but the issue is not fixed. I requested for that report to be reopened, and was told to make a new report.

            aalidoust [Mojang] Nightingale
            stormconure Conure
            Votes:
            11 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: