[PR #4225] [MERGED] Slimes and magma cubes hurt the iron golems they touch #5498

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4225
Author: @d3grando
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3513-cube-hurts-golem


📝 Commits (2)

  • 84ac601 Slimes and magma cubes hurt the iron golems they touch
  • d225a5f Merge origin/main into fix-3513-cube-hurts-golem

📊 Changes

3 files changed (+164 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+25 -0)
📝 crates/horizon-client/src/mobs.rs (+9 -0)
📝 crates/horizon-client/src/mobs/cube.rs (+130 -8)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Slimes and magma cubes target iron golems (NearestTarget::species([IronGolem]) in mobs/cube.rs) and hop at them, but never hurt them. cube::ai_step only ported the playerTouch path (Player.touch -> dealDamage). Vanilla also has AbstractCubeMob.push(Entity), which calls dealDamage on an IronGolem when the golem's LivingEntity.pushEntities picks up the cube. Horizon had no equivalent.

The fix: after the player check, ai_step now runs hurt_touching_golems. It finds every alive iron golem whose box overlaps the cube's (the golem's pushEntities box, with EntitySelector.pushableBy team collision rules). For each one it applies dealDamage's checks (doTeamsAllowDamage, isWithinMeleeAttackRange, which always holds for overlapping boxes, and hasLineOfSight) and emits a hit for getAttackDamage with a mobAttack source: the size for slimes, size + 2 for magma cubes (MagmaCube.getAttackDamage). Tiny slimes still never hurt, and neither does a NoAI cube (canDealDamage needs isEffectiveAi, which Mob makes false for NoAI).

A new MobEvent::CubeHurtMob carries the hit. The game applies it through mob_hits_mob. Like dealDamage, it plays entity.slime.attack only when hurtServer let the hit land, and only then draws the two pitch floats from the cube's random (even for a silent cube, whose playSound is then skipped, as in vanilla). So a golem in its invulnerability window doesn't trigger a sound every tick. The golem then fights back through its usual hurt-by targeting, because the source names the cube.

Part of #3513 (rows AbstractCubeMob.push and AbstractCubeMob.dealDamage).

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

  • net.minecraft.world.entity.monster.cubemob.AbstractCubeMob.push(Entity): super.push, then if (entity instanceof IronGolem && canDealDamage()) dealDamage((LivingEntity) entity).
  • AbstractCubeMob.dealDamage(LivingEntity): isAlive, doTeamsAllowDamage, isWithinMeleeAttackRange, hasLineOfSight, then hurtServer(mobAttack(this), getAttackDamage()). Only if that returns true: playSound(SLIME_ATTACK, 1.0, (r.nextFloat() - r.nextFloat()) * 0.2 + 1.0).
  • AbstractCubeMob.canDealDamage (!isTiny() && isEffectiveAi()) and MagmaCube.canDealDamage (isEffectiveAi()); AbstractCubeMob.getAttackDamage and MagmaCube.getAttackDamage (+2).
  • LivingEntity.pushEntities: level.getPushableEntities(this, getBoundingBox()), then doPush(e) = e.push(this).

All read with javap on the 26.3 client jar. No parity harness covers cube contact damage. The new unit test mobs::cube::golem_touch_tests::a_cube_touching_an_iron_golem_hurts_it checks it: a size 2 slime hits for 2, a size 4 magma cube for 6, a tiny magma cube for 3, a tiny slime never, a NoAI slime never, and nothing happens when the golem is out of touch.

Self-check

tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • New test, with only the hurt_touching_golems(m, w, events); call commented out (the fix reverted):
    cargo test -p horizon-client --lib -- mobs::cube::golem_touch_tests -> FAILED: a size 2 slime hits the golem for 2, left [], right [(2, 2.0)]
  • With only the m.no_ai guard removed: FAILED: a NoAI cube is not isEffectiveAi, so it cannot deal damage
  • Same command with the fix: test mobs::cube::golem_touch_tests::a_cube_touching_an_iron_golem_hurts_it ... ok
  • cargo test -p horizon-client --lib -- mobs::cube mobs::golem mobs::ai:: mobs::sulfur_cube: 8 passed
  • cargo test -p horizon-client --bin horizon-client -- game::creatures game::combat: 3 passed
  • In game (Windows, single player on the server thread, creative, normal difficulty): a NoAI iron golem and a size 2 slime shut in a 3x2 glass box. Before the fix, the golem was still at 100/100 health after more than 2 minutes of the slime bumping into it (horizon-ctl entities). With the fix, the golem started losing 2 health per hit as soon as the slime touched it, and was at 14/100 after about 30 seconds.

Screenshots

after: a slime pushing into an iron golem hurts it (the golem flashes red), as AbstractCubeMob.push does

Same spot, same time of day (noon, daylight cycle off), same setup (a NoAI iron golem and a size 2 slime in a glass box), seen through the glass:

  • Before: after more than 2 minutes of contact, the golem has no cracks (100/100 health).
  • After: within about 30 seconds the golem is heavily cracked and flashes red from the slime's hits (14/100 health).

🤖 Generated with Claude Code


🔄 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/4225 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3513-cube-hurts-golem` --- ### 📝 Commits (2) - [`84ac601`](https://github.com/horizon-rust/horizon/commit/84ac601f3aab9aa4760ec09f738af8e98a5becae) Slimes and magma cubes hurt the iron golems they touch - [`d225a5f`](https://github.com/horizon-rust/horizon/commit/d225a5fdf73d96d3d85d76edb06533d0a202d800) Merge origin/main into fix-3513-cube-hurts-golem ### 📊 Changes **3 files changed** (+164 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+25 -0) 📝 `crates/horizon-client/src/mobs.rs` (+9 -0) 📝 `crates/horizon-client/src/mobs/cube.rs` (+130 -8) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Slimes and magma cubes target iron golems (`NearestTarget::species([IronGolem])` in `mobs/cube.rs`) and hop at them, but never hurt them. `cube::ai_step` only ported the `playerTouch` path (`Player.touch` -> `dealDamage`). Vanilla also has `AbstractCubeMob.push(Entity)`, which calls `dealDamage` on an `IronGolem` when the golem's `LivingEntity.pushEntities` picks up the cube. Horizon had no equivalent. The fix: after the player check, `ai_step` now runs `hurt_touching_golems`. It finds every alive iron golem whose box overlaps the cube's (the golem's `pushEntities` box, with `EntitySelector.pushableBy` team collision rules). For each one it applies `dealDamage`'s checks (`doTeamsAllowDamage`, `isWithinMeleeAttackRange`, which always holds for overlapping boxes, and `hasLineOfSight`) and emits a hit for `getAttackDamage` with a `mobAttack` source: the size for slimes, size + 2 for magma cubes (`MagmaCube.getAttackDamage`). Tiny slimes still never hurt, and neither does a NoAI cube (`canDealDamage` needs `isEffectiveAi`, which `Mob` makes false for NoAI). A new `MobEvent::CubeHurtMob` carries the hit. The game applies it through `mob_hits_mob`. Like `dealDamage`, it plays `entity.slime.attack` only when `hurtServer` let the hit land, and only then draws the two pitch floats from the cube's random (even for a silent cube, whose `playSound` is then skipped, as in vanilla). So a golem in its invulnerability window doesn't trigger a sound every tick. The golem then fights back through its usual hurt-by targeting, because the source names the cube. Part of #3513 (rows `AbstractCubeMob.push` and `AbstractCubeMob.dealDamage`). ## 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 - `net.minecraft.world.entity.monster.cubemob.AbstractCubeMob.push(Entity)`: `super.push`, then `if (entity instanceof IronGolem && canDealDamage()) dealDamage((LivingEntity) entity)`. - `AbstractCubeMob.dealDamage(LivingEntity)`: `isAlive`, `doTeamsAllowDamage`, `isWithinMeleeAttackRange`, `hasLineOfSight`, then `hurtServer(mobAttack(this), getAttackDamage())`. Only if that returns true: `playSound(SLIME_ATTACK, 1.0, (r.nextFloat() - r.nextFloat()) * 0.2 + 1.0)`. - `AbstractCubeMob.canDealDamage` (`!isTiny() && isEffectiveAi()`) and `MagmaCube.canDealDamage` (`isEffectiveAi()`); `AbstractCubeMob.getAttackDamage` and `MagmaCube.getAttackDamage` (+2). - `LivingEntity.pushEntities`: `level.getPushableEntities(this, getBoundingBox())`, then `doPush(e)` = `e.push(this)`. All read with javap on the 26.3 client jar. No parity harness covers cube contact damage. The new unit test `mobs::cube::golem_touch_tests::a_cube_touching_an_iron_golem_hurts_it` checks it: a size 2 slime hits for 2, a size 4 magma cube for 6, a tiny magma cube for 3, a tiny slime never, a NoAI slime never, and nothing happens when the golem is out of touch. ## Self-check `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - New test, with only the `hurt_touching_golems(m, w, events);` call commented out (the fix reverted): `cargo test -p horizon-client --lib -- mobs::cube::golem_touch_tests` -> **FAILED**: `a size 2 slime hits the golem for 2`, left `[]`, right `[(2, 2.0)]` - With only the `m.no_ai` guard removed: **FAILED**: `a NoAI cube is not isEffectiveAi, so it cannot deal damage` - Same command with the fix: `test mobs::cube::golem_touch_tests::a_cube_touching_an_iron_golem_hurts_it ... ok` - `cargo test -p horizon-client --lib -- mobs::cube mobs::golem mobs::ai:: mobs::sulfur_cube`: 8 passed - `cargo test -p horizon-client --bin horizon-client -- game::creatures game::combat`: 3 passed - In game (Windows, single player on the server thread, creative, normal difficulty): a NoAI iron golem and a size 2 slime shut in a 3x2 glass box. Before the fix, the golem was still at 100/100 health after more than 2 minutes of the slime bumping into it (`horizon-ctl entities`). With the fix, the golem started losing 2 health per hit as soon as the slime touched it, and was at 14/100 after about 30 seconds. ## Screenshots ![after: a slime pushing into an iron golem hurts it (the golem flashes red), as AbstractCubeMob.push does](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3513-cube-hurts-golem-1.png) Same spot, same time of day (noon, daylight cycle off), same setup (a NoAI iron golem and a size 2 slime in a glass box), seen through the glass: - Before: after more than 2 minutes of contact, the golem has no cracks (100/100 health). - After: within about 30 seconds the golem is heavily cracked and flashes red from the slime's hits (14/100 health). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:00 +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#5498
No description provided.