[PR #4022] [MERGED] Withers and golems build in any orientation, like vanilla #5364

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

📋 Pull Request Information

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

Base: main ← Head: fix-3098


📝 Commits (1)

  • 5200d36 Withers build in any orientation, like vanilla's BlockPattern

📊 Changes

5 files changed (+332 additions, -81 deletions)

View changed files

➕ crates/horizon-client/src/block_pattern.rs (+262 -0)
📝 crates/horizon-client/src/game/dispenser.rs (+7 -23)
📝 crates/horizon-client/src/game/golems.rs (+12 -11)
📝 crates/horizon-client/src/game/wither.rs (+50 -47)
📝 crates/horizon-client/src/lib.rs (+1 -0)

📄 Description

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

What and why

A wither only spawned when its T was built upright with the arms along X or Z. Both check_wither_spawn and the dispenser's can_build_wither tried just those two layouts. Vanilla's BlockPattern.find tries every orientation: 24 forwards/up pairs, from every front-top-left corner in the cube that starts at the placed block. So in vanilla a T lying flat on the ground, upside down or turned on its side still builds a wither. In Horizon none of these did anything.

This adds horizon_client::block_pattern, a port of BlockPattern (find, matches, translateAndRotate, BlockPatternMatch.getBlock) with the wither's full and base patterns as data. The wither checks now go through it:

  • check_wither_spawn (WitherSkullBlock.checkSpawn) uses the full pattern and clears the match's front layer. The wither stands on getBlock(1, 2, 0) and takes its yaw from the match's forwards axis (0 for X, else 90). Main had this inverted for upright builds: vanilla's match for a T along X faces north or south, so its yaw is 90, but main gave 0.
  • The summon base blocks come from #minecraft:wither_summon_base_blocks instead of a hard-coded pair.
  • SUMMONED_ENTITY for the wither now checks the 50-block box around it, as vanilla does. The golems' existing 5-block check became trigger_summoned(id, reach) so the two share it. Before, the wither fired the trigger for the local player at any distance.
  • The dispenser's can_build_wither (WitherSkullBlock.canSpawnMob) uses the base pattern.

Fixes #3098. It also covers the wither item of #3845. I found no cause in these checks for the "only at y <= 135" claim there: they have no height limit apart from the dispenser's existing minY + 2, and an upright wither built at y = 200 spawned in game. The report's screenshot has expired, so I can't tell which layout it used; orientation is the one gap left in these checks.

Golems have the same orientation gap. #3959 already fixes it for snow and iron golems in golems.rs, so this PR leaves the golem patterns alone. Once both land, the golems can move onto block_pattern, and the copper golem (still checked straight down) can follow.

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

Read with javap from the 26.3 client jar:

  • net.minecraft.world.level.block.state.pattern.BlockPattern: find(LevelReader, BlockPos) (corners from BlockPos.betweenClosed(pos, pos + size - 1), then Direction.values() for forwards and up, skipping equal or opposite pairs), matches, translateAndRotate.
  • WitherSkullBlock: checkSpawn(Level, BlockPos, SkullBlockEntity) (getBlock(1, 2, 0), yaw from getForwards().getAxis(), SUMMONED_ENTITY for players in getBoundingBox().inflate(50.0)), canSpawnMob, getOrCreateWitherFull, getOrCreateWitherBase ('#' is BlockTags.WITHER_SUMMON_BASE_BLOCKS, '~' is isAir).
  • CarvedPumpkinBlock.clearPatternBlocks / updatePatternBlocks for the cells cleared and updated.

No parity harness covers block patterns. The new unit tests in block_pattern::tests cover it instead:

  • the wither found from each of its three skulls in seven layouts (upright along X and Z, upside down, flat two ways, sideways two ways), with the spawn cell and cleared cells checked;
  • the forwards axis used for the yaw;
  • the air rule beside the leg;
  • the base pattern ignoring the skull row.

Self-check

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

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client --lib block_pattern: 5 passed
  • cargo test -p horizon-client --lib --bins wither / golem / dispens: 4, 4 and 0 lib tests, all passed; no bin tests match these names

Before / after: I limited BlockPattern::find to what main tried (up = UP only, so upright builds along X or Z) and reran the tests. wither_builds_in_any_orientation failed (1 failed, 4 passed): the upright layouts still matched, the flat, upside-down and sideways ones did not. With the full search, all 5 pass.

In game (single player on the server thread, creative, Normal difficulty): I placed the last skull or pumpkin with horizon-ctl place.

  • Before (build of main): a wither T lying flat on the ground stayed as blocks and entities listed nothing.
  • After:
    • The flat T turned into a wither on the middle soul sand of the leg, the pattern blocks were cleared, and "Withering Heights" was granted.
    • An upright T along X still builds. data get entity @e[type=wither,limit=1] Rotation gives [90.0f, 0.0f], the yaw vanilla gives that layout (main's code set 0).
    • An upright T at y = 200 builds too.
    • An upright snow golem still builds, so the golems' shared trigger check still works.

Screenshots

after: a wither built lying flat spawns (boss bar) and Withering Heights is awarded

  • Before: the flat wither T stays as blocks after the last skull is placed.
  • After: the same build turns into a wither (boss bar showing) and the Withering Heights advancement appears in chat.

🤖 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/4022 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3098` --- ### 📝 Commits (1) - [`5200d36`](https://github.com/horizon-rust/horizon/commit/5200d36a7bf9540156c226dba6b96c3b1dca9fca) Withers build in any orientation, like vanilla's BlockPattern ### 📊 Changes **5 files changed** (+332 additions, -81 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/src/block_pattern.rs` (+262 -0) 📝 `crates/horizon-client/src/game/dispenser.rs` (+7 -23) 📝 `crates/horizon-client/src/game/golems.rs` (+12 -11) 📝 `crates/horizon-client/src/game/wither.rs` (+50 -47) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why A wither only spawned when its T was built upright with the arms along X or Z. Both `check_wither_spawn` and the dispenser's `can_build_wither` tried just those two layouts. Vanilla's `BlockPattern.find` tries every orientation: 24 forwards/up pairs, from every front-top-left corner in the cube that starts at the placed block. So in vanilla a T lying flat on the ground, upside down or turned on its side still builds a wither. In Horizon none of these did anything. This adds `horizon_client::block_pattern`, a port of `BlockPattern` (`find`, `matches`, `translateAndRotate`, `BlockPatternMatch.getBlock`) with the wither's full and base patterns as data. The wither checks now go through it: - `check_wither_spawn` (`WitherSkullBlock.checkSpawn`) uses the full pattern and clears the match's front layer. The wither stands on `getBlock(1, 2, 0)` and takes its yaw from the match's forwards axis (0 for X, else 90). Main had this inverted for upright builds: vanilla's match for a T along X faces north or south, so its yaw is 90, but main gave 0. - The summon base blocks come from `#minecraft:wither_summon_base_blocks` instead of a hard-coded pair. - SUMMONED_ENTITY for the wither now checks the 50-block box around it, as vanilla does. The golems' existing 5-block check became `trigger_summoned(id, reach)` so the two share it. Before, the wither fired the trigger for the local player at any distance. - The dispenser's `can_build_wither` (`WitherSkullBlock.canSpawnMob`) uses the base pattern. Fixes #3098. It also covers the wither item of #3845. I found no cause in these checks for the "only at y <= 135" claim there: they have no height limit apart from the dispenser's existing `minY + 2`, and an upright wither built at y = 200 spawned in game. The report's screenshot has expired, so I can't tell which layout it used; orientation is the one gap left in these checks. Golems have the same orientation gap. #3959 already fixes it for snow and iron golems in `golems.rs`, so this PR leaves the golem patterns alone. Once both land, the golems can move onto `block_pattern`, and the copper golem (still checked straight down) can follow. ## 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 Read with javap from the 26.3 client jar: - `net.minecraft.world.level.block.state.pattern.BlockPattern`: `find(LevelReader, BlockPos)` (corners from `BlockPos.betweenClosed(pos, pos + size - 1)`, then `Direction.values()` for forwards and up, skipping equal or opposite pairs), `matches`, `translateAndRotate`. - `WitherSkullBlock`: `checkSpawn(Level, BlockPos, SkullBlockEntity)` (`getBlock(1, 2, 0)`, yaw from `getForwards().getAxis()`, SUMMONED_ENTITY for players in `getBoundingBox().inflate(50.0)`), `canSpawnMob`, `getOrCreateWitherFull`, `getOrCreateWitherBase` (`'#'` is `BlockTags.WITHER_SUMMON_BASE_BLOCKS`, `'~'` is `isAir`). - `CarvedPumpkinBlock.clearPatternBlocks` / `updatePatternBlocks` for the cells cleared and updated. No parity harness covers block patterns. The new unit tests in `block_pattern::tests` cover it instead: - the wither found from each of its three skulls in seven layouts (upright along X and Z, upside down, flat two ways, sideways two ways), with the spawn cell and cleared cells checked; - the forwards axis used for the yaw; - the air rule beside the leg; - the base pattern ignoring the skull row. ## Self-check `tools/pr_ready.py` doesn't run on Windows, so I ran its steps by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client --lib block_pattern`: 5 passed - `cargo test -p horizon-client --lib --bins wither` / `golem` / `dispens`: 4, 4 and 0 lib tests, all passed; no bin tests match these names **Before / after:** I limited `BlockPattern::find` to what main tried (up = UP only, so upright builds along X or Z) and reran the tests. `wither_builds_in_any_orientation` failed (1 failed, 4 passed): the upright layouts still matched, the flat, upside-down and sideways ones did not. With the full search, all 5 pass. **In game** (single player on the server thread, creative, Normal difficulty): I placed the last skull or pumpkin with `horizon-ctl place`. - Before (build of `main`): a wither T lying flat on the ground stayed as blocks and `entities` listed nothing. - After: - The flat T turned into a wither on the middle soul sand of the leg, the pattern blocks were cleared, and "Withering Heights" was granted. - An upright T along X still builds. `data get entity @e[type=wither,limit=1] Rotation` gives `[90.0f, 0.0f]`, the yaw vanilla gives that layout (main's code set 0). - An upright T at y = 200 builds too. - An upright snow golem still builds, so the golems' shared trigger check still works. ## Screenshots ![after: a wither built lying flat spawns (boss bar) and Withering Heights is awarded](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3098-1.png) - Before: the flat wither T stays as blocks after the last skull is placed. - After: the same build turns into a wither (boss bar showing) and the Withering Heights advancement appears in chat. 🤖 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:12:04 +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#5364
No description provided.