Skip to content

Commit 0b3c0a9

Browse files
committed
mixinbooter compat
1 parent 44dea11 commit 0b3c0a9

File tree

12 files changed

+195
-46
lines changed

12 files changed

+195
-46
lines changed

build.gradle

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1656003793falsepattern29
1+
//version: 1656003793falsepattern31
22
/*
33
DO NOT CHANGE THIS FILE!
44
@@ -24,7 +24,7 @@ buildscript {
2424
mavenLocal()
2525
maven {
2626
name = "forge"
27-
url = "https://maven.minecraftforge.net"
27+
url = "https://mvn.falsepattern.com/forge/"
2828
}
2929
maven {
3030
name = "sonatype"
@@ -36,11 +36,11 @@ buildscript {
3636
}
3737
maven {
3838
name = "jitpack"
39-
url = "https://jitpack.falsepattern.com/"
39+
url = "https://mvn.falsepattern.com/jitpack/"
4040
}
4141
maven {
42-
name = "mavenpattern"
43-
url = "https://maven.falsepattern.com/"
42+
name = "mvnpattern"
43+
url = "https://mvn.falsepattern.com/releases/"
4444
}
4545
}
4646
dependencies {
@@ -120,11 +120,18 @@ propertyDefaultIfUnset("mavenArtifactId", "")
120120
propertyDefaultIfUnset("hasMixinDeps", false)
121121
propertyDefaultIfUnset("mixinPreinitConfig", "")
122122
propertyDefaultIfUnset("remapStubs", false)
123+
propertyDefaultIfUnset("useObsoleteSpongeMixins", false)
123124

124125
propertyDefaultIfUnset("remoteMappings", "https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/")
125126
propertyDefaultIfUnset("mappingsChannel", "stable")
126127
propertyDefaultIfUnset("mappingsVersion", "12")
127128

129+
if (usesMixins.toBoolean() && !useObsoleteSpongeMixins.toBoolean()) {
130+
//1.1.2
131+
//Currently using upstream, will make a fork soon(tm)
132+
apply from: 'https://raw.githubusercontent.com/tox1cozZ/mixin-booter-legacy/30de05f4c3e41360f423d8c5fd4adc73d4677a37/gradle/configurations/v1.gradle'
133+
}
134+
128135
String javaSourceDir = "src/main/java/"
129136
String scalaSourceDir = "src/main/scala/"
130137
String kotlinSourceDir = "src/main/kotlin/"
@@ -271,43 +278,53 @@ repositories {
271278
url = "https://gregtech.overminddl1.com/"
272279
}
273280
if(usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
274-
maven {
275-
name = "sponge"
276-
url = "https://sponge.falsepattern.com/"
281+
if (useObsoleteSpongeMixins.toBoolean()) {
282+
maven {
283+
name = "sponge"
284+
url = "https://mvn.falsepattern.com/sponge"
285+
}
277286
}
278287
maven {
279-
url = "https://jitpack.falsepattern.com/"
288+
url = "https://mvn.falsepattern.com/jitpack"
280289
}
281290
}
282291
}
283292

284293
dependencies {
285294
if(usesMixins.toBoolean()) {
286-
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
287-
annotationProcessor("com.google.guava:guava:24.1.1-jre")
288-
annotationProcessor("com.google.code.gson:gson:2.8.6")
289-
annotationProcessor("org.spongepowered:mixin:0.8-20200110.181151-15")
290-
// using 0.8 to workaround a issue in 0.7 which fails mixin application
291-
compile("org.spongepowered:mixin:0.7.11-20180703.121122-1") {
292-
// Mixin includes a lot of dependencies that are too up-to-date
293-
exclude module: "launchwrapper"
294-
exclude module: "guava"
295-
exclude module: "gson"
296-
exclude module: "commons-io"
297-
exclude module: "log4j-core"
295+
if (useObsoleteSpongeMixins.toBoolean()) {
296+
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
297+
annotationProcessor("com.google.guava:guava:24.1.1-jre")
298+
annotationProcessor("com.google.code.gson:gson:2.8.6")
299+
annotationProcessor("org.spongepowered:mixin:0.8-20200110.181151-15")
300+
// using 0.8 to workaround a issue in 0.7 which fails mixin application
301+
compile("org.spongepowered:mixin:0.7.11-20180703.121122-1") {
302+
// Mixin includes a lot of dependencies that are too up-to-date
303+
exclude module: "launchwrapper"
304+
exclude module: "guava"
305+
exclude module: "gson"
306+
exclude module: "commons-io"
307+
exclude module: "log4j-core"
308+
}
309+
compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
310+
} else {
311+
compile("com.github.tox1cozZ:mixin-booter-legacy:1.1.2")
298312
}
299-
compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
300313
}
301314
if(hasMixinDeps.toBoolean()) {
302-
runtime("org.spongepowered:mixin:0.7.11-20180703.121122-1") {
303-
// Mixin includes a lot of dependencies that are too up-to-date
304-
exclude module: "launchwrapper"
305-
exclude module: "guava"
306-
exclude module: "gson"
307-
exclude module: "commons-io"
308-
exclude module: "log4j-core"
315+
if (useObsoleteSpongeMixins.toBoolean()) {
316+
runtime("org.spongepowered:mixin:0.7.11-20180703.121122-1") {
317+
// Mixin includes a lot of dependencies that are too up-to-date
318+
exclude module: "launchwrapper"
319+
exclude module: "guava"
320+
exclude module: "gson"
321+
exclude module: "commons-io"
322+
exclude module: "log4j-core"
323+
}
324+
runtime("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
325+
} else {
326+
runtime("com.github.tox1cozZ:mixin-booter-legacy:1.1.2")
309327
}
310-
runtime("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
311328
}
312329
}
313330

@@ -378,18 +395,22 @@ jar {
378395
}
379396

380397
reobf {
381-
if(usesMixins.toBoolean()) {
398+
if(usesMixins.toBoolean() && useObsoleteSpongeMixins.toBoolean() && file(mixinSrg).exists()) {
382399
addExtraSrgFile mixinSrg
383400
}
384401
}
385402

386403
afterEvaluate {
387404
if(usesMixins.toBoolean()) {
388405
tasks.compileJava {
406+
if (useObsoleteSpongeMixins.toBoolean()) {
407+
options.compilerArgs += [
408+
"-AreobfSrgFile=${tasks.reobf.srg}",
409+
"-AoutSrgFile=${mixinSrg}",
410+
"-AoutRefMapFile=${refMap}"
411+
]
412+
}
389413
options.compilerArgs += [
390-
"-AreobfSrgFile=${tasks.reobf.srg}",
391-
"-AoutSrgFile=${mixinSrg}",
392-
"-AoutRefMapFile=${refMap}",
393414
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
394415
"-XDenableSunApiLintControl",
395416
"-XDignore.symbol.file"
@@ -694,7 +715,7 @@ task updateBuildScript {
694715
}
695716
}
696717

697-
if (!skipBuildScriptUpdateCheck.toBoolean() && isNewBuildScriptVersionAvailable(projectDir.toString())) {
718+
if (!project.getGradle().startParameter.isOffline() && !skipBuildScriptUpdateCheck.toBoolean() && isNewBuildScriptVersionAvailable(projectDir.toString())) {
698719
if (autoUpdateBuildScript.toBoolean()) {
699720
performBuildScriptUpdate(projectDir.toString())
700721
} else {

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dependencies {
22
compileOnly("org.projectlombok:lombok:1.18.22") {
33
transitive = false
44
}
5-
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
5+
compileOnly("com.github.tox1cozZ:mixin-booter-legacy:1.1.2") {
66
transitive = false
77
}
88
compileOnly("com.falsepattern:json:0.4.1")

gradle.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,15 @@ mixinPlugin =
7070
mixinsPackage =
7171
# Specify a preinit mixin here. Preinit mixins should be used very rarely, if at all, so this mixin config will not be managed by the buildscript, only included.
7272
mixinPreinitConfig =
73+
# By default, the buildscript uses mixin-booter-legacy for mixins. You can force the buildscript to use the obsolete SpongeMixins
74+
# library using this setting.
75+
# MixinBooterLegacy provides Mixins 0.8.2
76+
# SpongeMixins provides Mixins 0.7.11 on the official version, and Mixins 0.7.12 on the nh version
77+
useObsoleteSpongeMixins = false
7378
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
7479
# This parameter is for legacy compatability only
7580
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
76-
coreModClass = internal.CoreLoadingPlugin
81+
coreModClass = internal.asm.CoreLoadingPlugin
7782
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
7883
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
7984
containsMixinsAndOrCoreModOnly = false

repositories.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
repositories {
22
maven {
33
name = "sponge"
4-
url = "https://mvn.falsepattern.com/sponge"
4+
url = "https://mvn.falsepattern.com/sponge/"
5+
}
6+
maven {
7+
name = "jitpack"
8+
url = "https://mvn.falsepattern.com/jitpack/"
59
}
610
maven {
711
name = "mvnpattern"

src/main/java/com/falsepattern/lib/asm/ASMUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.falsepattern.lib.asm.exceptions.AsmClassNotFoundException;
2525
import com.falsepattern.lib.asm.exceptions.AsmFieldNotFoundException;
2626
import com.falsepattern.lib.asm.exceptions.AsmMethodNotFoundException;
27-
import com.falsepattern.lib.internal.CoreLoadingPlugin;
27+
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
2828
import com.falsepattern.lib.mapping.MappingManager;
2929
import com.falsepattern.lib.mapping.types.MappingType;
3030
import com.falsepattern.lib.mapping.types.NameType;

src/main/java/com/falsepattern/lib/asm/SmartTransformer.java

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

2323
import com.falsepattern.lib.StableAPI;
24-
import com.falsepattern.lib.internal.CoreLoadingPlugin;
24+
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
2525
import lombok.val;
2626
import org.apache.logging.log4j.Logger;
2727
import org.objectweb.asm.ClassReader;

src/main/java/com/falsepattern/lib/internal/CoreLoadingPlugin.java renamed to src/main/java/com/falsepattern/lib/internal/asm/CoreLoadingPlugin.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
* You should have received a copy of the GNU Lesser General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2020
*/
21-
package com.falsepattern.lib.internal;
21+
package com.falsepattern.lib.internal.asm;
2222

23+
import com.falsepattern.lib.internal.Tags;
24+
import com.falsepattern.lib.internal.asm.FPTransformer;
2325
import lombok.Getter;
2426
import lombok.val;
2527

@@ -36,6 +38,7 @@
3638
@MCVersion("1.7.10")
3739
@Name(Tags.MODID)
3840
@SortingIndex(500)
41+
@IFMLLoadingPlugin.TransformerExclusions({Tags.GROUPNAME + ".internal.asm", Tags.GROUPNAME + ".asm"})
3942
public class CoreLoadingPlugin implements IFMLLoadingPlugin {
4043
@Getter
4144
private static boolean obfuscated;
@@ -101,7 +104,7 @@ private static Error skillIssue(String message) {
101104

102105
@Override
103106
public String[] getASMTransformerClass() {
104-
return null;
107+
return new String[]{Tags.GROUPNAME + ".internal.asm.FPTransformer"};
105108
}
106109

107110
@Override
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.falsepattern.lib.internal.asm;
2+
3+
import com.falsepattern.lib.StableAPI;
4+
import com.falsepattern.lib.asm.IClassNodeTransformer;
5+
import com.falsepattern.lib.asm.SmartTransformer;
6+
import com.falsepattern.lib.internal.Tags;
7+
import lombok.Getter;
8+
import lombok.experimental.Accessors;
9+
import org.apache.logging.log4j.LogManager;
10+
import org.apache.logging.log4j.Logger;
11+
12+
import java.util.Collections;
13+
import java.util.List;
14+
15+
@Accessors(fluent = true)
16+
@StableAPI(since = "__INTERNAL__")
17+
public class FPTransformer implements SmartTransformer {
18+
@Getter
19+
private final List<IClassNodeTransformer> transformers;
20+
21+
@Getter
22+
private final Logger logger = LogManager.getLogger(Tags.MODNAME + " ASM");
23+
24+
public FPTransformer() {
25+
boolean obsolete;
26+
try {
27+
Class.forName("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin");
28+
logger.info("Detected MixinBooter Legacy.");
29+
obsolete = false;
30+
} catch (ClassNotFoundException e) {
31+
logger.info("Detected SpongeMixins or Grimoire. Applying legacy compat fix to IMixinPlugin.");
32+
obsolete = true;
33+
}
34+
transformers = Collections.singletonList(new IMixinPluginTransformer(obsolete));
35+
}
36+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.falsepattern.lib.internal.asm;
2+
3+
import com.falsepattern.lib.asm.IClassNodeTransformer;
4+
import com.falsepattern.lib.internal.Tags;
5+
import lombok.RequiredArgsConstructor;
6+
import lombok.val;
7+
import org.objectweb.asm.tree.ClassNode;
8+
import org.objectweb.asm.tree.MethodNode;
9+
10+
import java.util.ArrayList;
11+
12+
@RequiredArgsConstructor
13+
public class IMixinPluginTransformer implements IClassNodeTransformer {
14+
private final boolean obsolete;
15+
16+
@Override
17+
public String getName() {
18+
return "IMixinPluginTransformer";
19+
}
20+
21+
@Override
22+
public boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated) {
23+
return transformedName.equals(Tags.GROUPNAME + ".mixin.IMixinPlugin");
24+
}
25+
26+
@Override
27+
public void transform(ClassNode cn, String transformedName, boolean obfuscated) {
28+
val methods = cn.methods;
29+
val remove = new ArrayList<MethodNode>();
30+
if (obsolete) {
31+
for (val method : methods) {
32+
if (method.name.equals("preApply") || method.name.equals("postApply")) {
33+
remove.add(method);
34+
}
35+
}
36+
methods.removeAll(remove);
37+
for (val method : methods) {
38+
if (method.name.equals("preApply_obsolete") || method.name.equals("postApply_obsolete")) {
39+
method.name = method.name.substring(0, method.name.indexOf('_'));
40+
}
41+
}
42+
} else {
43+
for (val method : methods) {
44+
if (method.name.equals("preApply_obsolete") || method.name.equals("postApply_obsolete")) {
45+
remove.add(method);
46+
}
47+
}
48+
}
49+
}
50+
}

src/main/java/com/falsepattern/lib/mapping/MappingManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.falsepattern.lib.dependencies.DependencyLoader;
2525
import com.falsepattern.lib.dependencies.Library;
2626
import com.falsepattern.lib.dependencies.SemanticVersion;
27-
import com.falsepattern.lib.internal.CoreLoadingPlugin;
27+
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
2828
import com.falsepattern.lib.mapping.storage.Lookup;
2929
import com.falsepattern.lib.mapping.types.MappingType;
3030
import com.falsepattern.lib.mapping.types.NameType;

src/main/java/com/falsepattern/lib/mapping/types/UniversalClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
package com.falsepattern.lib.mapping.types;
2222

2323
import com.falsepattern.lib.StableAPI;
24-
import com.falsepattern.lib.internal.CoreLoadingPlugin;
24+
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
2525
import com.falsepattern.lib.mapping.storage.Lookup;
2626
import com.falsepattern.lib.mapping.storage.MappedString;
2727
import lombok.EqualsAndHashCode;

0 commit comments

Comments
 (0)