[PR #3991] [MERGED] Darkness dims the screen on servers and in single player #5340

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

📋 Pull Request Information

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

Base: main ← Head: fix-3393-darkness


📝 Commits (1)

  • 945ad05 Darkness dims the screen on servers and in single player

📊 Changes

3 files changed (+112 additions, -23 deletions)

View changed files

📝 crates/horizon-client/src/game/potions.rs (+64 -5)
📝 crates/horizon-client/src/game/remote.rs (+8 -1)
📝 crates/horizon-client/src/game/sculk.rs (+40 -17)

📄 Description

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

What and why

Part of #3393 (the "Darkness effect does not work" item).

/effect give @s minecraft:darkness (or a warden's or shrieker's darkness) did nothing on a server or in default single player: the effect showed in the inventory, but the screen never dimmed, pulsed or fogged.

Root cause: the darkness blend factor (MobEffectInstance.BlendState), which darkness_lighting (the lightmap) and darkness_fog read, was only ticked by tick_darkness_blend. Its only caller is tick_sculk_entities, which runs inside the integrated level's tick_world. A server's client goes through tick_remote_level/tick_client_effects instead. That covers multiplayer and the default single player, whose server runs on a thread. So the factor stayed at 0, and with it the effect.

Fix:

  • tick_client_effects now ticks the darkness blend after counting the effects down, as MobEffectInstance.tickClient does (tickDownDuration, downgradeToHiddenEffect, then blendState.tick). The blend step moved into a free function sculk::darkness_blend_tick (the same 22-tick fade as before). The integrated level's tick_sculk_entities uses it too, unchanged.
  • A new darkness from ClientboundUpdateMobEffectPacket starts its fade from nothing. When the server sent it without the blend flag (8), it starts at full strength at once (MobEffectInstance.skipBlending → BlendState.setImmediate): that happens on join and on a dimension change, through PlayerList.sendActivePlayerEffects. An update to an existing darkness keeps its fade (LivingEntity.forceAddEffect's copyBlendState).

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

Checked with javap against the 26.3 client jar:

  • MobEffectInstance.tickClient: count down, downgrade, then blendState.tick(this). tickServer doesn't touch the blend.
  • MobEffectInstance$BlendState.tick / hasEffect (!endsWithin(getBlendOutAdvanceTicks())) / setImmediate.
  • MobEffects.DARKNESS: setBlendDuration(22) (in, out and advance are all 22).
  • ClientPacketListener.handleUpdateMobEffect: shouldBlend() (flag 8) or else skipBlending(), then LivingEntity.forceAddEffect (copyBlendState from the old instance).

Tests: game::potions::tests::a_servers_client_blends_the_darkness_effect (fades in over 22 ticks, holds, fades out over the last 22) and a_new_darkness_starts_blended_or_at_once. tools/test_sculk_parity.py still covers the integrated path's darkness: 435/435 scenarios match on every tick.

Self-check

tools/pr_ready.py doesn't run on Windows, so I ran its steps by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client --bin horizon-client -- game::potions::tests game::sculk::tests:
    test game::potions::tests::a_servers_client_blends_the_darkness_effect ... ok
    test game::potions::tests::a_new_darkness_starts_blended_or_at_once ... ok
    test result: ok. 4 passed; 0 failed
    
  • The fix reverted (client blend tick dropped, new darkness always from 0) with the tests kept:
    test game::potions::tests::a_servers_client_blends_the_darkness_effect ... FAILED
    test game::potions::tests::a_new_darkness_starts_blended_or_at_once ... FAILED
    test result: FAILED. 2 passed; 2 failed
    
  • python tools/test_sculk_parity.py: 435/435 scenarios match on every tick
  • In game (cargo build --profile fast, default single player with the server on a thread; /effect give @s minecraft:darkness 120; horizon-ctl sculk reports the client's blend):
    • Before: effect active (duration 2328), "darkness":0.0 throughout, no change on screen.
    • After: the factor rises 0.09, 0.14, 0.27, 0.36, 0.45, 0.55… (steps of 1/22) to 1.0, and the screen darkens and pulses.
    • LAN guest (second game over lan open): /effect give Guest minecraft:darkness 120 on the host fades the guest's darkness in to 1.0. The guest's screen goes dark. After the guest disconnects and reconnects, the unblended resend puts it straight at 1.0.

Screenshots

before: Darkness applied, the screen stays fully bright

after: the sky and the distance go black

Default single player at noon with Darkness applied. Before: the scene is fully bright, as if there were no effect. After: the sky and the distance go black, terrain darkens, and it pulses as in vanilla.

🤖 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/3991 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3393-darkness` --- ### 📝 Commits (1) - [`945ad05`](https://github.com/horizon-rust/horizon/commit/945ad05579775b7c0f1751c013921ac750925cc7) Darkness dims the screen on servers and in single player ### 📊 Changes **3 files changed** (+112 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/potions.rs` (+64 -5) 📝 `crates/horizon-client/src/game/remote.rs` (+8 -1) 📝 `crates/horizon-client/src/game/sculk.rs` (+40 -17) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Part of #3393 (the "Darkness effect does not work" item). `/effect give @s minecraft:darkness` (or a warden's or shrieker's darkness) did nothing on a server or in default single player: the effect showed in the inventory, but the screen never dimmed, pulsed or fogged. **Root cause:** the darkness blend factor (`MobEffectInstance.BlendState`), which `darkness_lighting` (the lightmap) and `darkness_fog` read, was only ticked by `tick_darkness_blend`. Its only caller is `tick_sculk_entities`, which runs inside the integrated level's `tick_world`. A server's client goes through `tick_remote_level`/`tick_client_effects` instead. That covers multiplayer and the default single player, whose server runs on a thread. So the factor stayed at 0, and with it the effect. **Fix:** - `tick_client_effects` now ticks the darkness blend after counting the effects down, as `MobEffectInstance.tickClient` does (`tickDownDuration`, `downgradeToHiddenEffect`, then `blendState.tick`). The blend step moved into a free function `sculk::darkness_blend_tick` (the same 22-tick fade as before). The integrated level's `tick_sculk_entities` uses it too, unchanged. - A new darkness from `ClientboundUpdateMobEffectPacket` starts its fade from nothing. When the server sent it without the blend flag (8), it starts at full strength at once (`MobEffectInstance.skipBlending` → `BlendState.setImmediate`): that happens on join and on a dimension change, through `PlayerList.sendActivePlayerEffects`. An update to an existing darkness keeps its fade (`LivingEntity.forceAddEffect`'s `copyBlendState`). ## 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 Checked with javap against the 26.3 client jar: - `MobEffectInstance.tickClient`: count down, downgrade, then `blendState.tick(this)`. `tickServer` doesn't touch the blend. - `MobEffectInstance$BlendState.tick` / `hasEffect` (`!endsWithin(getBlendOutAdvanceTicks())`) / `setImmediate`. - `MobEffects.DARKNESS`: `setBlendDuration(22)` (in, out and advance are all 22). - `ClientPacketListener.handleUpdateMobEffect`: `shouldBlend()` (flag 8) or else `skipBlending()`, then `LivingEntity.forceAddEffect` (`copyBlendState` from the old instance). Tests: `game::potions::tests::a_servers_client_blends_the_darkness_effect` (fades in over 22 ticks, holds, fades out over the last 22) and `a_new_darkness_starts_blended_or_at_once`. `tools/test_sculk_parity.py` still covers the integrated path's darkness: 435/435 scenarios match on every tick. ## Self-check `tools/pr_ready.py` doesn't run on Windows, so I ran its steps by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client --bin horizon-client -- game::potions::tests game::sculk::tests`: ``` test game::potions::tests::a_servers_client_blends_the_darkness_effect ... ok test game::potions::tests::a_new_darkness_starts_blended_or_at_once ... ok test result: ok. 4 passed; 0 failed ``` - The fix reverted (client blend tick dropped, new darkness always from 0) with the tests kept: ``` test game::potions::tests::a_servers_client_blends_the_darkness_effect ... FAILED test game::potions::tests::a_new_darkness_starts_blended_or_at_once ... FAILED test result: FAILED. 2 passed; 2 failed ``` - `python tools/test_sculk_parity.py`: 435/435 scenarios match on every tick - In game (`cargo build --profile fast`, default single player with the server on a thread; `/effect give @s minecraft:darkness 120`; `horizon-ctl sculk` reports the client's blend): - Before: effect active (duration 2328), `"darkness":0.0` throughout, no change on screen. - After: the factor rises 0.09, 0.14, 0.27, 0.36, 0.45, 0.55… (steps of 1/22) to 1.0, and the screen darkens and pulses. - LAN guest (second game over `lan open`): `/effect give Guest minecraft:darkness 120` on the host fades the guest's darkness in to 1.0. The guest's screen goes dark. After the guest disconnects and reconnects, the unblended resend puts it straight at 1.0. ## Screenshots ![before: Darkness applied, the screen stays fully bright](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3393-darkness-1.png) ![after: the sky and the distance go black](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3393-darkness-2.png) Default single player at noon with Darkness applied. Before: the scene is fully bright, as if there were no effect. After: the sky and the distance go black, terrain darkens, and it pulses as in vanilla. 🤖 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:11:55 +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#5340
No description provided.