mojira.dev
MC-122717

Command success messages for some commands include unaffected entities, unlike command result

The bug

When a command affects multiple entities, it's often the case that the command fails for some entities and succeeds for others. For example, adding a tag to some entities that already have it and others that don't. The command result usually reflects how many entities were successfully affected, but the command feedback message often includes all entities, even unaffected ones.

Affected commands

Each of these commands behaves similarly:

  • result is the number of affected entities.

  • If none were affected, an error is shown.

  • ❌ If any were affected, the success message includes the total number of entities found by the selector, not just the affected ones.

  • ❌ The "single success" message only appears if the selector only found one entity; it does not appear when it found multiple but only one was affected.

Command

An entity is unaffected if...

/tag ... add

It has too many tags, or already has the tag

/tag ... remove

It doesn't have the tag

/scoreboard players enable

The trigger is already enabled for that player

/recipe give

The player already knows the recipe

/recipe take

The player doesn't know the recipe

/playsound

The player is "too far away"

/enchant

It's not a mob/player
It's not holding anything
It's holding an incompatible item
It's holding an item with incompatible enchantments

/effect give

It's not a mob/player
It's immune to the effect
It has a stronger effect already

/effect clear ...

It's not a mob/player
It doesn't have the effect

/effect clear

It's not a mob/player
It doesn't have any effects

/clear ...

No matching items were found

/advancement grant

The player already has the advancement

/advancement revoke

The player doesn't have the advancement

/advancement grant ... only ...

The player already has the criterion

/advancement revoke ... only ...

The player doesn't have the criterion

/advancement poses a unique challenge. The result is simply the number of changes applied to any player, meaning the many-to-many scenario currently does not know (A) how many advancements found were changed on at least one player, and (B) how many players found had at least one advancement changed. Those are the two numbers that should in theory appear in the feedback message.

/recipe and /clear also currently only keep track of a running total for their result. They need to also keep track of how many players were affected to appear in the feedback message.

For all other commands, simply substituting the existing result into the feedback message would resolve the issue.

How to reproduce

/tag @e[sort=nearest,limit=5] add test
/tag @e[sort=nearest,limit=6] add test

Expected result
Added tag 'test' to 5 entities
Added tag 'test' to (some specific entity)

Observed result
Added tag 'test' to 5 entities
Added tag 'test' to 6 entities

Linked issues

Attachments

Comments 2

Confirmed for 1.13-pre2

Can confirm in 24w18a for the /effect command.

[media]

tryashtar

(Unassigned)

Confirmed

Commands

command-feedback

Minecraft 17w48a, Minecraft 17w49a, Minecraft 17w49b, Minecraft 17w50a, Minecraft 18w01a, ..., 22w42a, 1.20.6, 24w18a, 24w40a, 1.21.5

Retrieved