Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-introduce Superclass Transformer #3629

Merged
merged 3 commits into from Feb 25, 2022
Merged

Conversation

gabizou
Copy link
Member

@gabizou gabizou commented Feb 14, 2022

Goal

Reintroduces the ability to re-assign the superclass of a target class previously achieved in legacy launch wrapper transformers. Certain API based classes have a requirement at runtime to be extensions of implementation classes.

Solution

The new transformer setup also pulls out the AccessWidener transformer to be available for both Vanilla and Forge without depending on either.

An example of changing org.spongepowered.api.entity.ai.goal.AbstractGoal from java.lang.Object:
In SpongeForge:

     protected AbstractGoal(org.spongepowered.api.entity.ai.goal.GoalType arg0) { // <init> //(Lorg/spongepowered/api/entity/ai/goal/GoalType;)V
         <localVar:index=0 , name=this , desc=Lorg/spongepowered/api/entity/ai/goal/AbstractGoal;, sig=Lorg/spongepowered/api/entity/ai/goal/AbstractGoal<TO;>;, start=L1, end=L2>
         <localVar:index=1 , name=type , desc=Lorg/spongepowered/api/entity/ai/goal/GoalType;, sig=null, start=L1, end=L2>

         L1 {
             aload0 // reference to self
             invokespecial net/minecraft/entity/ai/goal/Goal.<init>()V
         }

In SpongeVanilla:

     protected AbstractGoal(org.spongepowered.api.entity.ai.goal.GoalType arg0) { // <init> //(Lorg/spongepowered/api/entity/ai/goal/GoalType;)V
         <localVar:index=0 , name=this , desc=Lorg/spongepowered/api/entity/ai/goal/AbstractGoal;, sig=Lorg/spongepowered/api/entity/ai/goal/AbstractGoal<TO;>;, start=L1, end=L2>
         <localVar:index=1 , name=type , desc=Lorg/spongepowered/api/entity/ai/goal/GoalType;, sig=null, start=L1, end=L2>

         L1 {
             aload0 // reference to self
             invokespecial net/minecraft/world/entity/ai/goal/Goal.<init>()V
         }

Caveats

  • Pretty dumb transformer that doesn't handle remapping
  • Buildscript isn't tidy or self isolated, could probably build modlauncher-transformers as a separated jar
  • AccessWideners is only remapped by SpongeForge, not modlauncher-transformers

@gabizou gabizou force-pushed the api8/superclass-transformer branch 2 times, most recently from 931487d to ba81410 Compare February 17, 2022 08:36
Expanding on the existing getMixinConfiguration, we can enable querying
for potentially parented configurations from child projects.

Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
A general purpose project to enable SpongeForge and SpongeVanilla
to ship and share the same transformers thereby reducing code
duplication.

Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
Properly reintroduces superclass transformers with
ModLauncher's ITransformer api. There are some quirks with
needing to accept transforming classes multiple times based
on voting contexts. This functions as expected in both
development and production cases from limited testing.

Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
@gabizou gabizou merged commit 671bb14 into api-8 Feb 25, 2022
@gabizou gabizou deleted the api8/superclass-transformer branch February 25, 2022 05:37
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.

None yet

1 participant