From 682bb6a502372b43c9edc3d6fbf5020cd02b9b9b Mon Sep 17 00:00:00 2001 From: Deftu Date: Mon, 30 Dec 2024 15:34:06 +0200 Subject: [PATCH 01/14] dgt multiversion examplemod yeah --- build.gradle.kts | 202 +++--------------- gradle.properties | 25 ++- root.gradle.kts | 17 +- settings.gradle.kts | 34 ++- .../org/polyfrost/example/ExampleMod.java | 34 +-- .../example/command/ExampleCommand.java | 2 +- .../example/config/ExampleConfig.java | 36 ++++ .../polyfrost/example/config/TestConfig.java | 48 ----- .../org/polyfrost/example/hud/ExampleHud.java | 5 + .../org/polyfrost/example/hud/TestHud.java | 20 -- .../example/mixin/MinecraftMixin.java | 10 +- src/main/resources/mcmod.info | 8 +- src/main/resources/mixins.examplemod.json | 4 +- 13 files changed, 153 insertions(+), 292 deletions(-) create mode 100644 src/main/java/org/polyfrost/example/config/ExampleConfig.java delete mode 100644 src/main/java/org/polyfrost/example/config/TestConfig.java create mode 100644 src/main/java/org/polyfrost/example/hud/ExampleHud.java delete mode 100644 src/main/java/org/polyfrost/example/hud/TestHud.java diff --git a/build.gradle.kts b/build.gradle.kts index 0b5413d..1b61606 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,192 +1,50 @@ @file:Suppress("UnstableApiUsage", "PropertyName") -import org.polyfrost.gradle.util.noServerRunConfigs -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import dev.deftu.gradle.utils.GameSide +import dev.deftu.gradle.utils.MinecraftVersion -// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit -// which we use to prepare the environment. plugins { - kotlin("jvm") - id("org.polyfrost.multi-version") - id("org.polyfrost.defaults.repo") - id("org.polyfrost.defaults.java") - id("org.polyfrost.defaults.loom") - id("com.github.johnrengelman.shadow") - id("net.kyori.blossom") version "1.3.2" - id("signing") java + kotlin("jvm") + id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders. + id("dev.deftu.gradle.tools") // Applies several configurations to things such as the Java version, project name/version, etc. + id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources. + id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files. + id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those! + id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you. + id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth. } -// Gets the mod name, version and id from the `gradle.properties` file. -val mod_name: String by project -val mod_version: String by project -val mod_id: String by project -val mod_archives_name: String by project - -// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`. -blossom { - replaceToken("@VER@", mod_version) - replaceToken("@NAME@", mod_name) - replaceToken("@ID@", mod_id) -} - -// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver! -version = mod_version -// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username. -// e.g. com.github. or com. -group = "org.polyfrost" - -// Sets the name of the output jar (the one you put in your mods folder and send to other people) -// It outputs all versions of the mod into the `versions/{mcVersion}/build` directory. -base { - archivesName.set("$mod_archives_name-$platform") -} - -// Configures Polyfrost Loom, our plugin fork to easily set up the programming environment. -loom { - // Removes the server configs from IntelliJ IDEA, leaving only client runs. - noServerRunConfigs() - - // Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org) - if (project.platform.isLegacyForge) { - runConfigs { - "client" { - programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") - property("mixin.debug.export", "true") // Outputs all mixin changes to `versions/{mcVersion}/run/.mixin.out/class` - } - } - } - // Configures the mixins if we are building for forge - if (project.platform.isForge) { - forge { - mixinConfig("mixins.${mod_id}.json") - } - } - // Configures the name of the mixin "refmap" - mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json") -} - -// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately. -val shade: Configuration by configurations.creating { - configurations.implementation.get().extendsFrom(this) -} -val modShade: Configuration by configurations.creating { - configurations.modImplementation.get().extendsFrom(this) -} - -// Configures the output directory for when building from the `src/resources` directory. -sourceSets { - main { - output.setResourcesDir(java.classesDirectory) - } -} - -// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod. -repositories { - maven("https://repo.polyfrost.org/releases") -} +toolkitLoomHelper { + useOneConfig { + version = "1.0.0-alpha.47" + loaderVersion = "1.1.0-alpha.34" -// Configures the libraries/dependencies for your mod. -dependencies { - // Adds the OneConfig library, so we can develop with it. - modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.2-alpha+") + usePolyMixin = true + polyMixinVersion = "0.8.4+build.2" - // Adds DevAuth, which we can use to log in to Minecraft in development. - modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.2.0") + applyLoaderTweaker = true - // If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier, as well as mixin 0.7.11 - if (platform.isLegacyForge) { - compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") - shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta17") - } -} - -tasks { - // Processes the `src/resources/mcmod.info`, `fabric.mod.json`, or `mixins.${mod_id}.json` and replaces - // the mod id, name and version with the ones in `gradle.properties` - processResources { - inputs.property("id", mod_id) - inputs.property("name", mod_name) - val java = if (project.platform.mcMinor >= 18) { - 17 // If we are playing on version 1.18, set the java version to 17 - } else { - // Else if we are playing on version 1.17, use java 16. - if (project.platform.mcMinor == 17) - 16 - else - 8 // For all previous versions, we **need** java 8 (for Forge support). - } - val compatLevel = "JAVA_${java}" - inputs.property("java", java) - inputs.property("java_level", compatLevel) - inputs.property("version", mod_version) - inputs.property("mcVersionStr", project.platform.mcVersionStr) - filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) { - expand( - mapOf( - "id" to mod_id, - "name" to mod_name, - "java" to java, - "java_level" to compatLevel, - "version" to mod_version, - "mcVersionStr" to project.platform.mcVersionStr - ) - ) - } - filesMatching("fabric.mod.json") { - expand( - mapOf( - "id" to mod_id, - "name" to mod_name, - "java" to java, - "java_level" to compatLevel, - "version" to mod_version, - "mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x" - ) - ) + for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) { + +module } } - // Configures the resources to include if we are building for forge or fabric. - withType(Jar::class.java) { - if (project.platform.isFabric) { - exclude("mcmod.info", "mods.toml") - } else { - exclude("fabric.mod.json") - if (project.platform.isLegacyForge) { - exclude("mods.toml") - } else { - exclude("mcmod.info") - } - } - } + // Turns off the server-side run configs, as we're building a client-sided mod. + disableRunConfigs(GameSide.SERVER) - // Configures our shadow/shade configuration, so we can - // include some dependencies within our mod jar file. - named("shadowJar") { - archiveClassifier.set("dev") - configurations = listOf(shade, modShade) - duplicatesStrategy = DuplicatesStrategy.EXCLUDE + // Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes. + if (!mcData.isNeoForge) { + useMixinRefMap(modData.id) } - remapJar { - inputFile.set(shadowJar.get().archiveFile) - archiveClassifier.set("") + if (mcData.isForge) { + // Configures the Mixin tweaker if we are building for Forge. + useForgeMixin(modData.id) } - jar { - // Sets the jar manifest attributes. - if (platform.isLegacyForge) { - manifest.attributes += mapOf( - "ModSide" to "CLIENT", // We aren't developing a server-side mod - "ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so. - "TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible. - "MixinConfigs" to "mixins.${mod_id}.json", // We want to use our mixin configuration, so we specify it here. - "TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper. - ) - } - dependsOn(shadowJar) - archiveClassifier.set("") - enabled = false + // Sets up the KotlinForForge library for Forge 1.16.5+ and NeoForge. + if (mcData.isForgeLike && mcData.version >= MinecraftVersion.VERSION_1_16_5) { + useKotlinForForge() } } diff --git a/gradle.properties b/gradle.properties index f8f0b3b..41a8546 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,17 @@ -# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod_*` AND REMOVE THIS COMMENT. - -# Sets the name of your mod. -mod_name=ExampleMod -# Sets the id of your mod that mod loaders use to recognize it. -mod_id=examplemod -# Sets the version of your mod. Make sure to update this when you make changes according to semver. -mod_version=1.0.0 -# Sets the name of the jar file that you put in your 'mods' folder. -mod_archives_name=ExampleMod - # Gradle Configuration -- DO NOT TOUCH THESE VALUES. -polyfrost.defaults.loom=3 org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureoncommand=true org.gradle.parallel.threads=4 -org.gradle.jvmargs=-Xmx2G \ No newline at end of file +org.gradle.jvmargs=-Xmx2G + +# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod.*` AND REMOVE THIS COMMENT. + +# Sets the name of your mod. +mod.name=ExampleMod +# Sets the ID of your mod that mod loaders use to recognize it. +mod.id=examplemod +# Sets the version of your mod. Make sure to update this when you make changes according to the SemVer specification. +mod.version=1.0.0 +# Sets the Maven group ID of your mod. This is effectively unused but is good practice to set regardless. +mod.group=com.example diff --git a/root.gradle.kts b/root.gradle.kts index 5488cd7..25f5d68 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -1,11 +1,14 @@ plugins { - kotlin("jvm") version "1.9.10" apply false - id("org.polyfrost.multi-version.root") - id("com.github.johnrengelman.shadow") version "8.1.1" apply false + id("dev.deftu.gradle.multiversion-root") } preprocess { - "1.12.2-forge"(11202, "srg") { - "1.8.9-forge"(10809, "srg") - } -} \ No newline at end of file + // Adding new versions/loaders can be done like so: + // For each version, we add a new wrapper around the last from highest to lowest. + // Each mod loader needs to link up to the previous version's mod loader so that the mappings can be processed from the previous version. + // "1.12.2-forge"(11202, "srg") { + // "1.8.9-forge"(10809, "srg") + // } + + "1.8.9-forge"(10809, "srg") +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 9e578e6..ba41521 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,27 +1,47 @@ @file:Suppress("PropertyName") +import groovy.lang.MissingPropertyException + pluginManagement { repositories { + // Releases + maven("https://maven.deftu.dev/releases") + maven("https://maven.fabricmc.net") + maven("https://maven.architectury.dev/") + maven("https://maven.minecraftforge.net") + maven("https://repo.essential.gg/repository/maven-public") + maven("https://server.bbkr.space/artifactory/libs-release/") + maven("https://jitpack.io/") + + // Snapshots + maven("https://maven.deftu.dev/snapshots") + mavenLocal() + + // Default gradlePluginPortal() mavenCentral() - maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit } + plugins { - val pgtVersion = "0.6.5" // Sets the default versions for Polyfrost Gradle Toolkit - id("org.polyfrost.multi-version.root") version pgtVersion + kotlin("jvm") version("2.0.0") + id("dev.deftu.gradle.multiversion-root") version("2.17.0") } } -val mod_name: String by settings +val projectName: String = extra["mod.name"]?.toString() + ?: throw MissingPropertyException("mod.name has not been set.") // Configures the root project Gradle name based on the value in `gradle.properties` -rootProject.name = mod_name +rootProject.name = projectName rootProject.buildFileName = "root.gradle.kts" // Adds all of our build target versions to the classpath if we need to add version-specific code. +// Update this list if you want to remove/add a version and/or mod loader. +// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc) +// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S). listOf( - "1.8.9-forge", // Update this if you want to remove/add a version, along with `build.gradle.kts` and `root.gradle.kts`. - //"1.12.2-forge" // uncomment if you want 1.12.2 support in your mod + "1.8.9-forge", + // ... ).forEach { version -> include(":$version") project(":$version").apply { diff --git a/src/main/java/org/polyfrost/example/ExampleMod.java b/src/main/java/org/polyfrost/example/ExampleMod.java index 043a208..3602126 100644 --- a/src/main/java/org/polyfrost/example/ExampleMod.java +++ b/src/main/java/org/polyfrost/example/ExampleMod.java @@ -1,33 +1,39 @@ package org.polyfrost.example; import org.polyfrost.example.command.ExampleCommand; -import org.polyfrost.example.config.TestConfig; -import cc.polyfrost.oneconfig.events.event.InitializationEvent; +import org.polyfrost.example.config.ExampleConfig; import net.minecraftforge.fml.common.Mod; -import cc.polyfrost.oneconfig.utils.commands.CommandManager; import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import org.polyfrost.oneconfig.api.commands.v1.CommandManager; /** - * The entrypoint of the Example Mod that initializes it. + * The entrypoint of the Example Mod which initializes it. + * This is what is run when the game is started and typically how your mod will set up its functionality. * * @see Mod - * @see InitializationEvent */ -@Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION) +@Mod(modid = ExampleMod.ID, name = ExampleMod.NAME, version = ExampleMod.VERSION) public class ExampleMod { - // Sets the variables from `gradle.properties`. See the `blossom` config in `build.gradle.kts`. - public static final String MODID = "@ID@"; - public static final String NAME = "@NAME@"; - public static final String VERSION = "@VER@"; - @Mod.Instance(MODID) + // Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin. + public static final String ID = "@MOD_ID@"; + public static final String NAME = "@MOD_NAME@"; + public static final String VERSION = "@MOD_VERSION@"; + + @Mod.Instance(ID) public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables. - public static TestConfig config; + + private static ExampleConfig config; // Register the config and commands. @Mod.EventHandler public void onInit(FMLInitializationEvent event) { - config = new TestConfig(); - CommandManager.INSTANCE.registerCommand(new ExampleCommand()); + config = new ExampleConfig(); + CommandManager.registerCommand(new ExampleCommand()); } + + public static ExampleConfig getConfig() { + return config; + } + } diff --git a/src/main/java/org/polyfrost/example/command/ExampleCommand.java b/src/main/java/org/polyfrost/example/command/ExampleCommand.java index b4373a3..5124219 100644 --- a/src/main/java/org/polyfrost/example/command/ExampleCommand.java +++ b/src/main/java/org/polyfrost/example/command/ExampleCommand.java @@ -12,7 +12,7 @@ * @see Main * @see ExampleMod */ -@Command(value = ExampleMod.MODID, description = "Access the " + ExampleMod.NAME + " GUI.") +@Command(value = ExampleMod.ID, description = "Access the " + ExampleMod.NAME + " GUI.") public class ExampleCommand { @Main private void handle() { diff --git a/src/main/java/org/polyfrost/example/config/ExampleConfig.java b/src/main/java/org/polyfrost/example/config/ExampleConfig.java new file mode 100644 index 0000000..f73c499 --- /dev/null +++ b/src/main/java/org/polyfrost/example/config/ExampleConfig.java @@ -0,0 +1,36 @@ +package org.polyfrost.example.config; + +import org.polyfrost.example.ExampleMod; +import org.polyfrost.oneconfig.api.config.v1.Config; +import org.polyfrost.oneconfig.api.config.v1.annotations.Dropdown; +import org.polyfrost.oneconfig.api.config.v1.annotations.Slider; +import org.polyfrost.oneconfig.api.config.v1.annotations.Switch; + +/** + * The main Config entrypoint that extends the Config type and initializes your config options. + * See this link for more config Options + */ +public class ExampleConfig extends Config { + + @Switch(title = "Example Switch") + public static boolean exampleSwitch = false; // The default value for the boolean Switch. + + @Slider( + title = "Example Slider", + min = 0f, max = 100f, // Minimum and maximum values for the slider. + step = 10 // The amount of steps that the slider should have. + ) + public static float exampleSlider = 50f; // The default value for the float Slider. + + @Dropdown( + title = "Example Dropdown", // Name of the Dropdown + options = {"Option 1", "Option 2", "Option 3", "Option 4"} // Options available. + ) + public static int exampleDropdown = 1; // Default option (in this case "Option 2") + + public ExampleConfig() { + super(ExampleMod.ID + ".json", ExampleMod.NAME, Category.OTHER); // TODO: Change your category here. + } + +} + diff --git a/src/main/java/org/polyfrost/example/config/TestConfig.java b/src/main/java/org/polyfrost/example/config/TestConfig.java deleted file mode 100644 index a4cc343..0000000 --- a/src/main/java/org/polyfrost/example/config/TestConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.polyfrost.example.config; - -import org.polyfrost.example.ExampleMod; -import org.polyfrost.example.hud.TestHud; -import cc.polyfrost.oneconfig.config.Config; -import cc.polyfrost.oneconfig.config.annotations.Dropdown; -import cc.polyfrost.oneconfig.config.annotations.HUD; -import cc.polyfrost.oneconfig.config.annotations.Slider; -import cc.polyfrost.oneconfig.config.annotations.Switch; -import cc.polyfrost.oneconfig.config.data.Mod; -import cc.polyfrost.oneconfig.config.data.ModType; -import cc.polyfrost.oneconfig.config.data.OptionSize; - -/** - * The main Config entrypoint that extends the Config type and inits the config options. - * See this link for more config Options - */ -public class TestConfig extends Config { - @HUD( - name = "Example HUD" - ) - public TestHud hud = new TestHud(); - - @Switch( - name = "Example Switch", - size = OptionSize.SINGLE // Optional - ) - public static boolean exampleSwitch = false; // The default value for the boolean Switch. - - @Slider( - name = "Example Slider", - min = 0f, max = 100f, // Minimum and maximum values for the slider. - step = 10 // The amount of steps that the slider should have. - ) - public static float exampleSlider = 50f; // The default value for the float Slider. - - @Dropdown( - name = "Example Dropdown", // Name of the Dropdown - options = {"Option 1", "Option 2", "Option 3", "Option 4"} // Options available. - ) - public static int exampleDropdown = 1; // Default option (in this case "Option 2") - - public TestConfig() { - super(new Mod(ExampleMod.NAME, ModType.UTIL_QOL), ExampleMod.MODID + ".json"); - initialize(); - } -} - diff --git a/src/main/java/org/polyfrost/example/hud/ExampleHud.java b/src/main/java/org/polyfrost/example/hud/ExampleHud.java new file mode 100644 index 0000000..e2891b5 --- /dev/null +++ b/src/main/java/org/polyfrost/example/hud/ExampleHud.java @@ -0,0 +1,5 @@ +package org.polyfrost.example.hud; + +// TODO: for nextdayy +public class ExampleHud { +} diff --git a/src/main/java/org/polyfrost/example/hud/TestHud.java b/src/main/java/org/polyfrost/example/hud/TestHud.java deleted file mode 100644 index cd0dfa7..0000000 --- a/src/main/java/org/polyfrost/example/hud/TestHud.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.polyfrost.example.hud; - -import cc.polyfrost.oneconfig.hud.SingleTextHud; -import org.polyfrost.example.config.TestConfig; - -/** - * An example OneConfig HUD that is started in the config and displays text. - * - * @see TestConfig#hud - */ -public class TestHud extends SingleTextHud { - public TestHud() { - super("Test", true); - } - - @Override - public String getText(boolean example) { - return "I'm an example HUD"; - } -} diff --git a/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java b/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java index cc1304c..8aaa091 100644 --- a/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java +++ b/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java @@ -7,15 +7,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; /** - * An example mixin using SpongePowered's Mixin library + * An example Mixin using SpongePowered's Mixin library * - * @see Inject * @see Mixin + * @see Inject */ @Mixin(Minecraft.class) public class MinecraftMixin { + @Inject(method = "startGame", at = @At(value = "HEAD")) - private void onStartGame(CallbackInfo ci) { - System.out.println("This is a message from an example mod!"); + private void examplemod$onStartGame(CallbackInfo ci) { + System.out.println("This is a message from the example mod!"); } + } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 9028106..76001f3 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,10 +1,10 @@ [ { - "modid": "${id}", - "name": "${name}", + "modid": "${mod_id}", + "name": "${mod_name}", "description": "", - "version": "${version}", - "mcversion": "${mcVersionStr}", + "version": "${mod_version}", + "mcversion": "${mc_version}", "url": "", "updateUrl": "", "authorList": [ diff --git a/src/main/resources/mixins.examplemod.json b/src/main/resources/mixins.examplemod.json index c5a6f21..8a18b95 100644 --- a/src/main/resources/mixins.examplemod.json +++ b/src/main/resources/mixins.examplemod.json @@ -1,8 +1,8 @@ { - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "${java_version}", "minVersion": "0.7", "package": "org.polyfrost.example.mixin", - "refmap": "mixins.${id}.refmap.json", + "refmap": "mixins.${mod_id}.refmap.json", "injectors": { "maxShiftBy": 5 }, From c6739554e0e84825889de6293bce69e8cbd69286 Mon Sep 17 00:00:00 2001 From: Deftu Date: Mon, 30 Dec 2024 15:40:30 +0200 Subject: [PATCH 02/14] dgt single version examplemod yeah --- build.gradle.kts | 22 ++++++++-------------- gradle.properties | 5 +++++ root.gradle.kts | 14 -------------- settings.gradle.kts | 21 --------------------- versions/mainProject | 1 - 5 files changed, 13 insertions(+), 50 deletions(-) delete mode 100644 root.gradle.kts delete mode 100644 versions/mainProject diff --git a/build.gradle.kts b/build.gradle.kts index 1b61606..d5590a3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,18 +1,17 @@ @file:Suppress("UnstableApiUsage", "PropertyName") import dev.deftu.gradle.utils.GameSide -import dev.deftu.gradle.utils.MinecraftVersion plugins { java - kotlin("jvm") - id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders. - id("dev.deftu.gradle.tools") // Applies several configurations to things such as the Java version, project name/version, etc. - id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources. - id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files. - id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those! - id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you. - id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth. + kotlin("jvm") version("2.0.0") + val dgtVersion = "2.17.0" + id("dev.deftu.gradle.tools") version(dgtVersion) // Applies several configurations to things such as the Java version, project name/version, etc. + id("dev.deftu.gradle.tools.resources") version(dgtVersion) // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources. + id("dev.deftu.gradle.tools.bloom") version(dgtVersion) // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files. + id("dev.deftu.gradle.tools.shadow") version(dgtVersion) // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those! + id("dev.deftu.gradle.tools.minecraft.loom") version(dgtVersion) // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you. + id("dev.deftu.gradle.tools.minecraft.releases") version(dgtVersion) // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth. } toolkitLoomHelper { @@ -42,9 +41,4 @@ toolkitLoomHelper { // Configures the Mixin tweaker if we are building for Forge. useForgeMixin(modData.id) } - - // Sets up the KotlinForForge library for Forge 1.16.5+ and NeoForge. - if (mcData.isForgeLike && mcData.version >= MinecraftVersion.VERSION_1_16_5) { - useKotlinForForge() - } } diff --git a/gradle.properties b/gradle.properties index 41a8546..714ffe4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,3 +15,8 @@ mod.id=examplemod mod.version=1.0.0 # Sets the Maven group ID of your mod. This is effectively unused but is good practice to set regardless. mod.group=com.example + +# Configures the mod loader that we're developing for. +loom.platform=forge +# Configures the Minecraft version that we're developing for. +minecraft.version=1.8.9 diff --git a/root.gradle.kts b/root.gradle.kts deleted file mode 100644 index 25f5d68..0000000 --- a/root.gradle.kts +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id("dev.deftu.gradle.multiversion-root") -} - -preprocess { - // Adding new versions/loaders can be done like so: - // For each version, we add a new wrapper around the last from highest to lowest. - // Each mod loader needs to link up to the previous version's mod loader so that the mappings can be processed from the previous version. - // "1.12.2-forge"(11202, "srg") { - // "1.8.9-forge"(10809, "srg") - // } - - "1.8.9-forge"(10809, "srg") -} diff --git a/settings.gradle.kts b/settings.gradle.kts index ba41521..8c087b2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,11 +21,6 @@ pluginManagement { gradlePluginPortal() mavenCentral() } - - plugins { - kotlin("jvm") version("2.0.0") - id("dev.deftu.gradle.multiversion-root") version("2.17.0") - } } val projectName: String = extra["mod.name"]?.toString() @@ -33,19 +28,3 @@ val projectName: String = extra["mod.name"]?.toString() // Configures the root project Gradle name based on the value in `gradle.properties` rootProject.name = projectName -rootProject.buildFileName = "root.gradle.kts" - -// Adds all of our build target versions to the classpath if we need to add version-specific code. -// Update this list if you want to remove/add a version and/or mod loader. -// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc) -// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S). -listOf( - "1.8.9-forge", - // ... -).forEach { version -> - include(":$version") - project(":$version").apply { - projectDir = file("versions/$version") - buildFileName = "../../build.gradle.kts" - } -} diff --git a/versions/mainProject b/versions/mainProject deleted file mode 100644 index dd1433e..0000000 --- a/versions/mainProject +++ /dev/null @@ -1 +0,0 @@ -1.8.9-forge \ No newline at end of file From 625dc32a5b184ac2e9a5b2750929b0496c137cb8 Mon Sep 17 00:00:00 2001 From: Deftu Date: Mon, 30 Dec 2024 15:49:07 +0200 Subject: [PATCH 03/14] Port ExampleCommand (I forgor) --- .../polyfrost/example/command/ExampleCommand.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/polyfrost/example/command/ExampleCommand.java b/src/main/java/org/polyfrost/example/command/ExampleCommand.java index 5124219..57427bc 100644 --- a/src/main/java/org/polyfrost/example/command/ExampleCommand.java +++ b/src/main/java/org/polyfrost/example/command/ExampleCommand.java @@ -1,21 +1,22 @@ package org.polyfrost.example.command; import org.polyfrost.example.ExampleMod; -import cc.polyfrost.oneconfig.utils.commands.annotations.Command; -import cc.polyfrost.oneconfig.utils.commands.annotations.Main; +import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; +import org.polyfrost.oneconfig.utils.v1.dsl.ScreensKt; /** * An example command implementing the Command api of OneConfig. * Registered in ExampleMod.java with `CommandManager.INSTANCE.registerCommand(new ExampleCommand());` * * @see Command - * @see Main * @see ExampleMod */ @Command(value = ExampleMod.ID, description = "Access the " + ExampleMod.NAME + " GUI.") public class ExampleCommand { - @Main + + @Command private void handle() { - ExampleMod.INSTANCE.config.openGui(); + ScreensKt.openUI(ExampleMod.getConfig()); } -} \ No newline at end of file + +} From 2d2c716b50c88bc21c92b69563421c9d28776c65 Mon Sep 17 00:00:00 2001 From: Deftu Date: Mon, 30 Dec 2024 16:50:18 +0200 Subject: [PATCH 04/14] Update ExampleCommand.java --- src/main/java/org/polyfrost/example/command/ExampleCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/polyfrost/example/command/ExampleCommand.java b/src/main/java/org/polyfrost/example/command/ExampleCommand.java index 57427bc..6cb6c1d 100644 --- a/src/main/java/org/polyfrost/example/command/ExampleCommand.java +++ b/src/main/java/org/polyfrost/example/command/ExampleCommand.java @@ -15,7 +15,7 @@ public class ExampleCommand { @Command - private void handle() { + private void main() { ScreensKt.openUI(ExampleMod.getConfig()); } From 9c6f916d3f505858a0fe1d43b84cda214ebeaf9e Mon Sep 17 00:00:00 2001 From: ev chang Date: Tue, 31 Dec 2024 21:03:28 +0900 Subject: [PATCH 05/14] Update OneConfig + other things --- README.md | 8 +-- build.gradle.kts | 6 ++- gradle.properties | 2 +- .../example/config/ExampleConfig.java | 2 +- .../example/mixin/MinecraftMixin.java | 2 +- update-to-301a6ca.md | 51 ------------------- update-to-fd8e095.md | 21 -------- 7 files changed, 8 insertions(+), 84 deletions(-) delete mode 100644 update-to-301a6ca.md delete mode 100644 update-to-fd8e095.md diff --git a/README.md b/README.md index f5fd532..55e1a4e 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,4 @@ Example mod implementing OneConfig. - **Remove the license named "LICENSE-TEMPLATE" and choose a new one.** - Refactor the template (specifically, the modid, version and name in the gradle.properties and most of the class names) to a different name. -- Have fun modding! :D - -## Need to update to a newer commit of this template? - -Check out these update guides: -- [Updating to commit `fd8e095`](update-to-fd8e095.md) (most recent update) -- [Updating to commit `301a6ca`](update-to-301a6ca.md) \ No newline at end of file +- Have fun modding! :D \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index d5590a3..e8699fe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,8 +16,8 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.47" - loaderVersion = "1.1.0-alpha.34" + version = "1.0.0-alpha.49" + loaderVersion = "1.1.0-alpha.35" usePolyMixin = true polyMixinVersion = "0.8.4+build.2" @@ -28,6 +28,8 @@ toolkitLoomHelper { +module } } + useDevAuth("1.2.1") + useMixinExtras("0.4.1") // Turns off the server-side run configs, as we're building a client-sided mod. disableRunConfigs(GameSide.SERVER) diff --git a/gradle.properties b/gradle.properties index 714ffe4..0ddc67f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ mod.id=examplemod # Sets the version of your mod. Make sure to update this when you make changes according to the SemVer specification. mod.version=1.0.0 # Sets the Maven group ID of your mod. This is effectively unused but is good practice to set regardless. -mod.group=com.example +mod.group=org.polyfrost # Configures the mod loader that we're developing for. loom.platform=forge diff --git a/src/main/java/org/polyfrost/example/config/ExampleConfig.java b/src/main/java/org/polyfrost/example/config/ExampleConfig.java index f73c499..0ea12a3 100644 --- a/src/main/java/org/polyfrost/example/config/ExampleConfig.java +++ b/src/main/java/org/polyfrost/example/config/ExampleConfig.java @@ -8,7 +8,7 @@ /** * The main Config entrypoint that extends the Config type and initializes your config options. - * See this link for more config Options + * See this link for more config Options */ public class ExampleConfig extends Config { diff --git a/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java b/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java index 8aaa091..b109546 100644 --- a/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java +++ b/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java @@ -15,7 +15,7 @@ @Mixin(Minecraft.class) public class MinecraftMixin { - @Inject(method = "startGame", at = @At(value = "HEAD")) + @Inject(method = "", at = @At(value = "RETURN")) private void examplemod$onStartGame(CallbackInfo ci) { System.out.println("This is a message from the example mod!"); } diff --git a/update-to-301a6ca.md b/update-to-301a6ca.md deleted file mode 100644 index 74f3894..0000000 --- a/update-to-301a6ca.md +++ /dev/null @@ -1,51 +0,0 @@ -# Updating to commit [`301a6ca`](https://github.com/Polyfrost/OneConfigExampleMod/commit/301a6cae2fc9b62d00e968b05eb689f3175c5f79) - -If you don't care to check the commit and manually apply everything, here are all the changes we made in that commit: - -## build.gradle.kts - -![Screenshot 2024-06-17 at 5 24 13 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/830faef9-bb86-4279-86d5-b9b7f837d1af) - -Updates blossom to 1.3.2 (what this template uses to automatically replace mentions of mod_id, mod_ver, etc. with the values in `gradle.properties`. unofficial Polyfrost update fixing Kotlin 1.9.x support), and removes unnecessary preprocessor variable (it's already included by PGT) - -## gradle.properties - -![Screenshot 2024-06-17 at 5 27 35 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/a170663b-2449-4043-9be3-865e982387c9) - -Updates `polyfrost.defaults.loom` (PGT's "loom revision," aka what mappings the mod uses) to `3`. This won't really affect anyone outside of modern version users, but this is just good practice. - -## gradle/wrapper/gradle-wrapper.properties - -![Screenshot 2024-06-17 at 5 29 02 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/ff423c15-1339-47bc-8435-e05d15181b32) - -Updates Gradle to 8.8. - -### IMPORTANT!! - -This Gradle update is why some other gradle-related files in this project (`gradle-wrapper.jar`, `gradlew` and `gradlew.bat`) changed. Obviously, it would be a bit inconvenient to apply the changes to those files manually, so here's what you do to properly apply the new changes: - -1. Apply the rest of the changes in this document -2. Temporarily change `gradle/wrapper/gradle-wrapper.properties` to gradle 8.6 or 8.7. This is necessary because in order for Loom to function, 8.6 or higher is required. -3. Reload the Gradle project -4. Run `gradle wrapper --gradle-version 8.8` in Terminal or through your IDE (IntelliJ users can run this through the following method:) -![Screenshot 2024-06-17 at 5 33 24 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/8df43b0f-485d-4f4b-a288-f4db2c4521fe) -![Screenshot 2024-06-17 at 5 34 05 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/0d7b0598-d486-4fa4-af07-f72b2ab77966) -5. Done! - -## root.gradle.kts - -![Screenshot 2024-06-17 at 5 35 02 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/b4622399-6548-47ef-9724-cfe5f2785243) - -Updates shadow (what Gradle uses to shade dependencies) to 8.1.1. - -## settings.gradle.kts - -![Screenshot 2024-06-17 at 5 36 43 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/88252eb9-3aeb-48c4-b7f0-ec1553d999a3) - -Updates PGT to 0.6.2 (which updates loom), and comments out 1.12.2 support in case people don't want it. - -## src/resources/mcmod.info - -![Screenshot 2024-06-17 at 5 38 49 AM](https://github.com/Polyfrost/OneConfigExampleMod/assets/45589059/bb721a82-edd8-4a2e-8678-3b53f3741671) - -Makes sure the `mcversion` field in `mcmod.info` is updated to the actual Minecraft version (in this case, either 1.8.9 or 1.12.2) diff --git a/update-to-fd8e095.md b/update-to-fd8e095.md deleted file mode 100644 index cd1e766..0000000 --- a/update-to-fd8e095.md +++ /dev/null @@ -1,21 +0,0 @@ -# Updating to commit [`fd8e095`](https://github.com/Polyfrost/OneConfigExampleMod/commit/fd8e095b2964eb0264c59d573ee3b0ca0855847f) - -If you don't care to check the commit and manually apply everything, here are all the changes we made in that commit: - -## build.gradle.kts - -Screenshot 2024-07-06 at 9 19 02 PM - -Updates and forces OneConfig Wrapper (what is used to download and load OneConfig automatically) to 1.0.0-beta17 (fixes SSL / antivirus detections) - -## src/main/resources/mixins.examplemod.json - -Screenshot 2024-07-06 at 9 20 43 PM - -Fixes the mixin json refmap not reflecting the mod id that is set in `gradle.properties`. - -## settings.gradle.kts - -Screenshot 2024-07-14 at 8 30 40 PM - -Updates PGT and Loom to 0.6.5 From f66d94302d9f19d64f8bad63f7bf4359c4dddea2 Mon Sep 17 00:00:00 2001 From: ev chang Date: Tue, 31 Dec 2024 21:06:07 +0900 Subject: [PATCH 06/14] update gh action --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db54b04..62008db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,17 +19,17 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 10 - name: Set up JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: - java-version: 17 + java-version: 21 distribution: temurin - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: path: | ~/.gradle/caches From 3985a21644f553b809da77f27cff4b2af6b2ad4a Mon Sep 17 00:00:00 2001 From: ev chang Date: Wed, 1 Jan 2025 15:29:22 +0900 Subject: [PATCH 07/14] update mixin min version --- src/main/resources/mixins.examplemod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mixins.examplemod.json b/src/main/resources/mixins.examplemod.json index 8a18b95..9f9d8c5 100644 --- a/src/main/resources/mixins.examplemod.json +++ b/src/main/resources/mixins.examplemod.json @@ -1,6 +1,6 @@ { "compatibilityLevel": "${java_version}", - "minVersion": "0.7", + "minVersion": "0.8", "package": "org.polyfrost.example.mixin", "refmap": "mixins.${mod_id}.refmap.json", "injectors": { From 17121e4249124b2298aeaffdb8351d947ba98778 Mon Sep 17 00:00:00 2001 From: ev chang Date: Wed, 1 Jan 2025 15:35:07 +0900 Subject: [PATCH 08/14] put instance of config in the config class --- src/main/java/org/polyfrost/example/ExampleMod.java | 9 +-------- .../org/polyfrost/example/command/ExampleCommand.java | 3 ++- .../java/org/polyfrost/example/config/ExampleConfig.java | 2 ++ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/polyfrost/example/ExampleMod.java b/src/main/java/org/polyfrost/example/ExampleMod.java index 3602126..ac07539 100644 --- a/src/main/java/org/polyfrost/example/ExampleMod.java +++ b/src/main/java/org/polyfrost/example/ExampleMod.java @@ -23,17 +23,10 @@ public class ExampleMod { @Mod.Instance(ID) public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables. - private static ExampleConfig config; - // Register the config and commands. @Mod.EventHandler public void onInit(FMLInitializationEvent event) { - config = new ExampleConfig(); + ExampleConfig.INSTANCE.preload(); CommandManager.registerCommand(new ExampleCommand()); } - - public static ExampleConfig getConfig() { - return config; - } - } diff --git a/src/main/java/org/polyfrost/example/command/ExampleCommand.java b/src/main/java/org/polyfrost/example/command/ExampleCommand.java index 6cb6c1d..62a4cb4 100644 --- a/src/main/java/org/polyfrost/example/command/ExampleCommand.java +++ b/src/main/java/org/polyfrost/example/command/ExampleCommand.java @@ -1,6 +1,7 @@ package org.polyfrost.example.command; import org.polyfrost.example.ExampleMod; +import org.polyfrost.example.config.ExampleConfig; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; import org.polyfrost.oneconfig.utils.v1.dsl.ScreensKt; @@ -16,7 +17,7 @@ public class ExampleCommand { @Command private void main() { - ScreensKt.openUI(ExampleMod.getConfig()); + ScreensKt.openUI(ExampleConfig.INSTANCE); } } diff --git a/src/main/java/org/polyfrost/example/config/ExampleConfig.java b/src/main/java/org/polyfrost/example/config/ExampleConfig.java index 0ea12a3..e865ef4 100644 --- a/src/main/java/org/polyfrost/example/config/ExampleConfig.java +++ b/src/main/java/org/polyfrost/example/config/ExampleConfig.java @@ -28,6 +28,8 @@ public class ExampleConfig extends Config { ) public static int exampleDropdown = 1; // Default option (in this case "Option 2") + public static final ExampleConfig INSTANCE = new ExampleConfig(); // The instance of the config. + public ExampleConfig() { super(ExampleMod.ID + ".json", ExampleMod.NAME, Category.OTHER); // TODO: Change your category here. } From a4f27a994f8bd97ccc7026467228acee4c80623f Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 9 Jan 2025 09:13:15 -0500 Subject: [PATCH 09/14] Update build.gradle.kts --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index e8699fe..5190361 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.49" + version = "1.0.0-alpha.55" loaderVersion = "1.1.0-alpha.35" usePolyMixin = true From 8de6a4b0bcc8740d7e557aacd54c41bb1f780a4e Mon Sep 17 00:00:00 2001 From: Deftu Date: Sat, 18 Jan 2025 00:37:53 +0200 Subject: [PATCH 10/14] Bump OneConfig loader version --- build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5190361..49c0e6a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ plugins { toolkitLoomHelper { useOneConfig { version = "1.0.0-alpha.55" - loaderVersion = "1.1.0-alpha.35" + loaderVersion = "1.1.0-alpha.38" usePolyMixin = true polyMixinVersion = "0.8.4+build.2" @@ -28,6 +28,7 @@ toolkitLoomHelper { +module } } + useDevAuth("1.2.1") useMixinExtras("0.4.1") From aaab2101b0c95dbc37bfa89cfcb9654542214a81 Mon Sep 17 00:00:00 2001 From: Deftu Date: Sat, 18 Jan 2025 00:46:17 +0200 Subject: [PATCH 11/14] Reorganize according to new Polyfrost code guidelines. --- .../polyfrost/example/ExampleConstants.java | 10 ++++++ .../org/polyfrost/example/ExampleMod.java | 32 ------------------- .../example/client/ExampleClient.java | 20 ++++++++++++ .../{command => client}/ExampleCommand.java | 9 +++--- .../{config => client}/ExampleConfig.java | 6 ++-- .../example/{hud => client}/ExampleHud.java | 2 +- 6 files changed, 38 insertions(+), 41 deletions(-) create mode 100644 src/main/java/org/polyfrost/example/ExampleConstants.java delete mode 100644 src/main/java/org/polyfrost/example/ExampleMod.java create mode 100644 src/main/java/org/polyfrost/example/client/ExampleClient.java rename src/main/java/org/polyfrost/example/{command => client}/ExampleCommand.java (65%) rename src/main/java/org/polyfrost/example/{config => client}/ExampleConfig.java (86%) rename src/main/java/org/polyfrost/example/{hud => client}/ExampleHud.java (57%) diff --git a/src/main/java/org/polyfrost/example/ExampleConstants.java b/src/main/java/org/polyfrost/example/ExampleConstants.java new file mode 100644 index 0000000..f8edd06 --- /dev/null +++ b/src/main/java/org/polyfrost/example/ExampleConstants.java @@ -0,0 +1,10 @@ +package org.polyfrost.example; + +public class ExampleConstants { + + // Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin. + public static final String ID = "@MOD_ID@"; + public static final String NAME = "@MOD_NAME@"; + public static final String VERSION = "@MOD_VERSION@"; + +} diff --git a/src/main/java/org/polyfrost/example/ExampleMod.java b/src/main/java/org/polyfrost/example/ExampleMod.java deleted file mode 100644 index ac07539..0000000 --- a/src/main/java/org/polyfrost/example/ExampleMod.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.polyfrost.example; - -import org.polyfrost.example.command.ExampleCommand; -import org.polyfrost.example.config.ExampleConfig; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import org.polyfrost.oneconfig.api.commands.v1.CommandManager; - -/** - * The entrypoint of the Example Mod which initializes it. - * This is what is run when the game is started and typically how your mod will set up its functionality. - * - * @see Mod - */ -@Mod(modid = ExampleMod.ID, name = ExampleMod.NAME, version = ExampleMod.VERSION) -public class ExampleMod { - - // Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin. - public static final String ID = "@MOD_ID@"; - public static final String NAME = "@MOD_NAME@"; - public static final String VERSION = "@MOD_VERSION@"; - - @Mod.Instance(ID) - public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables. - - // Register the config and commands. - @Mod.EventHandler - public void onInit(FMLInitializationEvent event) { - ExampleConfig.INSTANCE.preload(); - CommandManager.registerCommand(new ExampleCommand()); - } -} diff --git a/src/main/java/org/polyfrost/example/client/ExampleClient.java b/src/main/java/org/polyfrost/example/client/ExampleClient.java new file mode 100644 index 0000000..bcd8cb2 --- /dev/null +++ b/src/main/java/org/polyfrost/example/client/ExampleClient.java @@ -0,0 +1,20 @@ +package org.polyfrost.example.client; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import org.polyfrost.example.ExampleConstants; +import org.polyfrost.oneconfig.api.commands.v1.CommandManager; + +@Mod(modid = ExampleConstants.ID, name = ExampleConstants.NAME, version = ExampleConstants.VERSION) +public class ExampleClient { + + @Mod.Instance(ExampleConstants.ID) + public static ExampleClient INSTANCE; + + @Mod.EventHandler + public void onInit(FMLInitializationEvent event) { + ExampleConfig.INSTANCE.preload(); + CommandManager.registerCommand(new ExampleCommand()); + } + +} diff --git a/src/main/java/org/polyfrost/example/command/ExampleCommand.java b/src/main/java/org/polyfrost/example/client/ExampleCommand.java similarity index 65% rename from src/main/java/org/polyfrost/example/command/ExampleCommand.java rename to src/main/java/org/polyfrost/example/client/ExampleCommand.java index 62a4cb4..14dfa4b 100644 --- a/src/main/java/org/polyfrost/example/command/ExampleCommand.java +++ b/src/main/java/org/polyfrost/example/client/ExampleCommand.java @@ -1,7 +1,6 @@ -package org.polyfrost.example.command; +package org.polyfrost.example.client; -import org.polyfrost.example.ExampleMod; -import org.polyfrost.example.config.ExampleConfig; +import org.polyfrost.example.ExampleConstants; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; import org.polyfrost.oneconfig.utils.v1.dsl.ScreensKt; @@ -10,9 +9,9 @@ * Registered in ExampleMod.java with `CommandManager.INSTANCE.registerCommand(new ExampleCommand());` * * @see Command - * @see ExampleMod + * @see ExampleClient */ -@Command(value = ExampleMod.ID, description = "Access the " + ExampleMod.NAME + " GUI.") +@Command(value = ExampleConstants.ID, description = "Access the " + ExampleConstants.NAME + " GUI.") public class ExampleCommand { @Command diff --git a/src/main/java/org/polyfrost/example/config/ExampleConfig.java b/src/main/java/org/polyfrost/example/client/ExampleConfig.java similarity index 86% rename from src/main/java/org/polyfrost/example/config/ExampleConfig.java rename to src/main/java/org/polyfrost/example/client/ExampleConfig.java index e865ef4..f3acd55 100644 --- a/src/main/java/org/polyfrost/example/config/ExampleConfig.java +++ b/src/main/java/org/polyfrost/example/client/ExampleConfig.java @@ -1,6 +1,6 @@ -package org.polyfrost.example.config; +package org.polyfrost.example.client; -import org.polyfrost.example.ExampleMod; +import org.polyfrost.example.ExampleConstants; import org.polyfrost.oneconfig.api.config.v1.Config; import org.polyfrost.oneconfig.api.config.v1.annotations.Dropdown; import org.polyfrost.oneconfig.api.config.v1.annotations.Slider; @@ -31,7 +31,7 @@ public class ExampleConfig extends Config { public static final ExampleConfig INSTANCE = new ExampleConfig(); // The instance of the config. public ExampleConfig() { - super(ExampleMod.ID + ".json", ExampleMod.NAME, Category.OTHER); // TODO: Change your category here. + super(ExampleConstants.ID + ".json", ExampleConstants.NAME, Category.OTHER); // TODO: Change your category here. } } diff --git a/src/main/java/org/polyfrost/example/hud/ExampleHud.java b/src/main/java/org/polyfrost/example/client/ExampleHud.java similarity index 57% rename from src/main/java/org/polyfrost/example/hud/ExampleHud.java rename to src/main/java/org/polyfrost/example/client/ExampleHud.java index e2891b5..75f9ac3 100644 --- a/src/main/java/org/polyfrost/example/hud/ExampleHud.java +++ b/src/main/java/org/polyfrost/example/client/ExampleHud.java @@ -1,4 +1,4 @@ -package org.polyfrost.example.hud; +package org.polyfrost.example.client; // TODO: for nextdayy public class ExampleHud { From 6372b6bbbb89ce5210ef77e2e8261b538ab3da3a Mon Sep 17 00:00:00 2001 From: Deftu Date: Sat, 25 Jan 2025 09:53:43 +0200 Subject: [PATCH 12/14] Bump DGT, OneConfig and OneConfig loader --- build.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 49c0e6a..189682f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ import dev.deftu.gradle.utils.GameSide plugins { java kotlin("jvm") version("2.0.0") - val dgtVersion = "2.17.0" + val dgtVersion = "2.22.0" id("dev.deftu.gradle.tools") version(dgtVersion) // Applies several configurations to things such as the Java version, project name/version, etc. id("dev.deftu.gradle.tools.resources") version(dgtVersion) // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources. id("dev.deftu.gradle.tools.bloom") version(dgtVersion) // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files. @@ -16,8 +16,8 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.55" - loaderVersion = "1.1.0-alpha.38" + version = "1.0.0-alpha.58" + loaderVersion = "1.1.0-alpha.44" usePolyMixin = true polyMixinVersion = "0.8.4+build.2" From 07c5e7c6bed5161707837949caf63fb04289dc83 Mon Sep 17 00:00:00 2001 From: Deftu Date: Wed, 12 Mar 2025 17:02:37 +0200 Subject: [PATCH 13/14] Bump to OneConfig A70 --- build.gradle.kts | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 2 +- src/main/java/org/polyfrost/example/client/ExampleClient.java | 2 +- .../java/org/polyfrost/example/client/ExampleCommand.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 189682f..a61c59b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ import dev.deftu.gradle.utils.GameSide plugins { java kotlin("jvm") version("2.0.0") - val dgtVersion = "2.22.0" + val dgtVersion = "2.27.1" id("dev.deftu.gradle.tools") version(dgtVersion) // Applies several configurations to things such as the Java version, project name/version, etc. id("dev.deftu.gradle.tools.resources") version(dgtVersion) // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources. id("dev.deftu.gradle.tools.bloom") version(dgtVersion) // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files. @@ -16,7 +16,7 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.58" + version = "1.0.0-alpha.70" loaderVersion = "1.1.0-alpha.44" usePolyMixin = true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..e2847c8 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.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..b740cf1 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/src/main/java/org/polyfrost/example/client/ExampleClient.java b/src/main/java/org/polyfrost/example/client/ExampleClient.java index bcd8cb2..8fd4254 100644 --- a/src/main/java/org/polyfrost/example/client/ExampleClient.java +++ b/src/main/java/org/polyfrost/example/client/ExampleClient.java @@ -14,7 +14,7 @@ public class ExampleClient { @Mod.EventHandler public void onInit(FMLInitializationEvent event) { ExampleConfig.INSTANCE.preload(); - CommandManager.registerCommand(new ExampleCommand()); + CommandManager.register(new ExampleCommand()); } } diff --git a/src/main/java/org/polyfrost/example/client/ExampleCommand.java b/src/main/java/org/polyfrost/example/client/ExampleCommand.java index 14dfa4b..acc67d5 100644 --- a/src/main/java/org/polyfrost/example/client/ExampleCommand.java +++ b/src/main/java/org/polyfrost/example/client/ExampleCommand.java @@ -11,7 +11,7 @@ * @see Command * @see ExampleClient */ -@Command(value = ExampleConstants.ID, description = "Access the " + ExampleConstants.NAME + " GUI.") +@Command(ExampleConstants.ID) public class ExampleCommand { @Command From b21b73ec740ded517286f9efda66f2ed775fd93f Mon Sep 17 00:00:00 2001 From: Deftu Date: Wed, 4 Jun 2025 18:51:28 +0200 Subject: [PATCH 14/14] Bring up-to-date --- build.gradle.kts | 12 +++++------- gradle.properties | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a61c59b..452d474 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,8 +4,8 @@ import dev.deftu.gradle.utils.GameSide plugins { java - kotlin("jvm") version("2.0.0") - val dgtVersion = "2.27.1" + kotlin("jvm") version("2.0.10") + val dgtVersion = "2.35.0" id("dev.deftu.gradle.tools") version(dgtVersion) // Applies several configurations to things such as the Java version, project name/version, etc. id("dev.deftu.gradle.tools.resources") version(dgtVersion) // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources. id("dev.deftu.gradle.tools.bloom") version(dgtVersion) // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files. @@ -16,8 +16,8 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.70" - loaderVersion = "1.1.0-alpha.44" + version = "1.0.0-alpha.106" + loaderVersion = "1.1.0-alpha.46" usePolyMixin = true polyMixinVersion = "0.8.4+build.2" @@ -36,9 +36,7 @@ toolkitLoomHelper { disableRunConfigs(GameSide.SERVER) // Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes. - if (!mcData.isNeoForge) { - useMixinRefMap(modData.id) - } + useMixinRefMap(modData.id) if (mcData.isForge) { // Configures the Mixin tweaker if we are building for Forge. diff --git a/gradle.properties b/gradle.properties index 0ddc67f..7cf5e4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,7 @@ org.gradle.parallel=true org.gradle.configureoncommand=true org.gradle.parallel.threads=4 org.gradle.jvmargs=-Xmx2G +loom.ignoreDependencyLoomVersionValidation=true # gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod.*` AND REMOVE THIS COMMENT.