Skip to content

Refactor WirelessNetworkMixin to use injection for range - #1612

Closed
Dokt0r wants to merge 1 commit into
ryanhcode:mainfrom
Dokt0r:main
Closed

Dokt0r wants to merge 1 commit into
ryanhcode:mainfrom
Dokt0r:main

Conversation

@Dokt0r

@Dokt0r Dokt0r commented Oct 7, 2026

Copy link
Copy Markdown

Summary of Changes

Fixes an InjectionError (Scanned 0 target(s)) occurring when running Sable alongside CC: Tweaked 1.120.0+.

Problem

The previous implementation relied on a @Redirect targeting the Vec3.distanceToSqr invocation inside WirelessNetwork.tryTransmit. Bytecode shifts or instruction changes in recent CC: Tweaked builds caused Mixin to fail locating the targeted instruction, resulting in a server crash on startup.

Solution

Replaced the fragile @Redirect with a head injection (@At("HEAD")) on tryTransmit(PacketReceiver, Packet, double, boolean):

  1. Intercepts tryTransmit at entry.
  2. Re-implements the transmission check while substituting the distance calculation with Sable.HELPER.distanceSquaredWithSubLevels(...).
  3. Cancels the original method execution via ci.cancel().

This approach avoids fragile INVOKE matching while maintaining full sub-level distance support for wireless modems.

This mixin adjusts the wireless modem range calculations to account for sub-level distances by injecting into the tryTransmit method.
@CLAassistant

CLAassistant commented Oct 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@IThundxr

IThundxr commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

This is awful, inject + unconditional cancels should never be used.

@IThundxr IThundxr closed this Oct 7, 2026
@IThundxr

IThundxr commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Furthermore this fix is entirely incorrect, WirelessNetwork in CC: Tweaked hasn't been changed in years, so whatever issue you are experiencing is likely caused by another mod and you should make a issue about it here so someone can implement a proper fix.

@Dokt0r

Dokt0r commented Oct 7, 2026

Copy link
Copy Markdown
Author

Thanks, I went more in depth into the issue it was caused by a code injection incompatibility between Valkyrien skies and Sable ended up creating my own patch/bridge and it now works with both mods at the same time.

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.

3 participants