Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 43 additions & 33 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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/")
Expand All @@ -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")
}
}
}

Expand All @@ -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"]}")
Expand All @@ -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.
Expand Down Expand Up @@ -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>("jar") {
from(rootProject.file("LICENSE")) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -295,6 +296,10 @@ loom {
source("test")
server()
}

configureEach {
programArgs("enableAmiCompat")
}
}
}

Expand All @@ -308,3 +313,8 @@ tasks.register<Jar>("testJar") {
tasks.withType<GenerateModuleMetadata> {
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<Test> {
failOnNoDiscoveredTests = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
modmenu_version = 1.1.1
rc_version = 0.5.4
ami_version = 1.10.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> 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<String> 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) {

}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down