[PR #7593] A sulfur cube with a block takes a lead #7700

Open
opened 2026-11-03 07:22:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7593
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/sulfur-cube-leash


📝 Commits (4)

  • 9f02173 A sulfur cube takes a lead while it holds a block
  • 8a26f90 Test the sulfur cube's lead and its rope height
  • fc147cc Drop a needless return in the leash test
  • 6727ba9 Bind the test world result instead of naming an unused variable

📊 Changes

2 files changed (+44 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/mobs/leash.rs (+42 -0)
📝 tools/port_map/game2-003.tsv (+2 -1)

📄 Description

Behaviour: a sulfur cube that has swallowed a block can be put on a lead, and the rope hangs at the middle of its box. A sulfur cube with nothing in it cannot, as before.

Vanilla javap -p -c -constants -cp /tmp/cj:

net.minecraft.world.entity.monster.cubemob.SulfurCube.canBeLeashed() overrides the Enemy rule:

 0: aload_0
 1: invokevirtual #206                // Method hasBodyItem:()Z
 4: ireturn

and SulfurCube.hasBodyItem():

 0: aload_0
 1: getstatic     #363                // Field net/minecraft/world/entity/EquipmentSlot.BODY
 4: invokevirtual #369                // Method getItemBySlot:(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;
 7: invokevirtual #373                // Method net/minecraft/world/item/ItemStack.isEmpty:()Z
10: ifne          17
13: iconst_1 / 14: goto 18 / 17: iconst_0 / 18: ireturn

The rule it replaces, net.minecraft.world.entity.Mob.canBeLeashed():

 0: aload_0
 1: instanceof    #1671               // class net/minecraft/world/entity/monster/Enemy
 4: ifne          11
 7: iconst_1 / 8: goto 12 / 11: iconst_0 / 12: ireturn

net.minecraft.world.entity.monster.cubemob.SulfurCube.getLeashOffset():

 0: new Vec3
 4: dconst_0                          // x
 5: aload_0
 6: invokevirtual getBbHeight:()F
 9: fconst_2 / 10: fdiv               // y = getBbHeight() / 2
12: dconst_0                          // z
16: areturn

What Horizon got wrong: mobs/leash.rs::can_be_leashed has no sulfur cube arm, so a cube fell through to !m.hostile() && !m.removed. Its category is monster, so every sulfur cube was refused a lead even while it carried a block — SulfurCube.canBeLeashed never reaches the Enemy rule at all, it asks hasBodyItem. leash_offset fell through to the default [0, eye height, bbWidth * 0.4] (0.175 and 0.196 for a cube's 0.49 box) instead of the cube's own (0, bbHeight / 2, 0) = (0, 0.245, 0).

Test: mobs::leash::tests::a_sulfur_cube_is_leashed_by_its_block_and_hangs_at_its_middle builds a sulfur cube with and without a block in extra.head (the swallowed block) and checks can_be_leashed and leash_offset.

Failing without the fix, the same test. The rope first:

thread '...a_sulfur_cube_is_leashed_by_its_block_and_hangs_at_its_middle' panicked at ...leash.rs:861:
half the box height: 0.17499999701976776 vs 0.24500000476837158

— the eye height 0.175 instead of the cube's half box 0.245 (and the z, unchecked at that point, is 0.196 in front instead of 0). With the offset fixed but the leashing rule left out, the next assertion is a cube holding a block: can_be_leashed is false where vanilla's hasBodyItem makes it true.

Proven: the bytecode above; hasBodyItem is the BODY slot, which Horizon already models as the swallowed block (sulfur_cube::has_body, extra.head), and the lead path reaches it for any mob (game/leads.rs::can_attach_lead → leash::can_be_leashed).

Not proven: no in-game run — that a leashed cube's rope follows it while it rolls is inferred from game/leads.rs using leash_offset for the rope, not watched. A cube's hasBodyItem is the BODY slot; Horizon models the swallowed block as extra.head, which is what has_body reads, and no test covers a cube that swallowed a block and then had it sheared out.


🔄 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/7593 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/sulfur-cube-leash` --- ### 📝 Commits (4) - [`9f02173`](https://github.com/horizon-rust/horizon/commit/9f0217377e7b0811042edfe5fa04d87ea5665306) A sulfur cube takes a lead while it holds a block - [`8a26f90`](https://github.com/horizon-rust/horizon/commit/8a26f90c6673f6bae498e0347a182173335c864d) Test the sulfur cube's lead and its rope height - [`fc147cc`](https://github.com/horizon-rust/horizon/commit/fc147cc62da297167d3b7a0cd42328f5ef7d0b28) Drop a needless return in the leash test - [`6727ba9`](https://github.com/horizon-rust/horizon/commit/6727ba939e72b6970473d7fdf7025e7039adea77) Bind the test world result instead of naming an unused variable ### 📊 Changes **2 files changed** (+44 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/leash.rs` (+42 -0) 📝 `tools/port_map/game2-003.tsv` (+2 -1) </details> ### 📄 Description **Behaviour:** a sulfur cube that has swallowed a block can be put on a lead, and the rope hangs at the middle of its box. A sulfur cube with nothing in it cannot, as before. Vanilla `javap -p -c -constants -cp /tmp/cj`: `net.minecraft.world.entity.monster.cubemob.SulfurCube.canBeLeashed()` overrides the `Enemy` rule: ``` 0: aload_0 1: invokevirtual #206 // Method hasBodyItem:()Z 4: ireturn ``` and `SulfurCube.hasBodyItem()`: ``` 0: aload_0 1: getstatic #363 // Field net/minecraft/world/entity/EquipmentSlot.BODY 4: invokevirtual #369 // Method getItemBySlot:(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack; 7: invokevirtual #373 // Method net/minecraft/world/item/ItemStack.isEmpty:()Z 10: ifne 17 13: iconst_1 / 14: goto 18 / 17: iconst_0 / 18: ireturn ``` The rule it replaces, `net.minecraft.world.entity.Mob.canBeLeashed()`: ``` 0: aload_0 1: instanceof #1671 // class net/minecraft/world/entity/monster/Enemy 4: ifne 11 7: iconst_1 / 8: goto 12 / 11: iconst_0 / 12: ireturn ``` `net.minecraft.world.entity.monster.cubemob.SulfurCube.getLeashOffset()`: ``` 0: new Vec3 4: dconst_0 // x 5: aload_0 6: invokevirtual getBbHeight:()F 9: fconst_2 / 10: fdiv // y = getBbHeight() / 2 12: dconst_0 // z 16: areturn ``` **What Horizon got wrong:** `mobs/leash.rs::can_be_leashed` has no sulfur cube arm, so a cube fell through to `!m.hostile() && !m.removed`. Its category is `monster`, so every sulfur cube was refused a lead even while it carried a block — `SulfurCube.canBeLeashed` never reaches the `Enemy` rule at all, it asks `hasBodyItem`. `leash_offset` fell through to the default `[0, eye height, bbWidth * 0.4]` (0.175 and 0.196 for a cube's 0.49 box) instead of the cube's own `(0, bbHeight / 2, 0)` = (0, 0.245, 0). **Test:** `mobs::leash::tests::a_sulfur_cube_is_leashed_by_its_block_and_hangs_at_its_middle` builds a sulfur cube with and without a block in `extra.head` (the swallowed block) and checks `can_be_leashed` and `leash_offset`. Failing without the fix, the same test. The rope first: ``` thread '...a_sulfur_cube_is_leashed_by_its_block_and_hangs_at_its_middle' panicked at ...leash.rs:861: half the box height: 0.17499999701976776 vs 0.24500000476837158 ``` — the eye height 0.175 instead of the cube's half box 0.245 (and the z, unchecked at that point, is 0.196 in front instead of 0). With the offset fixed but the leashing rule left out, the next assertion is `a cube holding a block`: `can_be_leashed` is false where vanilla's `hasBodyItem` makes it true. **Proven:** the bytecode above; `hasBodyItem` is the BODY slot, which Horizon already models as the swallowed block (`sulfur_cube::has_body`, `extra.head`), and the lead path reaches it for any mob (`game/leads.rs::can_attach_lead` → `leash::can_be_leashed`). **Not proven:** no in-game run — that a leashed cube's rope follows it while it rolls is inferred from `game/leads.rs` using `leash_offset` for the rope, not watched. A cube's `hasBodyItem` is the BODY slot; Horizon models the swallowed block as `extra.head`, which is what `has_body` reads, and no test covers a cube that swallowed a block and then had it sheared out. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7700
No description provided.