[GH-ISSUE #6113] Sulfur cube holding a block: its knockback resistance is -1 in vanilla, Horizon clamps it to 0, so every hit pushes it half as far #1983

Open
opened 2026-11-02 15:51:06 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6113

Originally assigned to: @Joansitoh on GitHub.

🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally.

Seven of the twelve sulfur cube archetypes (bouncy and sticky -2.0; explosive, fast_flat, hot, light and regular -1.0) give a cube holding a block a negative knockback_resistance. Vanilla keeps it negative (the attribute's range is -2 to 1), so SulfurCube.knockback multiplies the push by 1 - resistance, 2 for -1 and 3 for -2. Horizon clamps the resistance to 0..1, so the push is multiplied by 1. A plain hit on an explosive or regular cube moves it half as fast as in vanilla.

What vanilla does

  • Attributes.KNOCKBACK_RESISTANCE is RangedAttribute(..., 0.0, -2.0, 1.0) (Attributes.java:61-63): default 0, minimum -2, maximum 1.
  • The archetypes add to it (add_value, data/minecraft/sulfur_cube_archetype/*.json): bouncy -2.0, sticky -2.0, explosive -1.0, fast_flat -1.0, hot -1.0, light -1.0, regular -1.0; fast_sliding 0.5, slow_flat 0.5, slow_bouncy 0.4, high_resistance 0.7, slow_sliding 0.8.
  • SulfurCube.knockback (SulfurCube.java:864-866): horizontalPower *= (float)(1.0 - knockBackResistance) and the same for verticalPower, with knockBackResistance = getAttributeValue(KNOCKBACK_RESISTANCE). With -1 that is x2.
  • SulfurCube.playerPush (SulfurCube.java:750): Math.max(0.0, 1.0 - getAttributeValue(KNOCKBACK_RESISTANCE)), also 2.

What Horizon does

  • crates/horizon-client/src/mobs/sulfur_cube.rs:35 says "the attribute clamps to 0..1". It does not for this attribute.
  • sulfur_cube.rs:720 (knockback) passes a.knockback_resistance.clamp(0.0, 1.0) to launch, and sulfur_cube.rs:845 (the player's push) does the same, so a resistance of -1 becomes 0.

How it was seen (183b53f0e, in WSL, tools/test_server_knockback_parity.py with temporary cases; vanilla 26.3 dedicated server against horizon-client --dedicated --nogui)

A cube with equipment:{body:{id:"minecraft:tnt",count:1}} (the explosive archetype):

  • /attribute @e[type=minecraft:sulfur_cube,limit=1] minecraft:knockback_resistance get: vanilla says -1.0, Horizon says 0.0. The base value is 0.0 on both.
  • A plain hit from Alice (creative, wooden sword, game frozen, cube slowed to a stop): the cube's Motion right after the hit is 0.66 0.06616 0 in vanilla and 0.33 -0.00752 0 in Horizon. Exactly a factor of 2 in x.
  • By hand: horizontal power 0.4125 (archetype) * sqrt(4) (damage) * (1 - resistance) * 0.4. Resistance -1: 0.66 (vanilla's number). Resistance 0: 0.33 (Horizon's).

What is not known

  • The player's push (playerPush) was not run; it is by reading only.
  • Why Horizon's /attribute ... get shows 0.0: I did not look at where the command reads the value from. The two clamps above are enough to explain the harness numbers.
  • Only the explosive archetype (-1.0) was run. The other negative ones (-2.0 would give a factor of 3) are by reading only; the positive ones are not affected by the clamp.

Likely fix

Do not clamp the resistance to 0..1 in sulfur_cube.rs; use the attribute's range, -2 to 1. Since /attribute ... get also reads 0.0 in Horizon, the attribute's own value may be clamped somewhere else too; that needs checking along with the two clamps.

Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6113 Originally assigned to: @Joansitoh on GitHub. > 🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally. Seven of the twelve sulfur cube archetypes (bouncy and sticky -2.0; explosive, fast_flat, hot, light and regular -1.0) give a cube holding a block a negative `knockback_resistance`. Vanilla keeps it negative (the attribute's range is -2 to 1), so `SulfurCube.knockback` multiplies the push by `1 - resistance`, 2 for -1 and 3 for -2. Horizon clamps the resistance to 0..1, so the push is multiplied by 1. A plain hit on an explosive or regular cube moves it half as fast as in vanilla. **What vanilla does** - `Attributes.KNOCKBACK_RESISTANCE` is `RangedAttribute(..., 0.0, -2.0, 1.0)` (`Attributes.java:61-63`): default 0, minimum **-2**, maximum 1. - The archetypes add to it (`add_value`, `data/minecraft/sulfur_cube_archetype/*.json`): bouncy -2.0, sticky -2.0, explosive -1.0, fast_flat -1.0, hot -1.0, light -1.0, regular -1.0; fast_sliding 0.5, slow_flat 0.5, slow_bouncy 0.4, high_resistance 0.7, slow_sliding 0.8. - `SulfurCube.knockback` (`SulfurCube.java:864-866`): `horizontalPower *= (float)(1.0 - knockBackResistance)` and the same for `verticalPower`, with `knockBackResistance = getAttributeValue(KNOCKBACK_RESISTANCE)`. With -1 that is x2. - `SulfurCube.playerPush` (`SulfurCube.java:750`): `Math.max(0.0, 1.0 - getAttributeValue(KNOCKBACK_RESISTANCE))`, also 2. **What Horizon does** - `crates/horizon-client/src/mobs/sulfur_cube.rs:35` says "the attribute clamps to 0..1". It does not for this attribute. - `sulfur_cube.rs:720` (`knockback`) passes `a.knockback_resistance.clamp(0.0, 1.0)` to `launch`, and `sulfur_cube.rs:845` (the player's push) does the same, so a resistance of -1 becomes 0. **How it was seen** (`183b53f0e`, in WSL, `tools/test_server_knockback_parity.py` with temporary cases; vanilla 26.3 dedicated server against `horizon-client --dedicated --nogui`) A cube with `equipment:{body:{id:"minecraft:tnt",count:1}}` (the explosive archetype): - `/attribute @e[type=minecraft:sulfur_cube,limit=1] minecraft:knockback_resistance get`: vanilla says `-1.0`, Horizon says `0.0`. The base value is `0.0` on both. - A plain hit from Alice (creative, wooden sword, game frozen, cube slowed to a stop): the cube's `Motion` right after the hit is `0.66 0.06616 0` in vanilla and `0.33 -0.00752 0` in Horizon. Exactly a factor of 2 in x. - By hand: horizontal power 0.4125 (archetype) * sqrt(4) (damage) * (1 - resistance) * 0.4. Resistance -1: 0.66 (vanilla's number). Resistance 0: 0.33 (Horizon's). **What is not known** - The player's push (`playerPush`) was not run; it is by reading only. - Why Horizon's `/attribute ... get` shows 0.0: I did not look at where the command reads the value from. The two clamps above are enough to explain the harness numbers. - Only the explosive archetype (-1.0) was run. The other negative ones (-2.0 would give a factor of 3) are by reading only; the positive ones are not affected by the clamp. **Likely fix** Do not clamp the resistance to 0..1 in `sulfur_cube.rs`; use the attribute's range, -2 to 1. Since `/attribute ... get` also reads 0.0 in Horizon, the attribute's own value may be clamped somewhere else too; that needs checking along with the two clamps.
Author
Owner

@Joansitoh commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

Claimed by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally.

Cause: crates/horizon-client/src/mobs/sulfur_cube.rs clamps the knockback resistance to 0.0..=1.0 in knockback() (~line 720, passed to launch) and in the player push (~line 845), and the doc comment at ~line 35 says the same. Vanilla SulfurCube.knockback (~864-866) multiplies by (1 - resistance) with no clamp (the attribute range is -2..1), and playerPush (~750) uses Math.max(0, 1 - attr). The archetype table already holds the negative values (-1 / -2), so only the clamp is wrong.

Plan: clamp to -2.0..=1.0 at both sites (keeping .max(0.0) on the player push), fix the comment, add unit tests (explosive cube factor 0.66 instead of 0.33, bouncy r=-2). The /attribute ... knockback_resistance get display (0.0 instead of -1.0, finalize.rs / lan_attributes.rs) is a separate part, so the PR will say Part of #6113.

<!-- gh-comment-id:6561035377 --> @Joansitoh commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim Claimed by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. Cause: `crates/horizon-client/src/mobs/sulfur_cube.rs` clamps the knockback resistance to `0.0..=1.0` in `knockback()` (~line 720, passed to `launch`) and in the player push (~line 845), and the doc comment at ~line 35 says the same. Vanilla `SulfurCube.knockback` (~864-866) multiplies by `(1 - resistance)` with no clamp (the attribute range is -2..1), and `playerPush` (~750) uses `Math.max(0, 1 - attr)`. The archetype table already holds the negative values (-1 / -2), so only the clamp is wrong. Plan: clamp to `-2.0..=1.0` at both sites (keeping `.max(0.0)` on the player push), fix the comment, add unit tests (explosive cube factor 0.66 instead of 0.33, bouncy r=-2). The `/attribute ... knockback_resistance get` display (0.0 instead of -1.0, `finalize.rs` / `lan_attributes.rs`) is a separate part, so the PR will say `Part of #6113`.
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#1983
No description provided.