From 3efedb75cd903ccb716dfaa6e4e3c81a77cfd196 Mon Sep 17 00:00:00 2001 From: drullkus Date: Tue, 19 Dec 2023 13:50:15 -0800 Subject: [PATCH] Jar shadowing, update mixins json, add mixin plugin --- build.gradle | 45 ++++++++++++++----- gradle.properties | 2 +- src/main/resources/META-INF/mods.toml | 7 ++- ...ns.json => worldedit-neoforge.mixins.json} | 6 +-- 4 files changed, 43 insertions(+), 17 deletions(-) rename src/main/resources/{worldedit-forge.mixins.json => worldedit-neoforge.mixins.json} (67%) diff --git a/build.gradle b/build.gradle index a4bbe2f..eee6b1e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,21 +3,42 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.57' + id 'net.neoforged.gradle.userdev' version '7.0.57' // Cannot be .70 or past (for now) + id 'net.neoforged.gradle.mixin' version '7.0.57' + id 'com.github.johnrengelman.shadow' version '8.1.1' id 'antlr' } version = mod_version group = mod_group_id +configurations { + shade +} + +shadowJar { + archiveClassifier.set('') + configurations = [project.configurations.shade] +} + repositories { mavenLocal() + + maven { + name 'EngineHub Repository' + url 'https://maven.enginehub.org/repo/' + } } base { archivesName = mod_id } +mixin { + //add(sourceSets.main, "worldedit-neoforge.refmap.json") // Neoforge doesn't need refmapping + config "worldedit-neoforge.mixins.json" +} + // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) @@ -29,7 +50,7 @@ minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/ runs { // applies to all the run configs below configureEach { - dependencies { + dependencies { // Requires neogradle version lesser than .70 (for now) runtime "net.kyori:text-api:${TEXT}" runtime "net.kyori:text-serializer-gson:${TEXT}" runtime "net.kyori:text-serializer-legacy:${TEXT}" @@ -84,13 +105,6 @@ runs { // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } -repositories { - maven { - name 'EngineHub Repository' - url 'https://maven.enginehub.org/repo/' - } -} - dependencies { // Specify the version of Minecraft to use. // Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above. @@ -104,10 +118,19 @@ dependencies { implementation "net.kyori:text-serializer-gson:${TEXT}" implementation "net.kyori:text-serializer-legacy:${TEXT}" implementation "net.kyori:text-serializer-plain:${TEXT}" - implementation "com.sk89q.lib:jlibnoise:1.0.0" implementation "org.enginehub.piston:core:${PISTON}" implementation "org.enginehub.piston.core-ap:runtime:${PISTON}" implementation "org.enginehub.piston:default-impl:${PISTON}" + + shade "net.kyori:text-api:${TEXT}" + shade "net.kyori:text-serializer-gson:${TEXT}" + shade "net.kyori:text-serializer-legacy:${TEXT}" + shade "net.kyori:text-serializer-plain:${TEXT}" + shade "org.enginehub.piston:core:${PISTON}" + shade "org.enginehub.piston.core-ap:runtime:${PISTON}" + shade "org.enginehub.piston:default-impl:${PISTON}" + + implementation "com.sk89q.lib:jlibnoise:1.0.0" implementation "org.yaml:snakeyaml:2.0" implementation "org.enginehub.piston.core-ap:annotations:${PISTON}" implementation "org.enginehub.piston.core-ap:processor:${PISTON}" @@ -230,3 +253,5 @@ publishing { tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation } + +build.dependsOn shadowJar diff --git a/gradle.properties b/gradle.properties index 95b0ba6..39b244f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ minecraft_version=1.20.4 minecraft_version_range=[1.20.4,1.21) # The Neo version must agree with the Minecraft version to get a valid artifact #neo_version=20.4.42-beta -neo_version=20.4.0-beta +neo_version=20.4.45-beta # The Neo version range can use any version of Neo as bounds or match the loader version range neo_version_range=[20.5,) # The loader version range can only use the major version of Neo/FML as bounds diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index f8f08bb..7351e5c 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -25,13 +25,16 @@ WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both ''' [[dependencies.worldedit]] modId="minecraft" - mandatory=true + type="required" versionRange="[1.20.3,)" ordering="NONE" side="BOTH" [[dependencies.worldedit]] modId="neoforge" - mandatory=true + type="required" versionRange="[20.3.1,)" ordering="NONE" side="BOTH" + +[[mixins]] +config = "worldedit-neoforge.mixins.json" diff --git a/src/main/resources/worldedit-forge.mixins.json b/src/main/resources/worldedit-neoforge.mixins.json similarity index 67% rename from src/main/resources/worldedit-forge.mixins.json rename to src/main/resources/worldedit-neoforge.mixins.json index d7de4e1..0331990 100644 --- a/src/main/resources/worldedit-forge.mixins.json +++ b/src/main/resources/worldedit-neoforge.mixins.json @@ -1,16 +1,14 @@ { "required": true, - "package": "com.sk89q.worldedit.forge.mixin", + "package": "com.sk89q.worldedit.neoforge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ "AccessorServerPlayerGameMode", "MixinLevelChunkSetBlockHook", "MixinServerGamePacketListenerImpl" ], - "server": [ - ], "injectors": { "defaultRequire": 1 }, - "refmap": "worldedit-forge.mixins.refmap.json" + "refmap": "worldedit-neoforge.refmap.json" }