[PR #5071] [MERGED] fix(combat): a player hurt by a creeper's blast takes a player_explosion #6040

Closed
opened 2026-11-03 05:16:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5071
Author: @reservedbytes
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/player-creeper-blast-type


📝 Commits (1)

  • 9b63c4c fix(combat): a player hurt by a creeper's blast takes a player_explosion

📊 Changes

4 files changed (+147 additions, -37 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+9 -10)
📝 crates/horizon-client/src/game/explosion.rs (+127 -24)
📝 crates/horizon-client/src/game/wither.rs (+0 -3)
📝 crates/horizon-client/src/mobs/sulfur_cube.rs (+11 -0)

📄 Description

What and why

A player hurt or killed by a creeper's blast recorded minecraft:explosion
Vanilla records minecraft:player_explosion
Vanilla picks player_explosion whenever the blast has both a direct and a causing entity, and an exploding creeper is both
server_explode passed minecraft:explosion for every blast, so the player path never asked whether something caused it
A new blast_cause finds the blast's causing entity: the mob that owns the exploding projectile while it is still in the level, else the exploding mob
server_explode picks the type from it with creatures::damage_type, whose caused flag #4931 added for blasts
The blasts that reach it with a cause are a creeper's, a sulfur cube's, the wither's spawn blast, a wither skull and a ghast fireball, all player_explosion in vanilla as well
A ghast fireball that hits the player directly keeps its owner for the blast that follows
Before, the direct hit took projectile_owner, so the blast had no cause
A sulfur cube now names itself as the blast's source before it explodes, like a creeper and the wither
Before, its cause was guessed from the mobs near the centre, so a bystander could be named
Its blast now leaves the cube out, as getEntities(source, box) does in vanilla
A fireball or skull whose owner was removed before it landed has no cause, so it stays explosion and "blew up", as in vanilla
The mobs the blast hurts take the same cause as their attacker, so a removed owner no longer makes their hurt a player_explosion either
Whether mob_griefing off spares decorations from a mob's blast reads the same cause
The causing mob for the death message is now noted in explosion_hurt_player, under the type the player is hurt with
That lands in whichever tracker as_guest has swapped in, so a LAN guest's death message names the creeper too
Before, the cause was noted in the host's tracker before the blast, and a guest's own tracker never saw it
The death message changes from "Steve blew up" to "Steve was blown up by Creeper"
player_explosion's message id is explosion.player, and death.attack.explosion.player is "%1$s was blown up by %2$s"
LAN guests get player_explosion in the damage event, like a vanilla server sends
Loot and advancement predicates that test the damage type of the player's hurt or death now see player_explosion, and #minecraft:can_break_armor_stand matches it
No vanilla advancement or loot table tests an explosion type
Blast Protection and the knockback and panic tags have both types, so protection and knockback don't change
Beds and respawn anchors already hurt with bad_respawn_point
TNT is left to #4689, and fireworks don't go through this path
An end crystal's blast still records explosion when a player destroyed it, and so does a ghast fireball a player sent back
Vanilla records player_explosion caused by that player there
Horizon has no player cause for a blast yet
An end crystal broken by a mob's projectile also records explosion
Vanilla gives explosion(crystal, skeleton), which is a player_explosion
A TNT minecart primed by a source still records explosion
Vanilla carries its ignitionSource into the blast
A unit test checks the type and the named cause together for a creeper's blast, a live ghast's fireball, a fireball whose ghast was removed and a blast with no cause
It also covers an owner and an exploding mob both set, and a mob still in the level named before the exploded list
I think the guest's death message now reads "Guest was blown up by Creeper", but I didn't run it over LAN

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

DamageSources.explosion(entity, cause) picks PLAYER_EXPLOSION when both are set, EXPLOSION otherwise (world/damagesource/DamageSources.java:255-257)
ServerExplosion uses damageSources().explosion(this) when no source is given (world/level/ServerExplosion.java:70), which reads the direct and the indirect entity (world/damagesource/DamageSources.java:251-253)
Explosion.getIndirectSourceEntity is the source itself when it is a living entity, a projectile's living owner, or a primed TNT's owner (world/level/Explosion.java:18-25)
Projectile.getOwner resolves its EntityReference, which is null once the owner is removed (world/entity/projectile/Projectile.java:92-93, world/entity/EntityReference.java:57-73)
Creeper.explodeCreeper explodes with itself as the source (world/entity/monster/Creeper.java:234), so the creeper is both entities
The same holds for WitherBoss (world/entity/boss/wither/WitherBoss.java:267), WitherSkull (world/entity/projectile/hurtingprojectile/WitherSkull.java:97), LargeFireball (world/entity/projectile/hurtingprojectile/LargeFireball.java:36) and SulfurCube (world/entity/monster/cubemob/SulfurCube.java:305-308)
EndCrystal.hurtServer passes explosion(crystal, source.getEntity()) when something hurt it (world/entity/boss/enderdragon/EndCrystal.java:98-99)
BedBlock and RespawnAnchorBlock explode with badRespawnPointExplosion (world/level/block/BedBlock.java:55, world/level/block/RespawnAnchorBlock.java:169)
player_explosion has the message id explosion.player (world/damagesource/DamageTypes.java:108), and DamageSource.getLocalizedDeathMessage names the causing entity with death.attack.<msgId> (world/damagesource/DamageSource.java:77-91)
player_explosion is in #minecraft:can_break_armor_stand and #minecraft:is_explosion, explosion only in the latter (data tags/damage_type)

Other projects' code

none

Self-check

Check Result
Scope ✅ 4 files, +147 −37
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 7 s)
rustfmt ✅ (9 s)
clippy ✅ (2 min 16 s)
tests: horizon-client ✅ 1341 passed (5 min 14 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5071 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/player-creeper-blast-type` --- ### 📝 Commits (1) - [`9b63c4c`](https://github.com/horizon-rust/horizon/commit/9b63c4c7355889087f5c5e0582ebf44411602077) fix(combat): a player hurt by a creeper's blast takes a player_explosion ### 📊 Changes **4 files changed** (+147 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+9 -10) 📝 `crates/horizon-client/src/game/explosion.rs` (+127 -24) 📝 `crates/horizon-client/src/game/wither.rs` (+0 -3) 📝 `crates/horizon-client/src/mobs/sulfur_cube.rs` (+11 -0) </details> ### 📄 Description ## What and why A player hurt or killed by a creeper's blast recorded `minecraft:explosion` Vanilla records `minecraft:player_explosion` Vanilla picks `player_explosion` whenever the blast has both a direct and a causing entity, and an exploding creeper is both `server_explode` passed `minecraft:explosion` for every blast, so the player path never asked whether something caused it A new `blast_cause` finds the blast's causing entity: the mob that owns the exploding projectile while it is still in the level, else the exploding mob `server_explode` picks the type from it with `creatures::damage_type`, whose `caused` flag #4931 added for blasts The blasts that reach it with a cause are a creeper's, a sulfur cube's, the wither's spawn blast, a wither skull and a ghast fireball, all `player_explosion` in vanilla as well A ghast fireball that hits the player directly keeps its owner for the blast that follows Before, the direct hit took `projectile_owner`, so the blast had no cause A sulfur cube now names itself as the blast's source before it explodes, like a creeper and the wither Before, its cause was guessed from the mobs near the centre, so a bystander could be named Its blast now leaves the cube out, as `getEntities(source, box)` does in vanilla A fireball or skull whose owner was removed before it landed has no cause, so it stays `explosion` and "blew up", as in vanilla The mobs the blast hurts take the same cause as their attacker, so a removed owner no longer makes their hurt a `player_explosion` either Whether `mob_griefing` off spares decorations from a mob's blast reads the same cause The causing mob for the death message is now noted in `explosion_hurt_player`, under the type the player is hurt with That lands in whichever tracker `as_guest` has swapped in, so a LAN guest's death message names the creeper too Before, the cause was noted in the host's tracker before the blast, and a guest's own tracker never saw it The death message changes from "Steve blew up" to "Steve was blown up by Creeper" `player_explosion`'s message id is `explosion.player`, and `death.attack.explosion.player` is "%1$s was blown up by %2$s" LAN guests get `player_explosion` in the damage event, like a vanilla server sends Loot and advancement predicates that test the damage type of the player's hurt or death now see `player_explosion`, and `#minecraft:can_break_armor_stand` matches it No vanilla advancement or loot table tests an explosion type Blast Protection and the knockback and panic tags have both types, so protection and knockback don't change Beds and respawn anchors already hurt with `bad_respawn_point` TNT is left to #4689, and fireworks don't go through this path An end crystal's blast still records `explosion` when a player destroyed it, and so does a ghast fireball a player sent back Vanilla records `player_explosion` caused by that player there Horizon has no player cause for a blast yet An end crystal broken by a mob's projectile also records `explosion` Vanilla gives `explosion(crystal, skeleton)`, which is a `player_explosion` A TNT minecart primed by a source still records `explosion` Vanilla carries its `ignitionSource` into the blast A unit test checks the type and the named cause together for a creeper's blast, a live ghast's fireball, a fireball whose ghast was removed and a blast with no cause It also covers an owner and an exploding mob both set, and a mob still in the level named before the exploded list I think the guest's death message now reads "Guest was blown up by Creeper", but I didn't run it over LAN ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `DamageSources.explosion(entity, cause)` picks `PLAYER_EXPLOSION` when both are set, `EXPLOSION` otherwise (`world/damagesource/DamageSources.java:255-257`) `ServerExplosion` uses `damageSources().explosion(this)` when no source is given (`world/level/ServerExplosion.java:70`), which reads the direct and the indirect entity (`world/damagesource/DamageSources.java:251-253`) `Explosion.getIndirectSourceEntity` is the source itself when it is a living entity, a projectile's living owner, or a primed TNT's owner (`world/level/Explosion.java:18-25`) `Projectile.getOwner` resolves its `EntityReference`, which is null once the owner is removed (`world/entity/projectile/Projectile.java:92-93`, `world/entity/EntityReference.java:57-73`) `Creeper.explodeCreeper` explodes with itself as the source (`world/entity/monster/Creeper.java:234`), so the creeper is both entities The same holds for `WitherBoss` (`world/entity/boss/wither/WitherBoss.java:267`), `WitherSkull` (`world/entity/projectile/hurtingprojectile/WitherSkull.java:97`), `LargeFireball` (`world/entity/projectile/hurtingprojectile/LargeFireball.java:36`) and `SulfurCube` (`world/entity/monster/cubemob/SulfurCube.java:305-308`) `EndCrystal.hurtServer` passes `explosion(crystal, source.getEntity())` when something hurt it (`world/entity/boss/enderdragon/EndCrystal.java:98-99`) `BedBlock` and `RespawnAnchorBlock` explode with `badRespawnPointExplosion` (`world/level/block/BedBlock.java:55`, `world/level/block/RespawnAnchorBlock.java:169`) `player_explosion` has the message id `explosion.player` (`world/damagesource/DamageTypes.java:108`), and `DamageSource.getLocalizedDeathMessage` names the causing entity with `death.attack.<msgId>` (`world/damagesource/DamageSource.java:77-91`) `player_explosion` is in `#minecraft:can_break_armor_stand` and `#minecraft:is_explosion`, `explosion` only in the latter (data `tags/damage_type`) ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 4 files, +147 −37 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 7 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (2 min 16 s) | | tests: horizon-client | ✅ 1341 passed (5 min 14 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6040
No description provided.