[PR #6225] [MERGED] Send a silverfish back into the stone it came from #6729

Closed
opened 2026-11-03 06:25:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6225
Author: @MSedgeMC
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/silverfish-walk-target


📝 Commits (1)

  • 0d3eb99 Send a silverfish back into the stone it came from

📊 Changes

2 files changed (+71 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/mobs/ai.rs (+56 -0)
📝 crates/horizon-client/src/mobs/hostile.rs (+15 -0)

📄 Description

Silverfish.getWalkTargetValue gives one position class a top score:

// javap -p -c on Silverfish
 2: invokevirtual BlockPos.below
 5: invokevirtual LevelReader.getBlockState
10: invokestatic  InfestedBlock.isCompatibleHostBlock
13: ifeq          19
16: ldc           10.0f
18: freturn
19: invokespecial Monster.getWalkTargetValue

and InfestedBlock.isCompatibleHostBlock is a lookup in vanilla's host-to-infested map, i.e.
the block is one of stone, cobblestone, stone bricks (plain, mossy, cracked, chiseled) or
deepslate.

Horizon's walk_target_value had cases for the guardian, happy ghast, strider, turtle, hoglin,
bee, nautilus and animals, but nothing for the silverfish, so it fell through to the monster
light value: stone was worth no more than dirt and a silverfish never preferred a block it could
burrow out of.

Proven: on the build VM, cargo test -q -p horizon-client --lib a_silverfish_prefers_a_block_on_an_infested_host
→ 1 passed: a position on stone scores 10 and the same position on dirt does not, in the same
built world.

Not proven: not checked in game; the check is a silverfish's stroll target next to a stone
wall.

One thing worth naming: is_infested_host matches the seven host block names directly rather
than reading vanilla's map, because the prepared resources do not export it. A modded infested
block would not be recognised.

Note (added after the crate split): the tests under crates/horizon-client/src/ other than game/ and entry/ are now compiled by the horizon-client-lib crate, so the command above is cargo test -p horizon-client-lib --lib <filter> on current main. The change and the assertions are unchanged.


🔄 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/6225 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/silverfish-walk-target` --- ### 📝 Commits (1) - [`0d3eb99`](https://github.com/horizon-rust/horizon/commit/0d3eb998ae2b4eef2725c519a84e57fbc6aa7876) Send a silverfish back into the stone it came from ### 📊 Changes **2 files changed** (+71 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/ai.rs` (+56 -0) 📝 `crates/horizon-client/src/mobs/hostile.rs` (+15 -0) </details> ### 📄 Description `Silverfish.getWalkTargetValue` gives one position class a top score: ```java // javap -p -c on Silverfish 2: invokevirtual BlockPos.below 5: invokevirtual LevelReader.getBlockState 10: invokestatic InfestedBlock.isCompatibleHostBlock 13: ifeq 19 16: ldc 10.0f 18: freturn 19: invokespecial Monster.getWalkTargetValue ``` and `InfestedBlock.isCompatibleHostBlock` is a lookup in vanilla's host-to-infested map, i.e. the block is one of stone, cobblestone, stone bricks (plain, mossy, cracked, chiseled) or deepslate. Horizon's `walk_target_value` had cases for the guardian, happy ghast, strider, turtle, hoglin, bee, nautilus and animals, but nothing for the silverfish, so it fell through to the monster light value: stone was worth no more than dirt and a silverfish never preferred a block it could burrow out of. **Proven:** on the build VM, `cargo test -q -p horizon-client --lib a_silverfish_prefers_a_block_on_an_infested_host` → `1 passed`: a position on stone scores 10 and the same position on dirt does not, in the same built world. **Not proven:** not checked in game; the check is a silverfish's stroll target next to a stone wall. One thing worth naming: `is_infested_host` matches the seven host block names directly rather than reading vanilla's map, because the prepared resources do not export it. A modded infested block would not be recognised. Note (added after the crate split): the tests under `crates/horizon-client/src/` other than `game/` and `entry/` are now compiled by the `horizon-client-lib` crate, so the command above is `cargo test -p horizon-client-lib --lib <filter>` on current main. The change and the assertions are unchanged. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:25:41 +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#6729
No description provided.