Skip to content

Conversation

@jchung01
Copy link
Contributor

This PR rewrites or changes the following things in this mod:

  • Redstone interface
  • Redstone observer
  • Redstone tool
  • Redstone activator
  • Redstone remote

All of these tiles/items now have their signals handled through a "dynamic" redstone manager; based on Integrated Dynamics' redstone writers' remote offset implementation (here). The manager is responsible for their remote redstone functionalities, and is implemented as a World capability.

Non-exhaustive list of notable changes:

  • The above tiles/items now handle their logic on server-side only; the client-side does not need any of the information beyond syncing. The old code had unnecessary synchronization and copying which was the major source of their non-optimal performance.
  • The Redstone Activator now sends a sided signal based on which face was clicked, instead of a signal from all sides.
  • Cleaned up how the Redstone Tool gathers connections from the interface and observer.
  • Improved performance of the hooks into World#getRedstonePower()/World#getStrongPower(), methods that are very frequently called by tile entities (See comments in AsmHandler for changes).
  • Rewrote internals of the Redstone Interface & Redstone Observer to use dynamic redstone. The way they work should be mostly unaffected.
  • The Redstone Interface's/Observer's target(s) now need to be loaded for them to send/receive the signals. If the target isn't loaded yet, a task will be scheduled to get their redstone state once loaded.
  • The Redstone activator/remote now has their signal data saved in the dynamic redstone manager's capability data (was previously handled by RedstoneSignalHandler as WorldSavedData).

Related issues from original repo that are probably fixed: 286, 493, 517.

- Use per-world capability for manager
- Change Redstone Activator to emit a signal based on the side clicked
- Fix deserialization for strong states
- Prevent new signal removals being added to manager
- All signals with the same target are stored with their unique source
- Signals are sorted in priority queue according to their strength
- Cache manager capability for tiles
- Pass block info to dynamic redstone
- Properly notify neighbors immediately upon any change
- Handle redstone remote message on main thread
-  Refactor signal removal to use subclass RemovalSignal
- Change SignalQueue to be sorted based on total strength (weak + strong)
- Skip dynamic redstone checks if the power is already max
- Add toString() methods for signals
# Conflicts:
#	src/main/java/lumien/randomthings/handler/RTEventHandler.java
@jchung01 jchung01 marked this pull request as ready for review January 15, 2026 05:13
@MagicJinn
Copy link
Owner

Wonderful PR! I won't be able to properly review it for a couple of days (includes the other PR as well), so I hope you can be patient! In the meantime, do you have any good benchmarks of the improvements in performance this provides? Also, feel free to edit the readme.md and changelog.md to add your changes and credit yourself, if you feel like it of course!

@jchung01
Copy link
Contributor Author

Updated the docs with changes from this PR.
Using my old Meatballcraft world with a lot of machines, there's a lot of broken stuff but should suffice for a benchmark. This is with 1 redstone interface in the world, but not sending/updating any signals.

Before PR:
https://spark.lucko.me/mPNrLj1XWR
BeforePR

After PR:
https://spark.lucko.me/h5rEs2zbZu
AfterPR

Permalink to reports: spark_profiles.zip

The difference is probably more noticeable if you have many redstone interfaces/observers, in different dimensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants