[PR #857] [MERGED] Server: send entity attributes to clients #2861

Closed
opened 2026-11-02 15:59:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/857
Author: @ludovic111
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/18/2026
Merged by: @ludovic111

Base: main ← Head: feat/server-entity-attributes


📝 Commits (1)

  • bfa622b Server: send entity attributes to clients

📊 Changes

20 files changed (+754 additions, -122 deletions)

View changed files

📝 crates/horizon-client/examples/lan_flat.rs (+1 -0)
📝 crates/horizon-client/src/effects.rs (+72 -67)
📝 crates/horizon-client/src/entity_nbt.rs (+5 -2)
📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/lan.rs (+5 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+1 -0)
➕ crates/horizon-client/src/game/lan_attributes.rs (+274 -0)
📝 crates/horizon-client/src/game/lan_entities.rs (+2 -0)
➕ crates/horizon-client/src/lan/attributes.rs (+143 -0)
📝 crates/horizon-client/src/lan/entity.rs (+95 -18)
📝 crates/horizon-client/src/lan/hub.rs (+22 -0)
📝 crates/horizon-client/src/lan/mod.rs (+1 -0)
📝 crates/horizon-client/src/mobs/cube.rs (+15 -5)
📝 crates/horizon-client/src/mobs/finalize.rs (+2 -14)
📝 crates/horizon-client/tests/lan_bot.rs (+2 -0)
📝 crates/horizon-protocol/src/packets/play.rs (+58 -0)
📝 crates/horizon-world/src/attributes/entity.rs (+9 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/EntityTranscript.java (+18 -1)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaProtocolClient.java (+1 -1)
📝 tools/test_server_entities_parity.py (+27 -14)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Server hosting, step 2: the server now sends entity attributes (ClientboundUpdateAttributesPacket) for players and mobs, the way vanilla's ServerEntity does. Before this, a vanilla client on a Horizon server never received any attributes. Its reach in creative stayed at the survival values, and other players' and mobs' scale and speed never reached it.

What changes

  • Protocol. UpdateAttributes, AttributeSnapshot and AttributeModifier follow vanilla's stream codecs. A test checks the bytes against vanilla's encoding.

  • Tracker (lan/entity.rs). EntityState now carries the entity's client-syncable attribute instances.

    • Pairing sends all of them (getSyncableAttributes).
    • sendDirtyEntityData sends the ones that changed, after the entity data, to every client that tracks the entity.
  • Players (lan/attributes.rs, hub).

    • Other players get the instances in the player's LiveAttributes.
    • The player itself gets its dirty set (getAttributesToSync) every tick, which is then cleared.
    • Guests now run vanilla's per-tick player work: the tick creates the movement speed instance (removeFrost), and ServerPlayer.updatePlayerAttributes adds the creative block and entity reach modifiers.
  • Mobs and armor stands (game/lan_attributes.rs). These are the instances vanilla would have created by then:

    • movement speed, created by the first aiStep;
    • the bases and permanent modifiers set by finalizeSpawn;
    • the baby speed modifier;
    • effects' modifiers, from the same table the player uses (now effects::effect_modifier);
    • equipment modifiers, by EquipmentSlotGroup;
    • whatever /attribute changed in the generic map.

    Only attributes the type's supplier has are included (getInstance is null for the others).

  • Slimes and magma cubes. cube::set_size now sets the attribute bases, as AbstractCubeMob.setSize does: max health, speed (computed in floats, 0.2F + 0.1F * size), attack damage, and a magma cube's armor. Before, it wrote the cached fields only, so a summoned {Size:1} slime had a health of 1. On load, the saved health still wins, and a slime saved without one gets its max health. finalizeSpawn's cube_size now calls the same function.

Harness

server_entities compares attributes again, for every entity in the scene plus the player's own instances. Its scene gains:

  • a {Size:1} slime;
  • a pig whose scale /attribute sets.

EntityTranscript records what the player itself is sent from its login on. The amounts of vanilla's random spawn modifiers are normalised before comparing, as the brief asks. Only client-syncable attributes are ever sent, though, so follow range and knockback resistance (the usual random ones) never show.

Checks (Mac mini, rebased on e508a5ce)

  • server_entities: 28 entities identical, attributes and the player's own included. Before this PR, the armor stands, the chicken and the baby husk all differed on attributes.
  • Unchanged and still passing:
    • dedicated_server: 595 lines identical.
    • lan: 462 cases match.
    • server_dimension_players: 22 lines.
    • server_ops_feedback: 17 lines.
    • server_player_combat and server_player_damage: pass.
    • finalize_spawn: 24,000 cases.
    • mob_attributes: pass.
    • spawner: 6,000 cases.
  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-protocol -p horizon-client: lib tests 869 passed.
    • streaming_meshes::relit_columns_keep_every_mesh_current fails, and it fails on plain main (e508a5ce) on this machine too. It's unrelated (streaming light); see #856.
  • CI parity covers the rest.

Not covered

  • Vanilla clients draw no effect particles for mobs: DATA_EFFECT_PARTICLES and DATA_EFFECT_AMBIENCE_ID aren't sent. Because of this, the harness scene has no mob with an effect.
  • Main-hand attack modifiers (sword attack speed) aren't applied to players' LiveAttributes, so they aren't synced either. This is cosmetic: the client's attack indicator.

Needs Ludovic: nothing.

🤖 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/857 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/server-entity-attributes` --- ### 📝 Commits (1) - [`bfa622b`](https://github.com/horizon-rust/horizon/commit/bfa622bbdec711618b8516a1d7dbe164265b471a) Server: send entity attributes to clients ### 📊 Changes **20 files changed** (+754 additions, -122 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/lan_flat.rs` (+1 -0) 📝 `crates/horizon-client/src/effects.rs` (+72 -67) 📝 `crates/horizon-client/src/entity_nbt.rs` (+5 -2) 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+5 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+1 -0) ➕ `crates/horizon-client/src/game/lan_attributes.rs` (+274 -0) 📝 `crates/horizon-client/src/game/lan_entities.rs` (+2 -0) ➕ `crates/horizon-client/src/lan/attributes.rs` (+143 -0) 📝 `crates/horizon-client/src/lan/entity.rs` (+95 -18) 📝 `crates/horizon-client/src/lan/hub.rs` (+22 -0) 📝 `crates/horizon-client/src/lan/mod.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/cube.rs` (+15 -5) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+2 -14) 📝 `crates/horizon-client/tests/lan_bot.rs` (+2 -0) 📝 `crates/horizon-protocol/src/packets/play.rs` (+58 -0) 📝 `crates/horizon-world/src/attributes/entity.rs` (+9 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/EntityTranscript.java` (+18 -1) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaProtocolClient.java` (+1 -1) 📝 `tools/test_server_entities_parity.py` (+27 -14) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Server hosting, step 2: the server now sends entity attributes (`ClientboundUpdateAttributesPacket`) for players and mobs, the way vanilla's `ServerEntity` does. Before this, a vanilla client on a Horizon server never received any attributes. Its reach in creative stayed at the survival values, and other players' and mobs' scale and speed never reached it. ## What changes - **Protocol.** `UpdateAttributes`, `AttributeSnapshot` and `AttributeModifier` follow vanilla's stream codecs. A test checks the bytes against vanilla's encoding. - **Tracker** (`lan/entity.rs`). `EntityState` now carries the entity's client-syncable attribute instances. - Pairing sends all of them (`getSyncableAttributes`). - `sendDirtyEntityData` sends the ones that changed, after the entity data, to every client that tracks the entity. - **Players** (`lan/attributes.rs`, hub). - Other players get the instances in the player's `LiveAttributes`. - The player itself gets its dirty set (`getAttributesToSync`) every tick, which is then cleared. - Guests now run vanilla's per-tick player work: the tick creates the movement speed instance (`removeFrost`), and `ServerPlayer.updatePlayerAttributes` adds the creative block and entity reach modifiers. - **Mobs and armor stands** (`game/lan_attributes.rs`). These are the instances vanilla would have created by then: - movement speed, created by the first `aiStep`; - the bases and permanent modifiers set by finalizeSpawn; - the baby speed modifier; - effects' modifiers, from the same table the player uses (now `effects::effect_modifier`); - equipment modifiers, by `EquipmentSlotGroup`; - whatever `/attribute` changed in the generic map. Only attributes the type's supplier has are included (`getInstance` is null for the others). - **Slimes and magma cubes.** `cube::set_size` now sets the attribute bases, as `AbstractCubeMob.setSize` does: max health, speed (computed in floats, `0.2F + 0.1F * size`), attack damage, and a magma cube's armor. Before, it wrote the cached fields only, so a summoned `{Size:1}` slime had a health of 1. On load, the saved health still wins, and a slime saved without one gets its max health. finalizeSpawn's `cube_size` now calls the same function. ## Harness `server_entities` compares attributes again, for every entity in the scene plus the player's own instances. Its scene gains: - a `{Size:1}` slime; - a pig whose scale `/attribute` sets. `EntityTranscript` records what the player itself is sent from its login on. The amounts of vanilla's random spawn modifiers are normalised before comparing, as the brief asks. Only client-syncable attributes are ever sent, though, so follow range and knockback resistance (the usual random ones) never show. ## Checks (Mac mini, rebased on e508a5ce) - `server_entities`: 28 entities identical, attributes and the player's own included. Before this PR, the armor stands, the chicken and the baby husk all differed on attributes. - Unchanged and still passing: - `dedicated_server`: 595 lines identical. - `lan`: 462 cases match. - `server_dimension_players`: 22 lines. - `server_ops_feedback`: 17 lines. - `server_player_combat` and `server_player_damage`: pass. - `finalize_spawn`: 24,000 cases. - `mob_attributes`: pass. - `spawner`: 6,000 cases. - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-protocol -p horizon-client`: lib tests 869 passed. - `streaming_meshes::relit_columns_keep_every_mesh_current` fails, and it fails on plain `main` (e508a5ce) on this machine too. It's unrelated (streaming light); see #856. - CI parity covers the rest. ## Not covered - Vanilla clients draw no effect particles for mobs: `DATA_EFFECT_PARTICLES` and `DATA_EFFECT_AMBIENCE_ID` aren't sent. Because of this, the harness scene has no mob with an effect. - Main-hand attack modifiers (sword attack speed) aren't applied to players' `LiveAttributes`, so they aren't synced either. This is cosmetic: the client's attack indicator. Needs Ludovic: nothing. 🤖 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-02 15:59:40 +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#2861
No description provided.