Skip to content

Support no-refmap method patches and ModifyConstant injectors#12

Open
dominicbytes wants to merge 1 commit into
Sinytra:26.1.xfrom
dominicbytes:bytecraft/connector-26.1.2-mixin-repairs
Open

Support no-refmap method patches and ModifyConstant injectors#12
dominicbytes wants to merge 1 commit into
Sinytra:26.1.xfrom
dominicbytes:bytecraft/connector-26.1.2-mixin-repairs

Conversation

@dominicbytes

Copy link
Copy Markdown

The Issue

Adapter currently skips method transformations when it cannot resolve the mixin's clean target method. This prevents explicitly configured compatibility patches from running for Fabric mods that omit a usable refmap, even when the patch precisely matches the mixin annotation and supplies the required replacement.

Adapter also lacks a mixin model for @ModifyConstant. As a result, these injectors cannot be adapted when their target method moves between Minecraft and NeoForge. Integer constants are not represented by ConstantData, further limiting constant-injector matching.

Finally, the method-patch API cannot independently modify an injector's ordinal and its nested @At.ordinal. These are separate annotation properties and may both require adjustment after target bytecode changes.

These limitations were encountered while adapting Origins: Legacy to Minecraft 26.1.2 through Connector.

The Proposal

This change expands Adapter's generic method-patching capabilities:

  • Adds a ModifyConstantMixin model and registers @ModifyConstant as a supported mixin type.
  • Adds integer constant support to ConstantData.
  • Prevents the generic injection-point resolver from handling constant injectors before TARGET_CONSTANT has been inherited.
  • Allows an explicitly matched manual patch to run when the clean target method cannot be resolved.
  • Adds separate method-patch operations for modifying the injector ordinal and nested injection-point @At.ordinal.
  • Makes injection-point ordinal changes compose with earlier injection-point target changes.
  • Adds regression coverage for @ModifyConstant recognition and simultaneous injector/injection-point ordinal changes.

Explicit patches still have to match their configured target class, target method, mixin type, and other supplied annotation properties.

Possible Side Effects

Explicit manual patches can now run in cases where no clean target method is available. A stale or overly broad manual patch could therefore be attempted where Adapter previously returned early.

This risk is limited by the existing patch matcher and dirty-configuration validation. The fallback applies only when an explicitly registered patch matches; automatic resolution behavior remains unchanged when no manual patch is present.

Registering @ModifyConstant means these injectors now enter the normal Adapter processing pipeline instead of remaining unsupported. This may expose existing constant injectors to transformations that were previously skipped.

No material performance impact is expected. The additional matching and configuration work occurs only during mod transformation.

Alternatives

One alternative was to implement each affected transformation as a mod-specific bytecode rewrite in Connector. This was not selected because missing @ModifyConstant support and independent ordinal editing are general Adapter capabilities that can benefit other Fabric mod adaptations.

Another option was to generate or fabricate refmap information for mods that do not provide it. That would introduce inferred mapping data and could cause Adapter to select an incorrect clean target.

Disabling the affected mixins was also considered. This would allow startup in some cases but could remove intended mod behavior and produce a false compatibility result.

A final alternative was to retarget only the affected methods without adding a @ModifyConstant model. That would not provide the configuration and parameter handling required to transform constant injectors safely.

Additional Notes

Validation completed successfully:

  • Adapter unit suite: 31 tests passed.
  • Minecraft 26.1.2 Adapter integration suite: passed.
  • Connector transformer regression suite using the updated Adapter: passed.
  • A cold dedicated-server transformation of Origins: Legacy 1.12.15 for Minecraft 26.1.2 reached the server-ready marker and shut down cleanly.

@Su5eD Su5eD self-assigned this Jul 15, 2026
@Su5eD Su5eD added the enhancement New feature or request label Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test needs to be documented.

Please also add a new DynamicMixinPatchTest test with a real-world example or equivalent under testClasses.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants