
Redstonecompiler
JIT-compiles redstone circuits to bytecode for faster large machines.
Список изменений
Critical Bug Fixes (3)
Bug 1 — Output power discarded
CircuitManager.applyOutput() called updateNeighborsAlways() without actually setting the redstone signal strength. The power value computed by the compiled circuit was silently dropped.
Fix: replaced with
world.setBlockState(pos, state.with(POWER, clamped), 2)— actually writes the signal value.
Bug 2 — Input captured stale value
RedstoneWireMixin injected at HEAD and called ci.cancel(), but state.get(POWER) returned the pre-update value. Vanilla's recalculation never had a chance to run.
Fix: added
@Invoker("getReceivedRedstonePower")to directly call the vanilla private method for the correct input signal strength.
Bug 3 — Self-triggered infinite loop
applyOutput → setBlockState → triggered neighborUpdate → Mixin intercepted again → called onInputChanged…infinite recursion.
Fix: added
ThreadLocal<Boolean> APPLYING_OUTPUTSre-entrancy guard, checked in all 3 Mixins (RedstoneWireMixin, BlockChangeMixin).
Mixin Strategy Optimization
- Before: intercepted ALL circuit wire
neighborUpdatecalls, cancelled everything → signals couldn't propagate correctly - After: only intercepts INPUT nodes (wires receiving external signals); non-input nodes pass through to vanilla logic normally
Other Improvements
executedThisTickdeduplication: same circuit won't execute twice in the same tickBlockChangeMixin: addedisApplyingOutputs()guard to prevent self-invalidation during output application
