Skip to content

Commit 42543dc

Browse files
committed
mixin fix attempt
1 parent 4cf5f39 commit 42543dc

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

src/main/java/com/falsepattern/lib/internal/asm/IMixinPluginTransformer.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
import com.falsepattern.lib.mixin.MixinInfo;
2727
import lombok.val;
2828
import org.objectweb.asm.tree.ClassNode;
29-
import org.objectweb.asm.tree.MethodNode;
30-
31-
import java.util.ArrayList;
3229

3330
public class IMixinPluginTransformer implements IClassNodeTransformer {
3431
@Override
@@ -44,21 +41,18 @@ public boolean shouldTransform(ClassNode cn, String transformedName, boolean obf
4441
@Override
4542
public void transform(ClassNode cn, String transformedName, boolean obfuscated) {
4643
val methods = cn.methods;
47-
val remove = new ArrayList<MethodNode>();
48-
String name;
4944
if (!MixinInfo.isMixinBooterLegacy()) {
50-
FPTransformer.LOG.info("Could not detect MixinBooterLegacy. Removing MBL compat code.");
51-
name = "org/spongepowered/libraries/org/objectweb/asm/tree/ClassNode";
52-
} else {
53-
FPTransformer.LOG.info("Detected MixinBooterLegacy. Removing SpongeMixins compat code.");
54-
name = "org/spongepowered/asm/lib/tree/ClassNode";
55-
}
56-
for (val method: methods) {
57-
if ((method.name.equals("preApply") || method.name.equals("postApply")) &&
58-
method.desc.contains(name)) {
59-
remove.add(method);
45+
FPTransformer.LOG.info("Could not detect MixinBooterLegacy. Converting IMixinPlugin to legacy compat mode.");
46+
for (val method : methods) {
47+
if (method.name.equals("preApply") || method.name.equals("postApply")) {
48+
method.desc = method.desc.replace("org/spongepowered/libraries/org/objectweb/asm/tree/ClassNode",
49+
"org/spongepowered/asm/lib/tree/ClassNode");
50+
for (val local: method.localVariables) {
51+
local.desc = local.desc.replace("org/spongepowered/libraries/org/objectweb/asm/tree/ClassNode",
52+
"org/spongepowered/asm/lib/tree/ClassNode");
53+
}
54+
}
6055
}
6156
}
62-
methods.removeAll(remove);
6357
}
6458
}

src/main/java/com/falsepattern/lib/mixin/IMixinPlugin.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
package com.falsepattern.lib.mixin;
2222

2323
import com.falsepattern.lib.StableAPI;
24+
import com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
2425
import com.falsepattern.lib.util.FileUtil;
2526
import lombok.val;
2627
import org.apache.logging.log4j.LogManager;
2728
import org.apache.logging.log4j.Logger;
28-
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
2929
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
3030
import org.spongepowered.libraries.org.objectweb.asm.tree.ClassNode;
3131

@@ -157,14 +157,4 @@ default void preApply(String targetClassName, ClassNode targetClass, String mixi
157157
default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
158158

159159
}
160-
161-
@StableAPI.Expose(since = "__INTERNAL__")
162-
default void preApply(String targetClassName, com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
163-
164-
}
165-
166-
@StableAPI.Expose(since = "__INTERNAL__")
167-
default void postApply(String targetClassName, com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
168-
169-
}
170160
}

src/main/java/com/falsepattern/lib/mixin/stubpackage/org/spongepowered/asm/lib/tree/ClassNode.java

Lines changed: 0 additions & 25 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* This file is part of Mixin, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package com.falsepattern.lib.mixin.stubpackage.org.spongepowered.asm.mixin.extensibility;
26+
27+
import java.util.List;
28+
import java.util.Set;
29+
30+
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
31+
import org.spongepowered.libraries.org.objectweb.asm.tree.ClassNode;
32+
33+
public interface IMixinConfigPlugin {
34+
void onLoad(String mixinPackage);
35+
String getRefMapperConfig();
36+
boolean shouldApplyMixin(String targetClassName, String mixinClassName);
37+
void acceptTargets(Set<String> myTargets, Set<String> otherTargets);
38+
List<String> getMixins();
39+
void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo);
40+
void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo);
41+
}

0 commit comments

Comments
 (0)