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

You can no longer teleport entities with no death animation that were previously killed in the same function

XMLWordPrintable

    • Community Consensus
    • Commands, Data Packs
    • Low
    • Platform

      If a function, running as an entity (@s) with no death animation (such as a marker), kills the entity and then tries to run anything that moves the entity such as /teleport or /spreadplayers, the commands will "succeed" but the entity will not be moved at all.
      This was not the case in versions prior to 24w33a (1.21.1 and prior).

      Killing the executor entity at the beginning of a function is a commonly used technique to avoid needing to run extra commands later in the function to kill the entity (which is useful for lots of reasons, and very relevant since /return was added). This new behaviour is inconsistent with other commands in the game, inconsistent between entities, breaks much previously written code, and was not mentioned in the changelog.

      Steps to Reproduce:

      1. Download the attached data pack and enable it in a world in 1.21.1.
        • The data pack adds two functions, mc-276062:kill_first and mc-276062:kill_after, which teleport the executor to a fixed position and rotation, then teleport it elsewhere and with a different rotation then kill it, or vice versa respectively. Both functions also print in chat the entity's coordinates before and after, and print whether the /teleport command itself was stored as "successful" or a "failure" to all players.
      2. Run the following commands several times each to see what they output:
        execute summon marker run function mc-276062:kill_first
        execute summon pig run function mc-276062:kill_first
        
        execute summon marker run function mc-276062:kill_after
        execute summon pig run function mc-276062:kill_after
      1. Update to 24w33a or 24w34a and run the same commands several times each.

      You can also test this out with other entities. You can swap out pig for any mob, and you can swap out marker for entities such as item_display, interaction, armor_stand, etc.

      Observed Results:

      • In 1.21.1, all of the commands correctly teleport the entity; print out their (random) coordinates into the chat window to all players; and kill the entity.
      • In 24w33a, the commands that run the mc-276062:kill_after function work as expected, but the commands that run the mc-276062:kill_first function only work as expected for the pig. When ran by a marker, it always prints the coordinates and rotation as as [0.0d,0.0d,0.0d] [0.0f,0.0f].

      In both versions, the entity is killed no matter what but the difference is whether they are repositioned by the /teleport command or not.

      In both versions, the /teleport command is also "successful", despite not doing anything in mc-276062:kill_first in 24w44a when ran as a marker.

      Expected Results:

      In either version, both functions should teleport the entity and print out their coordinates, no matter what entity it runs as.

            Unassigned Unassigned
            Deoxyribonucleic Evans DorkOrc
            Votes:
            7 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              CHK: