Skip to content

Commit 49b207a

Browse files
committed
Move to GTNHMixins
1 parent 68ab3ef commit 49b207a

File tree

4 files changed

+61
-53
lines changed

4 files changed

+61
-53
lines changed

README.MD

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ModularUI - GUI library mod for Minecraft 1.7.10
22

33
This mod is a GUI library to ease the process of creating GUIs. Backported from 1.12.2 [ModularUI](https://github.com/CleanroomMC/ModularUI).
4-
Requires [SpongeMixins](https://github.com/TimeConqueror/SpongeMixins) or [GTNHMixins](https://github.com/GTNewHorizons/GTNHMixins) to work.
4+
Requires [GTNHMixins](https://github.com/GTNewHorizons/GTNHMixins) to work.
55

66
This mod is under LGPL-3 license.

build.gradle

+57-49
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//version: 1665425597
1+
//version: 1667597057
22
/*
33
DO NOT CHANGE THIS FILE!
44
Also, you may replace this file at any time if there is an update available.
5-
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
5+
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/master/build.gradle for updates.
66
*/
77

88

@@ -147,17 +147,21 @@ String javaSourceDir = "src/main/java/"
147147
String scalaSourceDir = "src/main/scala/"
148148
String kotlinSourceDir = "src/main/kotlin/"
149149

150-
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
151-
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
152-
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
150+
151+
final String modGroupPath = modGroup.toString().replaceAll("\\.", "/")
152+
final String apiPackagePath = apiPackage.toString().replaceAll("\\.", "/")
153+
154+
String targetPackageJava = javaSourceDir + modGroupPath
155+
String targetPackageScala = scalaSourceDir + modGroupPath
156+
String targetPackageKotlin = kotlinSourceDir + modGroupPath
153157
if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
154158
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
155159
}
156160

157161
if (apiPackage) {
158-
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
159-
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
160-
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
162+
targetPackageJava = javaSourceDir + modGroupPath + "/" + apiPackagePath
163+
targetPackageScala = scalaSourceDir + modGroupPath + "/" + apiPackagePath
164+
targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + apiPackagePath
161165
if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
162166
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
163167
}
@@ -171,31 +175,36 @@ if (accessTransformersFile) {
171175
}
172176

173177
if (usesMixins.toBoolean()) {
174-
if (mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
175-
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
178+
if (mixinsPackage.isEmpty()) {
179+
throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!")
176180
}
181+
final String mixinPackagePath = mixinsPackage.toString().replaceAll("\\.", "/")
182+
final String mixinPluginPath = mixinPlugin.toString().replaceAll("\\.", "/")
177183

178-
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
179-
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
180-
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
184+
targetPackageJava = javaSourceDir + modGroupPath + "/" + mixinPackagePath
185+
targetPackageScala = scalaSourceDir + modGroupPath + "/" + mixinPackagePath
186+
targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPackagePath
181187
if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
182188
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
183189
}
184190

185-
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
186-
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
187-
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
188-
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
189-
if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
190-
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
191+
if (!mixinPlugin.isEmpty()) {
192+
String targetFileJava = javaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java"
193+
String targetFileScala = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".scala"
194+
String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java"
195+
String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPluginPath + ".kt"
196+
if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
197+
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
198+
}
191199
}
192200
}
193201

194202
if (coreModClass) {
195-
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
196-
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
197-
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
198-
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt"
203+
final String coreModPath = coreModClass.toString().replaceAll("\\.", "/")
204+
String targetFileJava = javaSourceDir + modGroupPath + "/" + coreModPath + ".java"
205+
String targetFileScala = scalaSourceDir + modGroupPath + "/" + coreModPath + ".scala"
206+
String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + coreModPath + ".java"
207+
String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + coreModPath + ".kt"
199208
if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
200209
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
201210
}
@@ -251,7 +260,7 @@ if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
251260
def arguments = []
252261
def jvmArguments = []
253262

254-
if (usesMixins.toBoolean() || forceEnableMixins) {
263+
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
255264
arguments += [
256265
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
257266
]
@@ -316,13 +325,10 @@ repositories {
316325
name 'Overmind forge repo mirror'
317326
url 'https://gregtech.overminddl1.com/'
318327
}
319-
if (usesMixins.toBoolean() || forceEnableMixins) {
328+
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
320329
maven {
321-
name 'sponge'
322-
url 'https://repo.spongepowered.org/repository/maven-public'
323-
}
324-
maven {
325-
url 'https://jitpack.io'
330+
name = "GTNH Maven"
331+
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
326332
}
327333
}
328334
}
@@ -332,19 +338,10 @@ dependencies {
332338
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
333339
annotationProcessor('com.google.guava:guava:24.1.1-jre')
334340
annotationProcessor('com.google.code.gson:gson:2.8.6')
335-
annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
336-
}
337-
if (usesMixins.toBoolean() || forceEnableMixins) {
338-
// using 0.8 to workaround a issue in 0.7 which fails mixin application
339-
compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
340-
// Mixin includes a lot of dependencies that are too up-to-date
341-
exclude module: 'launchwrapper'
342-
exclude module: 'guava'
343-
exclude module: 'gson'
344-
exclude module: 'commons-io'
345-
exclude module: 'log4j-core'
346-
}
347-
compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
341+
annotationProcessor('org.spongepowered:mixin:0.8.5-GTNH:processor')
342+
}
343+
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
344+
compile('com.gtnewhorizon:gtnhmixins:2.0.2')
348345
}
349346
}
350347

@@ -356,13 +353,18 @@ def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
356353

357354
task generateAssets {
358355
if (usesMixins.toBoolean()) {
359-
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
356+
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json")
360357
if (!mixinConfigFile.exists()) {
358+
def mixinPluginLine = ""
359+
if(!mixinPlugin.isEmpty()) {
360+
// We might not have a mixin plugin if we're using early/late mixins
361+
mixinPluginLine += """\n "plugin": "${modGroup}.${mixinPlugin}", """
362+
}
363+
361364
mixinConfigFile.text = """{
362365
"required": true,
363-
"minVersion": "0.7.11",
364-
"package": "${modGroup}.${mixinsPackage}",
365-
"plugin": "${modGroup}.${mixinPlugin}",
366+
"minVersion": "0.8.5-GTNH",
367+
"package": "${modGroup}.${mixinsPackage}",${mixinPluginLine}
366368
"refmap": "${mixingConfigRefMap}",
367369
"target": "@env(DEFAULT)",
368370
"compatibilityLevel": "JAVA_8",
@@ -574,11 +576,11 @@ task devJar(type: Jar) {
574576

575577
task apiJar(type: Jar) {
576578
from(sourceSets.main.allSource) {
577-
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
579+
include modGroupPath + "/" + apiPackagePath + '/**'
578580
}
579581

580582
from(sourceSets.main.output) {
581-
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
583+
include modGroupPath + "/" + apiPackagePath + '/**'
582584
}
583585

584586
from(sourceSets.main.resources.srcDirs) {
@@ -691,6 +693,9 @@ if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) {
691693
addModrinthDep(qual[0], qual[1], parts[1])
692694
}
693695
}
696+
if (usesMixins.toBoolean()) {
697+
addModrinthDep("required", "version", "gtnhmixins")
698+
}
694699
tasks.modrinth.dependsOn(build)
695700
tasks.publish.dependsOn(tasks.modrinth)
696701
}
@@ -732,6 +737,9 @@ if (curseForgeProjectId.size() != 0 && System.getenv("CURSEFORGE_TOKEN") != null
732737
addCurseForgeRelation(parts[0], parts[1])
733738
}
734739
}
740+
if (usesMixins.toBoolean()) {
741+
addCurseForgeRelation("requiredDependency", "gtnhmixins")
742+
}
735743
tasks.curseforge.dependsOn(build)
736744
tasks.publish.dependsOn(tasks.curseforge)
737745
}

src/main/java/com/gtnewhorizons/modularui/ModularUI.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
public class ModularUI {
3535

3636
public static final String MODID = "modularui";
37-
public static final String DEPENDENCIES =
38-
"required-after:CodeChickenLib;" + "after:NotEnoughItems;" + "before:gregtech";
37+
public static final String DEPENDENCIES = "required-after:CodeChickenLib;" + "required-after:gtnhmixins@[2.0.1,); "
38+
+ "after:NotEnoughItems;" + "before:gregtech";
3939
public static final String GUI_FACTORY = Tags.GROUPNAME + ".config.GuiFactory";
4040

4141
public static final Logger logger = LogManager.getLogger(Tags.MODID);

src/main/java/com/gtnewhorizons/modularui/mixinplugin/MixinPlugin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import net.minecraft.launchwrapper.Launch;
1717
import org.apache.logging.log4j.LogManager;
1818
import org.apache.logging.log4j.Logger;
19-
import org.spongepowered.asm.lib.tree.ClassNode;
2019
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
2120
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
21+
import org.spongepowered.libraries.org.objectweb.asm.tree.ClassNode;
2222
import ru.timeconqueror.spongemixins.MinecraftURLClassPath;
2323

2424
public class MixinPlugin implements IMixinConfigPlugin {

0 commit comments

Comments
 (0)