[PR #2941] [MERGED] entity_model: make the bat's animation states accessible before setting them #4697

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2941
Author: @ASOwnerYT
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: tools/bat-oracle-final-fields


📝 Commits (1)

  • deea1a5 entity_model: make the bat's animation states accessible before setting them

📊 Changes

1 file changed (+6 additions, -2 deletions)

View changed files

📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityAnimOracle.java (+6 -2)

📄 Description

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

What and why

entity_model failed on every JDK with an oracle error:

minecraft:bat#main java.lang.IllegalAccessException: Can not set final net.minecraft.world.entity.AnimationState field net.minecraft.world.entity.ambient.Bat.flyAnimationState to net.minecraft.world.entity.AnimationState

VanillaEntityAnimOracle.batHistory (added in 15d99a685) allocates the bat with Unsafe.allocateInstance, then fills flyAnimationState and restAnimationState through type.getField(name).set(...). Both are final, and Field.set refuses a final field unless setAccessible(true) was called on it first. Now the oracle takes each field with getDeclaredField, makes it accessible, then sets it.

The Rust side already matched: the failing run reported 0 layers differing from vanilla over 5858 cases. Only the oracle's bat case threw.

Vanilla reference

none (harness oracle). The oracle runs net.minecraft.world.entity.ambient.Bat#setupAnimationStates on the bat it builds; that part is unchanged.

python3 tools/parity.py --fresh entity_model: failed before this change on JDK 25.0.5 and 27.0.1. With it, it passes on both (169 s on JDK 25).

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on cachyos, against upstream/main at f21e09510, 20 s)

Check Result
Scope ✅ 1 files, +6 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 398 passed (20 s)
rustfmt ➖ no Rust change
clippy ➖ no Rust change
tests ➖ no crate touched
doc tests ➖ no crate touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ✅ 2 affected, all passed already with these inputs (1 s)
Label skip-release

🤖 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/2941 **Author:** [@ASOwnerYT](https://github.com/ASOwnerYT) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `tools/bat-oracle-final-fields` --- ### 📝 Commits (1) - [`deea1a5`](https://github.com/horizon-rust/horizon/commit/deea1a5b839378db74e09a7f4a5430c12f0e2e71) entity_model: make the bat's animation states accessible before setting them ### 📊 Changes **1 file changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityAnimOracle.java` (+6 -2) </details> ### 📄 Description > 🤖 Opened by asowneryt's AI agent (Claude Code), not by asowneryt himself. ## What and why `entity_model` failed on every JDK with an oracle error: ``` minecraft:bat#main java.lang.IllegalAccessException: Can not set final net.minecraft.world.entity.AnimationState field net.minecraft.world.entity.ambient.Bat.flyAnimationState to net.minecraft.world.entity.AnimationState ``` `VanillaEntityAnimOracle.batHistory` (added in 15d99a685) allocates the bat with `Unsafe.allocateInstance`, then fills `flyAnimationState` and `restAnimationState` through `type.getField(name).set(...)`. Both are `final`, and `Field.set` refuses a final field unless `setAccessible(true)` was called on it first. Now the oracle takes each field with `getDeclaredField`, makes it accessible, then sets it. The Rust side already matched: the failing run reported 0 layers differing from vanilla over 5858 cases. Only the oracle's bat case threw. ## Vanilla reference none (harness oracle). The oracle runs `net.minecraft.world.entity.ambient.Bat#setupAnimationStates` on the bat it builds; that part is unchanged. `python3 tools/parity.py --fresh entity_model`: failed before this change on JDK 25.0.5 and 27.0.1. With it, it passes on both (169 s on JDK 25). ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on cachyos, against upstream/main at f21e09510, 20 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +6 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 398 passed (20 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ✅ 2 affected, all passed already with these inputs (1 s) | | Label | `skip-release` | 🤖 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:07:16 +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#4697
No description provided.