commit 63415c3e4b717121c0f8e72954ef5ad75c97b988 Author: MrMelon54 Date: Wed Jun 14 00:49:07 2023 +0100 First commit and add config options diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d8ed717 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,122 @@ +# Common settings that generally should always be used with your language specific settings + +# Auto detect text files and perform LF normalization +* text=auto + +# +# The above will handle all files NOT found below +# + +# Documents +*.bibtex text diff=bibtex +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain +*.md text diff=markdown +*.mdx text diff=markdown +*.tex text diff=tex +*.adoc text +*.textile text +*.mustache text +*.csv text eol=crlf +*.tab text +*.tsv text +*.txt text +*.sql text +*.epub diff=astextplain + +# Graphics +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.tif binary +*.tiff binary +*.ico binary +# SVG treated as text by default. +*.svg text +# If you want to treat it as binary, +# use the following line instead. +# *.svg binary +*.eps binary + +# Scripts +*.bash text eol=lf +*.fish text eol=lf +*.sh text eol=lf +*.zsh text eol=lf +# These are explicitly windows files and should use crlf +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +# Serialisation +*.json text +*.toml text +*.xml text +*.yaml text +*.yml text + +# Archives +*.7z binary +*.gz binary +*.tar binary +*.tgz binary +*.zip binary + +# Text files where line endings should be preserved +*.patch -text + +# +# Exclude files from exporting +# + +.gitattributes export-ignore +.gitignore export-ignore +.gitkeep export-ignore + +# Java sources +*.java text diff=java +*.kt text diff=kotlin +*.groovy text diff=java +*.scala text diff=java +*.gradle text diff=java +*.gradle.kts text diff=kotlin + +# These files are text and should be normalized (Convert crlf => lf) +*.css text diff=css +*.scss text diff=css +*.sass text +*.df text +*.htm text diff=html +*.html text diff=html +*.js text +*.jsp text +*.jspf text +*.jspx text +*.properties text +*.tld text +*.tag text +*.tagx text +*.xml text + +# These files are binary and should be left untouched +# (binary is a macro for -text -diff) +*.class binary +*.dll binary +*.ear binary +*.jar binary +*.so binary +*.war binary +*.jks binary + +# Common build-tool wrapper scripts ('.cmd' versions are handled by 'Common.gitattributes') +mvnw text eol=lf +gradlew text eol=lf diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..17f0be7 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +ko_fi: mrmelon54 +patreon: mrmelon54 +custom: ["https://www.paypal.me/mrmelon54"] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a16de5b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Java CI + +on: [ push ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "adopt" + + - name: Build + run: ./gradlew build + + - name: Compress + run: tar -czvf upload.tar.gz build/libs/*.jar + + - name: Deploy + if: startsWith(github.ref, 'refs/tags/v') + run: 'curl -X POST -H "Authorization: Bearer ${{ secrets.DEPLOY }}" -F "upload=@upload.tar.gz" https://b.mrmelon54.xyz/u/mc-mod/draggable' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..550b373 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# fabric + +run/ diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e18c048 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + + +This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + +0. Additional Definitions. + +As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + +"The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + +An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + +A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + +The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + +The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + +1. Exception to Section 3 of the GNU GPL. + +You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + +2. Conveying Modified Versions. + +If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + +a) under this License, provided that you make a good faith effort to +ensure that, in the event an Application does not supply the +function or data, the facility still operates, and performs +whatever part of its purpose remains meaningful, or + +b) under the GNU GPL, with none of the additional permissions of +this License applicable to that copy. + +3. Object Code Incorporating Material from Library Header Files. + +The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + +a) Give prominent notice with each copy of the object code that the +Library is used in it and that the Library and its use are +covered by this License. + +b) Accompany the object code with a copy of the GNU GPL and this license +document. + +4. Combined Works. + +You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + +a) Give prominent notice with each copy of the Combined Work that +the Library is used in it and that the Library and its use are +covered by this License. + +b) Accompany the Combined Work with a copy of the GNU GPL and this license +document. + +c) For a Combined Work that displays copyright notices during +execution, include the copyright notice for the Library among +these notices, as well as a reference directing the user to the +copies of the GNU GPL and this license document. + +d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + +e) Provide Installation Information, but only if you would otherwise +be required to provide such information under section 6 of the +GNU GPL, and only to the extent that such information is +necessary to install and execute a modified version of the +Combined Work produced by recombining or relinking the +Application with a modified version of the Linked Version. (If +you use option 4d0, the Installation Information must accompany +the Minimal Corresponding Source and Corresponding Application +Code. If you use option 4d1, you must provide the Installation +Information in the manner specified by section 6 of the GNU GPL +for conveying Corresponding Source.) + +5. Combined Libraries. + +You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + +a) Accompany the combined library with a copy of the same work based +on the Library, uncombined with any other library facilities, +conveyed under the terms of this License. + +b) Give prominent notice with the combined library that part of it +is a work based on the Library, and explaining where to find the +accompanying uncombined form of the same work. + +6. Revised Versions of the GNU Lesser General Public License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..0aec612 --- /dev/null +++ b/build.gradle @@ -0,0 +1,88 @@ +plugins { + id "architectury-plugin" version "3.4-SNAPSHOT" + id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false + id "io.github.pacifistmc.forgix" version "1.2.6" + id "org.ajoberstar.grgit" version "4.1.0" +} + +architectury { + minecraft = rootProject.minecraft_version +} + +subprojects { + apply plugin: "dev.architectury.loom" + + loom { + silentMojangMappingsLicense() + } + + dependencies { + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" + // The following line declares the mojmap mappings, you may use other mappings as well + mappings loom.officialMojangMappings() + // The following line declares the yarn mappings you may select this one as well. + // mappings "net.fabricmc:yarn:1.19.4+build.2:v2" + } + + build.finalizedBy(mergeJars) + assemble.finalizedBy(mergeJars) +} + +allprojects { + apply plugin: "java" + apply plugin: "architectury-plugin" + apply plugin: "maven-publish" + + archivesBaseName = rootProject.archives_base_name + version = rootProject.mod_version + group = rootProject.maven_group + + repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/releases/" } + } + + tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + options.release = 17 + } + + java { + withSourcesJar() + } +} + +forgix { + group = "com.mrmelon54.Draggable" + mergedJarName = "${project.archivesBaseName}-mc${project.minecraft_version}-${project.mod_version}-${getVersionMetadata()}.jar" + outputDir = "build/libs/merged" +} + +def getVersionMetadata() { + def build_id = System.getenv("GITHUB_RUN_NUMBER") + + // CI builds only + if (build_id != null) { + return "build.${build_id}" + } + + if (grgit != null) { + def head = grgit.head() + def id = head.abbreviatedId + + // Flag the build if the build tree is not clean + if (!grgit.status().clean) { + id += "-dirty" + } + + return "rev.${id}" + } + + // No tracking information could be found about the build + return "unknown" +} diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..0a879f7 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,33 @@ +architectury { + common(rootProject.enabled_platforms.split(",")) +} + +loom { + accessWidenerPath = file("src/main/resources/draggable.accesswidener") +} + +dependencies { + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury:${rootProject.architectury_version}" + + modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") + } +} + +publishing { + publications { + mavenCommon(MavenPublication) { + artifactId = rootProject.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/common/src/main/java/com/mrmelon54/Draggable/Draggable.java b/common/src/main/java/com/mrmelon54/Draggable/Draggable.java new file mode 100644 index 0000000..f26a948 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/Draggable/Draggable.java @@ -0,0 +1,27 @@ +package com.mrmelon54.Draggable; + +import com.mrmelon54.Draggable.config.ConfigStructure; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; +import net.minecraft.client.gui.screens.Screen; + +import java.util.List; +import java.util.function.Supplier; + +public class Draggable { + public static final String MOD_ID = "draggable"; + private static ConfigStructure config; + + public static ConfigStructure getConfig() { + return config; + } + + public static void init() { + AutoConfig.register(ConfigStructure.class, JanksonConfigSerializer::new); + config = AutoConfig.getConfigHolder(ConfigStructure.class).getConfig(); + } + + public static Supplier createConfigScreen(Screen screen) { + return AutoConfig.getConfigScreen(ConfigStructure.class, screen); + } +} diff --git a/common/src/main/java/com/mrmelon54/Draggable/ExampleExpectPlatform.java b/common/src/main/java/com/mrmelon54/Draggable/ExampleExpectPlatform.java new file mode 100644 index 0000000..c9cc412 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/Draggable/ExampleExpectPlatform.java @@ -0,0 +1,27 @@ +package com.mrmelon54.Draggable; + +import dev.architectury.injectables.annotations.ExpectPlatform; +import dev.architectury.platform.Platform; + +import java.nio.file.Path; + +public class ExampleExpectPlatform { + /** + * We can use {@link Platform#getConfigFolder()} but this is just an example of {@link ExpectPlatform}. + *

+ * This must be a public static method. The platform-implemented solution must be placed under a + * platform sub-package, with its class suffixed with {@code Impl}. + *

+ * Example: + * Expect: net.examplemod.ExampleExpectPlatform#getConfigDirectory() + * Actual Fabric: net.examplemod.fabric.ExampleExpectPlatformImpl#getConfigDirectory() + * Actual Forge: net.examplemod.forge.ExampleExpectPlatformImpl#getConfigDirectory() + *

+ * You should also get the IntelliJ plugin to help with @ExpectPlatform. + */ + @ExpectPlatform + public static Path getConfigDirectory() { + // Just throw an error, the content should get replaced at runtime. + throw new AssertionError(); + } +} diff --git a/common/src/main/java/com/mrmelon54/Draggable/config/ConfigStructure.java b/common/src/main/java/com/mrmelon54/Draggable/config/ConfigStructure.java new file mode 100644 index 0000000..4b57c0d --- /dev/null +++ b/common/src/main/java/com/mrmelon54/Draggable/config/ConfigStructure.java @@ -0,0 +1,11 @@ +package com.mrmelon54.Draggable.config; + +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; + +@Config(name = "draggable-resource-packs") +@Config.Gui.Background("minecraft:textures/block/brain_coral_block.png") +public class ConfigStructure implements ConfigData { + public boolean disableResourcePackArrows = true; + public boolean disableServerArrows = true; +} diff --git a/common/src/main/java/com/mrmelon54/Draggable/mixin/MixinTitleScreen.java b/common/src/main/java/com/mrmelon54/Draggable/mixin/MixinTitleScreen.java new file mode 100644 index 0000000..1d9ecd7 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/Draggable/mixin/MixinTitleScreen.java @@ -0,0 +1,15 @@ +package com.mrmelon54.Draggable.mixin; + +import net.minecraft.client.gui.screens.TitleScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public class MixinTitleScreen { + @Inject(at = @At("HEAD"), method = "init()V") + private void init(CallbackInfo info) { + System.out.println("Hello from example architectury common mixin!"); + } +} diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json new file mode 100644 index 0000000..413d21f --- /dev/null +++ b/common/src/main/resources/architectury.common.json @@ -0,0 +1,3 @@ +{ + "accessWidener": "draggable.accesswidener" +} diff --git a/common/src/main/resources/assets/draggable/lang/en_us.json b/common/src/main/resources/assets/draggable/lang/en_us.json new file mode 100644 index 0000000..45d1865 --- /dev/null +++ b/common/src/main/resources/assets/draggable/lang/en_us.json @@ -0,0 +1,7 @@ +{ + "text.autoconfig.draggable.title": "Draggable", + "text.autoconfig.draggable.option.disableResourcePackArrows": "Disable Resource Pack Arrows", + "text.autoconfig.draggable.option.disableDatapackArrows": "Disable Datapack Arrows", + "text.autoconfig.draggable.option.disableServerArrows": "Disable Server Arrows", + "text.autoconfig.draggable.option.disableLevelArrows": "Disable Level Arrows" +} diff --git a/common/src/main/resources/draggable-common.mixins.json b/common/src/main/resources/draggable-common.mixins.json new file mode 100644 index 0000000..918eab0 --- /dev/null +++ b/common/src/main/resources/draggable-common.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "com.mrmelon54.Draggable.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + "MixinTitleScreen" + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/common/src/main/resources/draggable.accesswidener b/common/src/main/resources/draggable.accesswidener new file mode 100644 index 0000000..13268c3 --- /dev/null +++ b/common/src/main/resources/draggable.accesswidener @@ -0,0 +1 @@ +accessWidener v2 named \ No newline at end of file diff --git a/common/src/main/resources/icon.png b/common/src/main/resources/icon.png new file mode 100644 index 0000000..248e32d Binary files /dev/null and b/common/src/main/resources/icon.png differ diff --git a/fabric-like/build.gradle b/fabric-like/build.gradle new file mode 100644 index 0000000..f67d67a --- /dev/null +++ b/fabric-like/build.gradle @@ -0,0 +1,16 @@ +architectury { + common(rootProject.enabled_platforms.split(",")) +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" + + compileClasspath(project(path: ":common", configuration: "namedElements")) { transitive false } +} diff --git a/fabric-like/src/main/java/com/mrmelon54/Draggable/fabriclike/DraggableFabricLike.java b/fabric-like/src/main/java/com/mrmelon54/Draggable/fabriclike/DraggableFabricLike.java new file mode 100644 index 0000000..b0bf49c --- /dev/null +++ b/fabric-like/src/main/java/com/mrmelon54/Draggable/fabriclike/DraggableFabricLike.java @@ -0,0 +1,9 @@ +package com.mrmelon54.Draggable.fabriclike; + +import com.mrmelon54.Draggable.Draggable; + +public class DraggableFabricLike { + public static void init() { + Draggable.init(); + } +} diff --git a/fabric-like/src/main/java/com/mrmelon54/Draggable/fabriclike/ModMenuIntegration.java b/fabric-like/src/main/java/com/mrmelon54/Draggable/fabriclike/ModMenuIntegration.java new file mode 100644 index 0000000..0b5fc86 --- /dev/null +++ b/fabric-like/src/main/java/com/mrmelon54/Draggable/fabriclike/ModMenuIntegration.java @@ -0,0 +1,16 @@ +package com.mrmelon54.Draggable.fabriclike; + +import com.mrmelon54.Draggable.config.ConfigStructure; +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import me.shedaniel.autoconfig.AutoConfig; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +@Environment(EnvType.CLIENT) +public class ModMenuIntegration implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> AutoConfig.getConfigScreen(ConfigStructure.class, parent).get(); + } +} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 0000000..887582f --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,91 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +architectury { + platformSetupLoomIde() + fabric() +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" + + modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } + common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false } +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +shadowJar { + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" +} + +remapJar { + injectAccessWidener = true + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenFabric(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/fabric/src/main/java/com/mrmelon54/Draggable/fabric/DraggableFabric.java b/fabric/src/main/java/com/mrmelon54/Draggable/fabric/DraggableFabric.java new file mode 100644 index 0000000..da9409c --- /dev/null +++ b/fabric/src/main/java/com/mrmelon54/Draggable/fabric/DraggableFabric.java @@ -0,0 +1,11 @@ +package com.mrmelon54.Draggable.fabric; + +import com.mrmelon54.Draggable.fabriclike.DraggableFabricLike; +import net.fabricmc.api.ModInitializer; + +public class DraggableFabric implements ModInitializer { + @Override + public void onInitialize() { + DraggableFabricLike.init(); + } +} diff --git a/fabric/src/main/java/com/mrmelon54/Draggable/fabric/ExampleExpectPlatformImpl.java b/fabric/src/main/java/com/mrmelon54/Draggable/fabric/ExampleExpectPlatformImpl.java new file mode 100644 index 0000000..4665090 --- /dev/null +++ b/fabric/src/main/java/com/mrmelon54/Draggable/fabric/ExampleExpectPlatformImpl.java @@ -0,0 +1,15 @@ +package com.mrmelon54.Draggable.fabric; + +import com.mrmelon54.Draggable.ExampleExpectPlatform; +import net.fabricmc.loader.api.FabricLoader; + +import java.nio.file.Path; + +public class ExampleExpectPlatformImpl { + /** + * This is our actual method to {@link ExampleExpectPlatform#getConfigDirectory()}. + */ + public static Path getConfigDirectory() { + return FabricLoader.getInstance().getConfigDir(); + } +} diff --git a/fabric/src/main/resources/draggable.mixins.json b/fabric/src/main/resources/draggable.mixins.json new file mode 100644 index 0000000..672196e --- /dev/null +++ b/fabric/src/main/resources/draggable.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "com.mrmelon54.Draggable.mixin.fabric", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..0999d55 --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,35 @@ +{ + "schemaVersion": 1, + "id": "draggable", + "version": "${version}", + "name": "Draggable", + "description": "Draggable resource packs, datapacks, servers and worlds", + "authors": [ + "MrMelon54" + ], + "contact": { + "homepage": "https://mrmelon54.com/minecraft/draggable", + "sources": "https://github.com/MrMelon54/draggable", + "issues": "https://github.com/MrMelon54/draggable/issues" + }, + "license": "GPL-3.0-only", + "icon": "icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "com.mrmelon54.Draggable.fabric.DraggableFabric" + ], + "modmenu": [ + "com.mrmelon54.Draggable.fabriclike.ModMenuIntegration" + ] + }, + "mixins": [ + "draggable.mixins.json", + "draggable-common.mixins.json" + ], + "depends": { + "fabric": "*", + "minecraft": ">=1.20", + "architectury": ">=9.0.0" + } +} diff --git a/forge/build.gradle b/forge/build.gradle new file mode 100644 index 0000000..a67d039 --- /dev/null +++ b/forge/build.gradle @@ -0,0 +1,91 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +architectury { + platformSetupLoomIde() + forge() +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath + + forge { + convertAccessWideners = true + extraAccessWideners.add loom.accessWidenerPath.get().asFile.name + + mixinConfig "draggable-common.mixins.json" + mixinConfig "draggable.mixins.json" + } +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentForge.extendsFrom common +} + +dependencies { + forge "net.minecraftforge:forge:${rootProject.forge_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}" + + modApi "me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}" + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } +} + +processResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } +} + +shadowJar { + exclude "fabric.mod.json" + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" +} + +remapJar { + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenForge(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/forge/gradle.properties b/forge/gradle.properties new file mode 100644 index 0000000..32f842a --- /dev/null +++ b/forge/gradle.properties @@ -0,0 +1 @@ +loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/com/mrmelon54/Draggable/forge/DraggableForge.java b/forge/src/main/java/com/mrmelon54/Draggable/forge/DraggableForge.java new file mode 100644 index 0000000..ae76621 --- /dev/null +++ b/forge/src/main/java/com/mrmelon54/Draggable/forge/DraggableForge.java @@ -0,0 +1,20 @@ +package com.mrmelon54.Draggable.forge; + +import dev.architectury.platform.forge.EventBuses; +import com.mrmelon54.Draggable.Draggable; +import net.minecraftforge.client.ConfigScreenHandler; +import net.minecraftforge.client.ConfigScreenHandler.ConfigScreenFactory; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod(Draggable.MOD_ID) +public class DraggableForge { + public DraggableForge() { + // Submit our event bus to let architectury register our content on the right time + EventBuses.registerModEventBus(Draggable.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus()); + ModLoadingContext.get().registerExtensionPoint(ConfigScreenFactory.class, () -> new ConfigScreenFactory((mc, screen) -> Draggable.createConfigScreen(screen).get())); + + Draggable.init(); + } +} diff --git a/forge/src/main/java/com/mrmelon54/Draggable/forge/ExampleExpectPlatformImpl.java b/forge/src/main/java/com/mrmelon54/Draggable/forge/ExampleExpectPlatformImpl.java new file mode 100644 index 0000000..73ef900 --- /dev/null +++ b/forge/src/main/java/com/mrmelon54/Draggable/forge/ExampleExpectPlatformImpl.java @@ -0,0 +1,15 @@ +package com.mrmelon54.Draggable.forge; + +import com.mrmelon54.Draggable.ExampleExpectPlatform; +import net.minecraftforge.fml.loading.FMLPaths; + +import java.nio.file.Path; + +public class ExampleExpectPlatformImpl { + /** + * This is our actual method to {@link ExampleExpectPlatform#getConfigDirectory()}. + */ + public static Path getConfigDirectory() { + return FMLPaths.CONFIGDIR.get(); + } +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..9564244 --- /dev/null +++ b/forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,33 @@ +modLoader = "javafml" +loaderVersion = "[46,)" +issueTrackerURL = "https://github.com/MrMelon54/draggable/issues" +license = "GPL-3.0-only" + +[[mods]] +modId = "draggable" +version = "${version}" +displayName = "Draggable" +authors = "MrMelon54" +description = "Draggable resource packs, datapacks, servers and worlds" +logoFile = "/icon.png" + +[[dependencies.draggable]] +modId = "forge" +mandatory = true +versionRange = "[46,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.draggable]] +modId = "minecraft" +mandatory = true +versionRange = "[1.20,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.draggable]] +modId = "architectury" +mandatory = true +versionRange = "[9.0.0,)" +ordering = "AFTER" +side = "BOTH" diff --git a/forge/src/main/resources/draggable.mixins.json b/forge/src/main/resources/draggable.mixins.json new file mode 100644 index 0000000..1b344bc --- /dev/null +++ b/forge/src/main/resources/draggable.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "com.mrmelon54.Draggable.mixin.forge", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..3f93c20 --- /dev/null +++ b/forge/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Draggable", + "pack_format": 15 + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..7f71028 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,24 @@ +org.gradle.jvmargs=-Xmx4096M + +minecraft_version=1.20 +enabled_platforms=quilt,fabric,forge + +archives_base_name=draggable +mod_id=draggable +mod_name=Draggable +mod_version=1.0.0 +mod_description="Draggable resource packs, datapacks, servers and worlds" +maven_group=com.mrmelon54.Draggable + +architectury_version=9.0.7 + +fabric_loader_version=0.14.21 +fabric_api_version=0.83.0+1.20 + +forge_version=1.20-46.0.1 + +quilt_loader_version=0.19.0-beta.18 +quilt_fabric_api_version=7.0.0+0.83.0-1.20 + +cloth_config_version=11.0.99 +modmenu_version=7.0.1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..41dfb87 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..248e32d Binary files /dev/null and b/icon.png differ diff --git a/mod-info.json b/mod-info.json new file mode 100644 index 0000000..cbf3640 --- /dev/null +++ b/mod-info.json @@ -0,0 +1,10 @@ +{ + "modid": "draggable", + "modname": "Draggable", + "modclass": "Draggable", + "modgroup": "com.mrmelon54.Draggable", + "moddesc": "Draggable resource packs, datapacks, servers and worlds", + "modwebsite": "https://mrmelon54.com/minecraft/draggable", + "modsource": "https://github.com/MrMelon54/draggable", + "modissue": "https://github.com/MrMelon54/draggable/issues" +} diff --git a/quilt/build.gradle b/quilt/build.gradle new file mode 100644 index 0000000..35a73c4 --- /dev/null +++ b/quilt/build.gradle @@ -0,0 +1,103 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +repositories { + maven { url "https://maven.quiltmc.org/repository/release/" } +} + +architectury { + platformSetupLoomIde() + loader("quilt") +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentQuilt.extendsFrom common +} + +dependencies { + modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" + modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" + // Remove the next few lines if you don't want to depend on the API + modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { + // We must not pull Fabric Loader from Architectury Fabric + exclude group: "net.fabricmc" + exclude group: "net.fabricmc.fabric-api" + } + + modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { + exclude(group: "net.fabricmc") + exclude(group: "net.fabricmc.fabric-api") + } + modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { + exclude(group: "net.fabricmc") + exclude(group: "net.fabricmc.fabric-api") + } + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false } + common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false } +} + +processResources { + inputs.property "group", rootProject.maven_group + inputs.property "version", project.version + + filesMatching("quilt.mod.json") { + expand "group": rootProject.maven_group, + "version": project.version + } +} + +shadowJar { + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" +} + +remapJar { + injectAccessWidener = true + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenQuilt(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/quilt/gradle.properties b/quilt/gradle.properties new file mode 100644 index 0000000..96758ce --- /dev/null +++ b/quilt/gradle.properties @@ -0,0 +1 @@ +loom.platform=quilt \ No newline at end of file diff --git a/quilt/src/main/java/com/mrmelon54/Draggable/quilt/DraggableQuilt.java b/quilt/src/main/java/com/mrmelon54/Draggable/quilt/DraggableQuilt.java new file mode 100644 index 0000000..813bed5 --- /dev/null +++ b/quilt/src/main/java/com/mrmelon54/Draggable/quilt/DraggableQuilt.java @@ -0,0 +1,12 @@ +package com.mrmelon54.Draggable.quilt; + +import com.mrmelon54.Draggable.fabriclike.DraggableFabricLike; +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; + +public class DraggableQuilt implements ModInitializer { + @Override + public void onInitialize(ModContainer mod) { + DraggableFabricLike.init(); + } +} diff --git a/quilt/src/main/java/com/mrmelon54/Draggable/quilt/ExampleExpectPlatformImpl.java b/quilt/src/main/java/com/mrmelon54/Draggable/quilt/ExampleExpectPlatformImpl.java new file mode 100644 index 0000000..6240683 --- /dev/null +++ b/quilt/src/main/java/com/mrmelon54/Draggable/quilt/ExampleExpectPlatformImpl.java @@ -0,0 +1,15 @@ +package com.mrmelon54.Draggable.quilt; + +import com.mrmelon54.Draggable.ExampleExpectPlatform; +import org.quiltmc.loader.api.QuiltLoader; + +import java.nio.file.Path; + +public class ExampleExpectPlatformImpl { + /** + * This is our actual method to {@link ExampleExpectPlatform#getConfigDirectory()}. + */ + public static Path getConfigDirectory() { + return QuiltLoader.getConfigDir(); + } +} diff --git a/quilt/src/main/resources/draggable.mixins.json b/quilt/src/main/resources/draggable.mixins.json new file mode 100644 index 0000000..672196e --- /dev/null +++ b/quilt/src/main/resources/draggable.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "com.mrmelon54.Draggable.mixin.fabric", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json new file mode 100644 index 0000000..535e28c --- /dev/null +++ b/quilt/src/main/resources/quilt.mod.json @@ -0,0 +1,56 @@ +{ + "schema_version": 1, + "mixin": [ + "draggable.mixins.json", + "draggable-common.mixins.json" + ], + "quilt_loader": { + "group": "${group}", + "id": "draggable", + "version": "${version}", + "metadata": { + "name": "Draggable", + "description": "Draggable resource packs, datapacks, servers and worlds", + "contributors": { + "MrMelon54": "Owner" + }, + "contact": { + "homepage": "https://mrmelon54.com/minecraft/draggable", + "sources": "https://github.com/MrMelon54/draggable", + "issues": "https://github.com/MrMelon54/draggable/issues" + }, + "license": "GPL-3.0-only", + "icon": "icon.png" + }, + "intermediate_mappings": "net.fabricmc:intermediary", + "entrypoints": { + "init": [ + "com.mrmelon54.Draggable.quilt.DraggableQuilt" + ], + "modmenu": [ + "com.mrmelon54.Draggable.fabriclike.ModMenuIntegration" + ] + }, + "depends": [ + { + "id": "quilt_loader", + "version": "*" + }, + { + "id": "quilt_base", + "version": "*" + }, + { + "id": "minecraft", + "version": ">=1.20" + }, + { + "id": "architectury", + "version": ">=9.0.0" + } + ] + }, + "minecraft": { + "environment": "*" + } +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..5496ac6 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,16 @@ +pluginManagement { + repositories { + maven { url "https://maven.fabricmc.net/" } + maven { url "https://maven.architectury.dev/" } + maven { url "https://maven.minecraftforge.net/" } + gradlePluginPortal() + } +} + +include("common") +include("fabric-like") +include("fabric") +include("quilt") +include("forge") + +rootProject.name = "draggable"