[PR #4019] [MERGED] Pose plugins hide the player's own body again #5361

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

📋 Pull Request Information

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

Base: main ← Head: fix-3788


📝 Commits (1)

  • dff6db1 Hide the own body when the server sets the player's invisible flag

📊 Changes

5 files changed (+61 additions, -18 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+2 -2)
📝 crates/horizon-client/src/game/client_ambient.rs (+1 -1)
📝 crates/horizon-client/src/game/names.rs (+1 -1)
📝 crates/horizon-client/src/game/perspective.rs (+41 -14)
📝 crates/horizon-client/src/game/remote.rs (+16 -0)

📄 Description

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

What and why

On servers with pose plugins (GSit's /lay, /crawl, /spin), the player saw their own real body standing or sitting under the pose in third person.

Cause. A pose plugin hides the real player with Player.setInvisible(true). That sets only the shared flag 0x20 (Entity.isInvisible) and gives no Invisibility effect. SetEntityData read flag 0x20 into Mob::invisible for other entities only. For the player's own entity it read just the sprinting bit. Everything that hides the player's own body checked only the minecraft:invisibility effect: the body (body_visible), the cape, the empty first-person arm, the arms under a held map, Horizon's own name tag and the rate of the own effect swirls (LivingEntity.tickEffects). So the flag the server set never reached any of them.

Fix:

  • Remote::own_invisible stores the own entity's invisible bit from SetEntityData.
  • The bit resets on Login and on a Respawn without KEEP_ENTITY_DATA, because vanilla's new LocalPlayer starts with default synched data in both cases.
  • A new Game::own_invisible() is Entity.isInvisible for the own player: the shared flag, or the effect. The effect stays as a fallback for the deprecated in-frame world, which has no server-sent flag. On a vanilla server the effect always sets the flag anyway (LivingEntity.updateInvisibilityStatus).
  • The body, the cape, the first-person arm and map arms, the own name tag and the own effect swirls (one in fifteen ticks while invisible) now ask own_invisible().
  • The team rule is unchanged: a team that sees friendly invisibles still sees the body translucent.

The issue's comment about not being able to move while crawling is a separate question and is not changed here.

Fixes #3788

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 jars:

  • Entity.isInvisible() is getSharedFlag(5). On the client this is only the synched flag; the client never recomputes it from effects. LivingEntity.updateInvisibilityStatus runs only on the server (from updateDataBeforeSync).
  • EntityRenderer/LivingEntityRenderer.extractRenderState fills isInvisible and isInvisibleToPlayer (LivingEntity.isInvisibleTo). LivingEntityRenderer.isBodyVisible returns !state.isInvisible.
  • CapeLayer checks AvatarRenderState.isInvisible.
  • LivingEntity.tickEffects thins the effect swirls with isInvisible() (nextInt(15) instead of nextInt(4)).
  • ClientPacketListener.handleRespawn copies the old player's getNonDefaultValues() only when shouldKeep(KEEP_ENTITY_DATA = 2).
  • Checked by the new unit test game::perspective::preview_tests::the_servers_invisible_flag_hides_the_own_body_without_the_effect, and in game against a vanilla 26.3 dedicated server (below). No parity harness covers own-entity render state.

Self-check

tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand. CARGO_TARGET_DIR was a private folder.

  • cargo fmt --all -- --check: clean.
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean.
  • cargo build --profile fast -p horizon-client --bins: ok.
  • cargo test --profile fast -p horizon-client --bin horizon-client -- game::perspective:: game::names:: game::remote:: game::client_ambient::: 13 passed, 0 failed, 1 ignored (it needs HORIZON_TEST_RESOURCES).
  • Before the fix: I put main's logic back in own_invisible (effect only, flag ignored) and kept the test. the_servers_invisible_flag_hides_the_own_body_without_the_effect then FAILED (panicked at perspective.rs:973), while an_invisible_player_hides_its_own_body still passed. With the fix, both pass.
  • In game, I used a vanilla 26.3 dedicated server (offline mode). It sat behind a small local proxy that sends the joined player an extra SetEntityData with only shared flag 0x20 set, the same packet a plugin's Player.setInvisible(true) produces. I connected a Horizon build to it and switched to third person:
    • main: with the flag set, horizon-ctl status still reported "own_body": true and the screenshot showed the full body.
    • this branch: with the flag set, "own_body": false and the body is gone. After clearing the flag it is true again and the body is back.
    • Effect path: effect give Guest minecraft:invisibility from the server console gives false, and effect clear gives true.
  • Single player on the server thread: /effect give @s invisibility hides the body (own_body false) and /effect clear @s shows it again, as before.

Screenshots

before: the server set the player's invisible flag, yet third person still draws the body

after: the body is hidden, as in vanilla

Third person on a vanilla 26.3 server, after the server sets only the player's invisible flag (no effect), as a pose plugin does:

  • Before: the player's full body still stands in front of the camera.
  • After: no body is drawn. Clearing the flag brings it back.

🤖 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/4019 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3788` --- ### 📝 Commits (1) - [`dff6db1`](https://github.com/horizon-rust/horizon/commit/dff6db1e86634368a87806e16343158f7b64c124) Hide the own body when the server sets the player's invisible flag ### 📊 Changes **5 files changed** (+61 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+2 -2) 📝 `crates/horizon-client/src/game/client_ambient.rs` (+1 -1) 📝 `crates/horizon-client/src/game/names.rs` (+1 -1) 📝 `crates/horizon-client/src/game/perspective.rs` (+41 -14) 📝 `crates/horizon-client/src/game/remote.rs` (+16 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why On servers with pose plugins (GSit's `/lay`, `/crawl`, `/spin`), the player saw their own real body standing or sitting under the pose in third person. **Cause.** A pose plugin hides the real player with `Player.setInvisible(true)`. That sets only the shared flag `0x20` (`Entity.isInvisible`) and gives no Invisibility effect. `SetEntityData` read flag `0x20` into `Mob::invisible` for other entities only. For the player's own entity it read just the sprinting bit. Everything that hides the player's own body checked only the `minecraft:invisibility` effect: the body (`body_visible`), the cape, the empty first-person arm, the arms under a held map, Horizon's own name tag and the rate of the own effect swirls (`LivingEntity.tickEffects`). So the flag the server set never reached any of them. **Fix:** - `Remote::own_invisible` stores the own entity's invisible bit from `SetEntityData`. - The bit resets on `Login` and on a `Respawn` without `KEEP_ENTITY_DATA`, because vanilla's new `LocalPlayer` starts with default synched data in both cases. - A new `Game::own_invisible()` is `Entity.isInvisible` for the own player: the shared flag, or the effect. The effect stays as a fallback for the deprecated in-frame world, which has no server-sent flag. On a vanilla server the effect always sets the flag anyway (`LivingEntity.updateInvisibilityStatus`). - The body, the cape, the first-person arm and map arms, the own name tag and the own effect swirls (one in fifteen ticks while invisible) now ask `own_invisible()`. - The team rule is unchanged: a team that sees friendly invisibles still sees the body translucent. The issue's comment about not being able to move while crawling is a separate question and is not changed here. Fixes #3788 ## 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 jars: - `Entity.isInvisible()` is `getSharedFlag(5)`. On the client this is only the synched flag; the client never recomputes it from effects. `LivingEntity.updateInvisibilityStatus` runs only on the server (from `updateDataBeforeSync`). - `EntityRenderer`/`LivingEntityRenderer.extractRenderState` fills `isInvisible` and `isInvisibleToPlayer` (`LivingEntity.isInvisibleTo`). `LivingEntityRenderer.isBodyVisible` returns `!state.isInvisible`. - `CapeLayer` checks `AvatarRenderState.isInvisible`. - `LivingEntity.tickEffects` thins the effect swirls with `isInvisible()` (`nextInt(15)` instead of `nextInt(4)`). - `ClientPacketListener.handleRespawn` copies the old player's `getNonDefaultValues()` only when `shouldKeep(KEEP_ENTITY_DATA = 2)`. - Checked by the new unit test `game::perspective::preview_tests::the_servers_invisible_flag_hides_the_own_body_without_the_effect`, and in game against a vanilla 26.3 dedicated server (below). No parity harness covers own-entity render state. ## Self-check `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand. `CARGO_TARGET_DIR` was a private folder. - `cargo fmt --all -- --check`: clean. - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean. - `cargo build --profile fast -p horizon-client --bins`: ok. - `cargo test --profile fast -p horizon-client --bin horizon-client -- game::perspective:: game::names:: game::remote:: game::client_ambient::`: 13 passed, 0 failed, 1 ignored (it needs `HORIZON_TEST_RESOURCES`). - Before the fix: I put main's logic back in `own_invisible` (effect only, flag ignored) and kept the test. `the_servers_invisible_flag_hides_the_own_body_without_the_effect` then FAILED (panicked at `perspective.rs:973`), while `an_invisible_player_hides_its_own_body` still passed. With the fix, both pass. - In game, I used a vanilla 26.3 dedicated server (offline mode). It sat behind a small local proxy that sends the joined player an extra `SetEntityData` with only shared flag `0x20` set, the same packet a plugin's `Player.setInvisible(true)` produces. I connected a Horizon build to it and switched to third person: - **main:** with the flag set, horizon-ctl `status` still reported `"own_body": true` and the screenshot showed the full body. - **this branch:** with the flag set, `"own_body": false` and the body is gone. After clearing the flag it is `true` again and the body is back. - **Effect path:** `effect give Guest minecraft:invisibility` from the server console gives `false`, and `effect clear` gives `true`. - Single player on the server thread: `/effect give @s invisibility` hides the body (`own_body` false) and `/effect clear @s` shows it again, as before. ## Screenshots ![before: the server set the player's invisible flag, yet third person still draws the body](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3788-1.png) ![after: the body is hidden, as in vanilla](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3788-2.png) Third person on a vanilla 26.3 server, after the server sets only the player's invisible flag (no effect), as a pose plugin does: - **Before:** the player's full body still stands in front of the camera. - **After:** no body is drawn. Clearing the flag brings it back. 🤖 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:03 +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#5361
No description provided.