diff --git a/build.gradle.kts b/build.gradle.kts index c206c5669..bfc3c0ad7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,8 +5,8 @@ import net.modificationstation.stationapi.gradle.SubprojectHelpers.addDependency plugins { id("maven-publish") - id("fabric-loom") version "1.9-SNAPSHOT" - id("babric-loom-extension") version "1.9.2" + id("fabric-loom") version "1.17.12" + id("babric-loom-extension") version "1.16.1" } // https://stackoverflow.com/a/40101046 - Even with kotlin, gradle can't get it's shit together. @@ -19,8 +19,12 @@ allprojects { apply(plugin = "fabric-loom") apply(plugin = "babric-loom-extension") - java.sourceCompatibility = JavaVersion.VERSION_17 - java.targetCompatibility = JavaVersion.VERSION_17 + java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } + withSourcesJar() + } repositories { maven(url = "https://maven.minecraftforge.net/") @@ -47,15 +51,13 @@ allprojects { } } - @Suppress("UnstableApiUsage") configurations { - create("transitiveImplementation") - - // Required cause loom 0.14 for some reason doesn't remove asm-all 4.1. Ew. - all { - exclude(group = "org.ow2.asm", module = "asm-debug-all") - exclude(group = "org.ow2.asm", module = "asm-all") - exclude(group = "babric") + listOf("transitiveImplementation", "modImplementation").forEach { name -> + named(name) { + exclude(group = "org.ow2.asm", module = "asm-debug-all") + exclude(group = "org.ow2.asm", module = "asm-all") + exclude(group = "babric", module = "fabric-loader") + } } } @@ -74,15 +76,15 @@ allprojects { modImplementation("net.fabricmc:fabric-loader:${project.properties["loader_version"]}") - "transitiveImplementation"(implementation("org.apache.commons:commons-lang3:3.12.0") as Dependency) - "transitiveImplementation"(implementation("commons-io:commons-io:2.11.0") as Dependency) - "transitiveImplementation"(implementation("net.jodah:typetools:${project.properties["typetools_version"]}") as Dependency) - "transitiveImplementation"(implementation("com.github.mineLdiver:UnsafeEvents:${project.properties["unsafeevents_version"]}") as Dependency) - "transitiveImplementation"(implementation("it.unimi.dsi:fastutil:${project.properties["fastutil_version"]}") as Dependency) - "transitiveImplementation"(implementation("com.github.ben-manes.caffeine:caffeine:${project.properties["caffeine_version"]}") as Dependency) - "transitiveImplementation"(implementation("com.mojang:datafixerupper:${project.properties["dfu_version"]}") as Dependency) - "transitiveImplementation"(implementation("maven.modrinth:spasm:${project.properties["spasm_version"]}") as Dependency) - "transitiveImplementation"(implementation("me.carleslc:Simple-Yaml:1.8.4") as Dependency) + transitiveImplementation(implementation("org.apache.commons:commons-lang3:3.12.0") as Dependency) + transitiveImplementation(implementation("commons-io:commons-io:2.11.0") as Dependency) + transitiveImplementation(implementation("net.jodah:typetools:${project.properties["typetools_version"]}") as Dependency) + transitiveImplementation(implementation("com.github.mineLdiver:UnsafeEvents:${project.properties["unsafeevents_version"]}") as Dependency) + transitiveImplementation(implementation("it.unimi.dsi:fastutil:${project.properties["fastutil_version"]}") as Dependency) + transitiveImplementation(implementation("com.github.ben-manes.caffeine:caffeine:${project.properties["caffeine_version"]}") as Dependency) + transitiveImplementation(implementation("com.mojang:datafixerupper:${project.properties["dfu_version"]}") as Dependency) + transitiveImplementation(implementation("maven.modrinth:spasm:${project.properties["spasm_version"]}") as Dependency) + transitiveImplementation(implementation("me.carleslc:Simple-Yaml:1.8.4") as Dependency) // not a runtime dependency unless we use something outside its events. modImplementation("net.glasslauncher.mods:GlassConfigAPI:${project.properties["gcapi_version"]}") @@ -97,11 +99,16 @@ allprojects { // adds some useful annotations for miscellaneous uses. does not add any dependencies, though people without the lib will be missing some useful context hints. implementation("org.jetbrains:annotations:23.0.0") - modLocalRuntime("net.glasslauncher.mods:ModMenu:${project.properties["modmenu_version"]}") + modLocalRuntime("net.danygames2014:modmenu:${project.properties["modmenu_version"]}") modLocalRuntime("maven.modrinth:retrocommands:${project.properties["rc_version"]}") { isTransitive = false } + // The "enableAmiCompat" program argument needs to be present in order to apply a dev-only patch for AMI to work + modLocalRuntime("net.glasslauncher.mods:AlwaysMoreItems:${project.properties["ami_version"]}") { + isTransitive = false + } + annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.4.1") // Optional bugfix mod for testing qol. Remove the // to enable. @@ -129,13 +136,6 @@ allprojects { } } - java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() - } - // Include license inside of the mod jar configure("jar") { from(rootProject.file("LICENSE")) { @@ -207,12 +207,13 @@ base.archivesName.set(project.properties["archives_base_name"] as String) version = (if (project.hasProperty("override_version")) (project.properties["override_version"] as String).substring(0, 7) else project.properties["mod_version"])!! subprojects { + version = rootProject.version + // This makes the older pre-releases easier to clean up. group = if (rootProject.hasProperty("override_version")) { - (project.properties["maven_group"] as String) + ".StationAPI.${(project.properties["override_version"] as String).substring(0, 7)}" - } - else { - (project.properties["maven_group"] as String) + ".StationAPI.submodule.${project.properties["archivesBaseName"]}" + (rootProject.properties["maven_group"] as String) + ".StationAPI.${(rootProject.properties["override_version"] as String).substring(0, 7)}" + } else { + (rootProject.properties["maven_group"] as String) + ".StationAPI.submodule.$name" } configurations { @@ -295,6 +296,10 @@ loom { source("test") server() } + + configureEach { + programArgs("enableAmiCompat") + } } } @@ -308,3 +313,8 @@ tasks.register("testJar") { tasks.withType { enabled = false } + +// Gradle 9 fails the build if there are no tests, but we are using the test package for a test mod +tasks.withType { + failOnNoDiscoveredTests = false +} \ No newline at end of file diff --git a/buildSrc/src/main/java/net/fabricmc/loom/util/GroovyXmlUtil.java b/buildSrc/src/main/java/net/fabricmc/loom/util/GroovyXmlUtil.java index 7547153ef..176fac0e9 100644 --- a/buildSrc/src/main/java/net/fabricmc/loom/util/GroovyXmlUtil.java +++ b/buildSrc/src/main/java/net/fabricmc/loom/util/GroovyXmlUtil.java @@ -25,7 +25,7 @@ package net.fabricmc.loom.util; import groovy.util.Node; -import groovy.xml.QName; +import javax.xml.namespace.QName; public final class GroovyXmlUtil { private GroovyXmlUtil() { } @@ -46,7 +46,7 @@ private static boolean isSameName(Object nodeName, String givenName) { } if (nodeName instanceof QName qName) { - return qName.matches(givenName); + return qName.getLocalPart().equals(givenName); } // New groovy 3 (gradle 7) class diff --git a/gradle.properties b/gradle.properties index 57c5e5a38..b13530acf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ fabric.loom.multiProjectOptimisation=true # check these on https://fabricmc.net/use minecraft_version = b1.7.3 yarn_mappings = b1.7.3+e1fe071 - loader_version = 0.16.9 + loader_version = 0.19.3 # Library Properties typetools_version = 0.8.3 @@ -28,5 +28,6 @@ fabric.loom.multiProjectOptimisation=true # Test properties gcapi_version = 3.2.5 - modmenu_version = 1.8.5-beta.11 - rc_version = 0.5.4 \ No newline at end of file + modmenu_version = 1.1.1 + rc_version = 0.5.4 + ami_version = 1.10.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e18bc253b..5dd3c0121 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/StationRecipesMixinPlugin.java b/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/StationRecipesMixinPlugin.java new file mode 100644 index 000000000..481fa44e1 --- /dev/null +++ b/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/StationRecipesMixinPlugin.java @@ -0,0 +1,74 @@ +package net.modificationstation.stationapi.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import net.modificationstation.stationapi.api.StationAPI; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class StationRecipesMixinPlugin implements IMixinConfigPlugin { + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return true; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + if (!FabricLoader.getInstance().isDevelopmentEnvironment()) { + return null; + } + + if (FabricLoader.getInstance().isModLoaded("alwaysmoreitems")) { + return null; + } + + boolean enableAmiCompat = false; + String[] launchArgs = FabricLoader.getInstance().getLaunchArguments(true); + for (String arg : launchArgs) { + if (arg.contains("enableAmiCompat")) { + enableAmiCompat = true; + break; + } + } + + if (!enableAmiCompat) { + return null; + } + + StationAPI.LOGGER.info("AlwaysMoreItems detected in development environment, adding mixins to make it work"); + + ArrayList mixins = new ArrayList<>(); + mixins.add("dev.StationShapedRecipeMixin"); + mixins.add("dev.StationShapelessRecipeMixin"); + return mixins; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/recipe/dev/StationShapedRecipeMixin.java b/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/recipe/dev/StationShapedRecipeMixin.java new file mode 100644 index 000000000..3ef5b31bd --- /dev/null +++ b/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/recipe/dev/StationShapedRecipeMixin.java @@ -0,0 +1,19 @@ +package net.modificationstation.stationapi.mixin.recipe.dev; + +import net.minecraft.item.ItemStack; +import net.modificationstation.stationapi.impl.recipe.StationShapedRecipe; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; + +@SuppressWarnings("UnusedMixin") // Added in a mixin plugin only in development environment with AlwaysMoreItems present +@Mixin(StationShapedRecipe.class) +public abstract class StationShapedRecipeMixin { + @Shadow + public abstract ItemStack getOutput(); + + @Unique + public ItemStack method_2073() { + return this.getOutput(); + } +} diff --git a/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/recipe/dev/StationShapelessRecipeMixin.java b/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/recipe/dev/StationShapelessRecipeMixin.java new file mode 100644 index 000000000..4f2701c23 --- /dev/null +++ b/station-recipes-v0/src/main/java/net/modificationstation/stationapi/mixin/recipe/dev/StationShapelessRecipeMixin.java @@ -0,0 +1,19 @@ +package net.modificationstation.stationapi.mixin.recipe.dev; + +import net.minecraft.item.ItemStack; +import net.modificationstation.stationapi.impl.recipe.StationShapelessRecipe; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; + +@SuppressWarnings("UnusedMixin") // Added in a mixin plugin only in development environment with AlwaysMoreItems present +@Mixin(StationShapelessRecipe.class) +public abstract class StationShapelessRecipeMixin { + @Shadow + public abstract ItemStack getOutput(); + + @Unique + public ItemStack method_2073() { + return this.getOutput(); + } +} diff --git a/station-recipes-v0/src/main/resources/station-recipes-v0.mixins.json b/station-recipes-v0/src/main/resources/station-recipes-v0.mixins.json index cb789d3bc..ea2816a23 100644 --- a/station-recipes-v0/src/main/resources/station-recipes-v0.mixins.json +++ b/station-recipes-v0/src/main/resources/station-recipes-v0.mixins.json @@ -3,6 +3,7 @@ "minVersion": "0.8", "package": "net.modificationstation.stationapi.mixin.recipe", "compatibilityLevel": "JAVA_17", + "plugin": "net.modificationstation.stationapi.mixin.StationRecipesMixinPlugin", "mixins": [ "CraftingRecipeManagerMixin", "CraftingResultMixin",