Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GrantGryczan opened this issue Jun 26, 2024 · 1 comment · May be fixed by #5850
Open
Labels
bug: confirmed Confirmed bugs in EssentialsX.

Comments

@GrantGryczan
Copy link

GrantGryczan commented Jun 26, 2024

Type of bug

Compatibility issue, 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

In MC 1.20.6, 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

This applies to /suicide as well.

See #5850 (comment) for important notes on how to fix this.

@GrantGryczan GrantGryczan added the bug: unconfirmed Potential bugs that need replicating to verify. label Jun 26, 2024
@GrantGryczan GrantGryczan changed the title /kill doesn't trigger minecraft:entity_hurt_player advancement (breaking data packs) /kill doesn't call minecraft:entity_hurt_player advancement trigger (breaking data packs) Jun 26, 2024
@zp4rker
Copy link

zp4rker commented Jun 28, 2024

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

@JRoy JRoy added bug: confirmed Confirmed bugs in EssentialsX. and removed bug: unconfirmed Potential bugs that need replicating to verify. labels Jun 29, 2024
zp4rker added a commit to zp4rker/Essentials that referenced this issue Jun 29, 2024
…le)`

Using Float.MAX_VALUE as that is what `/minecraft:kill` uses

Fixes EssentialsX#5842
@zp4rker zp4rker linked a pull request Jun 30, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed Confirmed bugs in EssentialsX.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants