EssentialsX / Essentials

The modern Essentials suite for Spigot and Paper.
https://essentialsx.net
GNU General Public License v3.0
1.9k stars 966 forks source link

`/kill` doesn't call `minecraft:entity_hurt_player` advancement trigger (breaking data packs) #5842

Open GrantGryczan opened 1 week ago

GrantGryczan commented 1 week ago

Type of bug

Other unexpected behaviour

/ess dump all output

https://essentialsx.net/dump.html?id=4688c1ddb0b848c7a0ed7437d7a5c9e0

Error log (if applicable)

No response

Bug description

In vanilla, an advancement is granted by what's called an advancement trigger. Advancement triggers are like game events. When something occurs in-game that a particular advancement trigger was meant to detect, it triggers all advancements that hook onto that trigger in their data.

One such trigger is minecraft:entity_hurt_player. Despite the name, this is triggered when the player takes any form of damage, including from /kill, and even while in creative mode. But with EssentialsX installed, /kill doesn't trigger minecraft:entity_hurt_player.

If data packs want to detect certain in-game events efficiently (i.e. without checking things every tick), they must use hidden advancements with these triggers. So to detect a player dying, data packs have to use the minecraft:entity_hurt_player advancement trigger. It's the only way for a data pack to detect player deaths efficiently. Therefore, this bug makes /kill able to break any data pack that relies on this to efficiently detect deaths, such as the Graves data pack from Vanilla Tweaks.

Steps to reproduce

Install this data pack by copying it into the datapacks folder in your world save and then reloading the world: test.zip

This is a minimal reproduction data pack which simply hooks onto the minecraft:entity_hurt_player advancement trigger, making it so whenever it triggers, it prints entity_hurt_player in chat to the player who triggered it.

With this data pack installed and enabled, enter /minecraft:kill. (Or if testing in vanilla, just use /kill. With EssentialsX installed, you can also use /kill <username>.)

Expected behaviour

Without EssentialsX, /minecraft:kill prints entity_hurt_player in your chat.

Actual behaviour

With EssentialsX, /minecraft:kill doesn't print entity_hurt_player in your chat, contrary to the vanilla behavior.

Additional Information

No response

zp4rker commented 5 days ago

I was able to replicate this. Seems that setHealth(double) does not call that trigger. Changing it to use damage(double) seems to work. Will do some testing then submit a PR