From 372eec27e5e0c8ef796ed9e6bcdc68a10df84718 Mon Sep 17 00:00:00 2001 From: nea Date: Tue, 12 Jul 2022 14:20:22 +0200 Subject: initial --- .gitignore | 27 +++ README.md | 6 + build.gradle.kts | 84 ++++++++ common/build.gradle.kts | 36 ++++ .../moe/nea/notenoughupdates/rei/NEUReiPlugin.kt | 140 ++++++++++++ .../kotlin/net/examplemod/ExampleExpectPlatform.kt | 30 +++ .../src/main/kotlin/net/examplemod/ExampleMod.kt | 31 +++ .../net/examplemod/mixin/MixinTitleScreen.kt | 23 ++ common/src/main/resources/architectury.common.json | 3 + .../resources/assets/examplemod/lang/en_us.json | 3 + .../resources/notenoughupdates-common.mixins.json | 13 ++ .../main/resources/notenoughupdates.accesswidener | 1 + fabric/build.gradle.kts | 108 ++++++++++ .../examplemod/fabric/ExampleExpectPlatformImpl.kt | 13 ++ .../net/examplemod/fabric/ExampleModFabric.kt | 10 + fabric/src/main/resources/fabric.mod.json | 34 +++ .../main/resources/notenoughupdates.mixins.json | 12 ++ forge/build.gradle.kts | 108 ++++++++++ forge/gradle.properties | 1 + .../examplemod/forge/ExampleExpectPlatformImpl.kt | 14 ++ .../kotlin/net/examplemod/forge/ExampleModForge.kt | 16 ++ forge/src/main/resources/META-INF/mods.toml | 35 +++ forge/src/main/resources/examplemod.mixins.json | 12 ++ forge/src/main/resources/pack.mcmeta | 6 + gradle.properties | 25 +++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes gradle/wrapper/gradle-wrapper.properties | 5 + gradlew | 234 +++++++++++++++++++++ gradlew.bat | 89 ++++++++ quilt/build.gradle.kts | 118 +++++++++++ quilt/gradle.properties | 1 + .../examplemod/fabric/ExampleExpectPlatformImpl.kt | 13 ++ .../kotlin/net/examplemod/quilt/ExampleModQuilt.kt | 12 ++ quilt/src/main/resources/quilt.mod.json | 45 ++++ settings.gradle.kts | 25 +++ 35 files changed, 1333 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 build.gradle.kts create mode 100644 common/build.gradle.kts create mode 100644 common/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt create mode 100644 common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt create mode 100644 common/src/main/kotlin/net/examplemod/ExampleMod.kt create mode 100644 common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt create mode 100644 common/src/main/resources/architectury.common.json create mode 100644 common/src/main/resources/assets/examplemod/lang/en_us.json create mode 100644 common/src/main/resources/notenoughupdates-common.mixins.json create mode 100644 common/src/main/resources/notenoughupdates.accesswidener create mode 100644 fabric/build.gradle.kts create mode 100644 fabric/src/main/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt create mode 100644 fabric/src/main/kotlin/net/examplemod/fabric/ExampleModFabric.kt create mode 100644 fabric/src/main/resources/fabric.mod.json create mode 100644 fabric/src/main/resources/notenoughupdates.mixins.json create mode 100644 forge/build.gradle.kts create mode 100644 forge/gradle.properties create mode 100644 forge/src/main/kotlin/net/examplemod/forge/ExampleExpectPlatformImpl.kt create mode 100644 forge/src/main/kotlin/net/examplemod/forge/ExampleModForge.kt create mode 100644 forge/src/main/resources/META-INF/mods.toml create mode 100644 forge/src/main/resources/examplemod.mixins.json create mode 100644 forge/src/main/resources/pack.mcmeta create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 quilt/build.gradle.kts create mode 100644 quilt/gradle.properties create mode 100644 quilt/src/main/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt create mode 100644 quilt/src/main/kotlin/net/examplemod/quilt/ExampleModQuilt.kt create mode 100644 quilt/src/main/resources/quilt.mod.json create mode 100644 settings.gradle.kts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b1f198 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +# IDEA +/.idea/ + +# Architectury-loom runClient +/common/build/ +/forge/build/ +/fabric/build/ +/quilt/build/ +/forge/run/ +/fabric/run/ +/quilt/run/ +/run/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..afff4cf --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# architectury-template-kotlin-dsl +architectury template with kotlin-dsl + +Based on [Architectury-templates(1.18.2-forge-fabric-quilt-mixin)](https://github.com/architectury/architectury-templates/releases) + +If you find bugs, please open a issues or PR to help me fix bugs. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..162f269 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,84 @@ +import net.fabricmc.loom.api.LoomGradleExtensionAPI +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + java + `kotlin-dsl` + id("architectury-plugin") version "3.4-SNAPSHOT" + id("dev.architectury.loom") version "0.12.0.+" apply false +} + +architectury { + minecraft = rootProject.property("minecraft_version").toString() +} + +subprojects { + apply(plugin = "dev.architectury.loom") + + val loom = project.extensions.getByName("loom") + + + dependencies { + "minecraft"("com.mojang:minecraft:${project.property("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.18.2+build.3:v2") + } +} + +allprojects { + apply(plugin = "java") + apply(plugin = "architectury-plugin") + apply(plugin = "maven-publish") + apply(plugin = "org.jetbrains.kotlin.jvm") + + base.archivesName.set(rootProject.property("archives_base_name").toString()) + //base.archivesBaseName = rootProject.property("archives_base_name").toString() + version = rootProject.property("mod_version").toString() + group = rootProject.property("maven_group").toString() + + 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("https://maven.terraformersmc.com/releases/") + maven("https://maven.shedaniel.me") + maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") + maven("https://api.modrinth.com/maven") { + content { + includeGroup("maven.modrinth") + } + } + mavenLocal() + } + + dependencies { + "compileClasspath"("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21") + implementation("io.github.moulberry:neurepoparser:0.0.1") + } + + tasks.withType { + options.encoding = "UTF-8" + options.release.set(17) + } + + java { + withSourcesJar() + toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + } + + // could not set to 17, up to 16 + val compileKotlin: KotlinCompile by tasks + compileKotlin.kotlinOptions { + jvmTarget = "16" + } + val compileTestKotlin: KotlinCompile by tasks + compileTestKotlin.kotlinOptions { + jvmTarget = "16" + } +} diff --git a/common/build.gradle.kts b/common/build.gradle.kts new file mode 100644 index 0000000..17146d0 --- /dev/null +++ b/common/build.gradle.kts @@ -0,0 +1,36 @@ +plugins { + `maven-publish` +} + +architectury { + val enabled_platforms: String by rootProject + common(enabled_platforms.split(",")) +} + +loom { + accessWidenerPath.set(file("src/main/resources/notenoughupdates.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.property("fabric_loader_version")}") + // Remove the next line if you don't want to depend on the API + modApi("dev.architectury:architectury:${rootProject.property("architectury_version")}") + modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${rootProject.property("rei_version")}") + implementation(kotlin("stdlib-jdk8")) +} + +publishing { + publications { + create("maven") { + artifactId = rootProject.property("archives_base_name").toString() + from(components.getByName("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/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt b/common/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt new file mode 100644 index 0000000..de8c689 --- /dev/null +++ b/common/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt @@ -0,0 +1,140 @@ +package moe.nea.notenoughupdates.rei + +import com.mojang.blaze3d.vertex.PoseStack +import io.github.moulberry.repo.NEURepository +import me.shedaniel.math.Point +import me.shedaniel.math.Rectangle +import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer +import me.shedaniel.rei.api.client.gui.widgets.Tooltip +import me.shedaniel.rei.api.client.plugins.REIClientPlugin +import me.shedaniel.rei.api.client.registry.entry.EntryRegistry +import me.shedaniel.rei.api.common.entry.EntrySerializer +import me.shedaniel.rei.api.common.entry.EntryStack +import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext +import me.shedaniel.rei.api.common.entry.type.EntryDefinition +import me.shedaniel.rei.api.common.entry.type.EntryType +import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes +import me.shedaniel.rei.api.common.util.EntryStacks +import net.minecraft.core.Registry +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.TextComponent +import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.TagKey +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraft.world.item.enchantment.Enchantments +import java.nio.file.Path +import java.util.stream.Stream + + +class NEUReiPlugin : REIClientPlugin { + + data class SBItem(val sbname: String, val backing: Item) + companion object { + + fun EntryStack.asItemStack() = + EntryStack.of(VanillaEntryTypes.ITEM, ItemStack(this.value.backing).also { + it.enchant(Enchantments.BINDING_CURSE, 1) + it.hoverName = TextComponent(value.sbname) + }) + + val hehe = ResourceLocation("notenoughupdates", "skyblockitems") + } + + object SBItemEntryDefinition : EntryDefinition { + override fun equals(o1: SBItem?, o2: SBItem?, context: ComparisonContext?): Boolean { + return o1 == o2 + } + + override fun getValueType(): Class = SBItem::class.java + override fun getType(): EntryType = + EntryType.deferred(hehe) + + override fun getRenderer(): EntryRenderer = object : EntryRenderer { + override fun render( + entry: EntryStack, + matrices: PoseStack, + bounds: Rectangle, + mouseX: Int, + mouseY: Int, + delta: Float + ) { + VanillaEntryTypes.ITEM.definition.renderer + .render( + entry.asItemStack(), + matrices, bounds, mouseX, mouseY, delta + ) + } + + override fun getTooltip(entry: EntryStack, mouse: Point): Tooltip? { + return VanillaEntryTypes.ITEM.definition.renderer + .getTooltip(entry.asItemStack(), mouse) + } + + } + + override fun getSerializer(): EntrySerializer? { + return null + } + + override fun getTagsFor(entry: EntryStack?, value: SBItem?): Stream> { + return Stream.empty() + } + + override fun asFormattedText(entry: EntryStack, value: SBItem): Component { + return VanillaEntryTypes.ITEM.definition.asFormattedText(entry.asItemStack(), ItemStack(value.backing)) + } + + override fun hash(entry: EntryStack, value: SBItem, context: ComparisonContext): Long { + return value.sbname.hashCode().toLong() + } + + override fun wildcard(entry: EntryStack, value: SBItem): SBItem { + return value + } + + override fun normalize(entry: EntryStack, value: SBItem): SBItem { + return value + } + + override fun copy(entry: EntryStack?, value: SBItem): SBItem { + return value.copy() + } + + override fun isEmpty(entry: EntryStack?, value: SBItem?): Boolean { + return false + } + + override fun getIdentifier(entry: EntryStack?, value: SBItem): ResourceLocation? { + return ResourceLocation("skyblockitem", value.sbname) + } + + + } + + val neuRepo = NEURepository.of(Path.of("NotEnoughUpdates-REPO")).also { + it.reload() + } + + override fun registerEntryTypes(registry: EntryTypeRegistry) { + registry.register(hehe, SBItemEntryDefinition) + } + + override fun registerEntries(registry: EntryRegistry) { + neuRepo.items.items.values.forEach { + println("Adding item: $it") + registry.addEntry( + EntryStack.of( + SBItemEntryDefinition, SBItem( + it.skyblockItemId.lowercase().replace(";", "__"), Registry.ITEM.get(ResourceLocation(it.minecraftItemId)) + ) + ) + ) + } + registry.addEntry(EntryStacks.of(ItemStack(Items.DIAMOND).also { + it.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 10) + })) + } +} diff --git a/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt b/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt new file mode 100644 index 0000000..4949054 --- /dev/null +++ b/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt @@ -0,0 +1,30 @@ +package net.examplemod + +import dev.architectury.injectables.annotations.ExpectPlatform +import dev.architectury.platform.Platform +import java.nio.file.Path + +object ExampleExpectPlatform { + /** + * We can use [Platform.getConfigFolder] but this is just an example of [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 `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.](https://plugins.jetbrains.com/plugin/16210-architectury) + */ + @ExpectPlatform + @JvmStatic + fun getConfigDirectory(): Path { + // Just throw an error, the content should get replaced at runtime. + throw AssertionError() + } +} diff --git a/common/src/main/kotlin/net/examplemod/ExampleMod.kt b/common/src/main/kotlin/net/examplemod/ExampleMod.kt new file mode 100644 index 0000000..4f618ce --- /dev/null +++ b/common/src/main/kotlin/net/examplemod/ExampleMod.kt @@ -0,0 +1,31 @@ +package net.examplemod + +import com.google.common.base.Suppliers +import dev.architectury.registry.CreativeTabRegistry +import dev.architectury.registry.registries.DeferredRegister +import dev.architectury.registry.registries.Registries +import dev.architectury.registry.registries.RegistrySupplier +import net.minecraft.core.Registry +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.CreativeModeTab +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import java.util.function.Supplier + +object ExampleMod { + const val MOD_ID = "examplemod" + + // We can use this if we don't want to use DeferredRegister + @Suppress("unused") + val REGISTRIES: Supplier = Suppliers.memoize { Registries.get(MOD_ID) } + + // Registering a new creative tab + val EXAMPLE_TAB: CreativeModeTab = CreativeTabRegistry.create(ResourceLocation(MOD_ID, "example_tab")) { ItemStack(EXAMPLE_ITEM.get()) } + val ITEMS: DeferredRegister = DeferredRegister.create(MOD_ID, Registry.ITEM_REGISTRY) + val EXAMPLE_ITEM: RegistrySupplier = ITEMS.register("example_item") { Item(Item.Properties().tab(EXAMPLE_TAB)) } + + fun init() { + ITEMS.register() + println(ExampleExpectPlatform.getConfigDirectory().toAbsolutePath().normalize().toString()) + } +} diff --git a/common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt b/common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt new file mode 100644 index 0000000..0b7e009 --- /dev/null +++ b/common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt @@ -0,0 +1,23 @@ +package net.examplemod.mixin + +import net.minecraft.client.gui.screens.TitleScreen +import org.objectweb.asm.Opcodes +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.Redirect +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo + +@Mixin(TitleScreen::class) +class MixinTitleScreen { + @Inject(at = [At("HEAD")], method = ["init()V"]) + private fun init(info: CallbackInfo) { + println("Hello from example architectury common mixin!") + } + + @Redirect(method = ["render"], at = At("FIELD", target = "minceraftEasterEgg", opcode = Opcodes.GETFIELD)) + private fun nextFloat(t: TitleScreen): Boolean { + return true + } + +} diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json new file mode 100644 index 0000000..017e6cd --- /dev/null +++ b/common/src/main/resources/architectury.common.json @@ -0,0 +1,3 @@ +{ + "accessWidener": "notenoughupdates.accesswidener" +} diff --git a/common/src/main/resources/assets/examplemod/lang/en_us.json b/common/src/main/resources/assets/examplemod/lang/en_us.json new file mode 100644 index 0000000..6bcd60e --- /dev/null +++ b/common/src/main/resources/assets/examplemod/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "item.examplemod.example_item": "Example Item" +} \ No newline at end of file diff --git a/common/src/main/resources/notenoughupdates-common.mixins.json b/common/src/main/resources/notenoughupdates-common.mixins.json new file mode 100644 index 0000000..d2e39dc --- /dev/null +++ b/common/src/main/resources/notenoughupdates-common.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "net.examplemod.mixin", + "compatibilityLevel": "JAVA_16", + "client": [ + "MixinTitleScreen" + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/common/src/main/resources/notenoughupdates.accesswidener b/common/src/main/resources/notenoughupdates.accesswidener new file mode 100644 index 0000000..236e6b1 --- /dev/null +++ b/common/src/main/resources/notenoughupdates.accesswidener @@ -0,0 +1 @@ +accessWidener v2 named diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts new file mode 100644 index 0000000..27900f6 --- /dev/null +++ b/fabric/build.gradle.kts @@ -0,0 +1,108 @@ +plugins { + id("com.github.johnrengelman.shadow") version "7.1.2" +} + +architectury { + platformSetupLoomIde() + fabric() +} + +loom { + accessWidenerPath.set(project(":common").loom.accessWidenerPath) +} + +/** + * @see: https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html + * */ +val common: Configuration by configurations.creating +val shadowCommon: Configuration by configurations.creating // Don't use shadow from the shadow plugin because we don't want IDEA to index this. +val developmentFabric: Configuration = configurations.getByName("developmentFabric") +configurations { + compileClasspath.get().extendsFrom(configurations["common"]) + runtimeClasspath.get().extendsFrom(configurations["common"]) + developmentFabric.extendsFrom(configurations["common"]) +} + +dependencies { + modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}") + modApi("net.fabricmc.fabric-api:fabric-api:${rootProject.property("fabric_api_version")}") + // Remove the next line if you don't want to depend on the API + modApi("dev.architectury:architectury-fabric:${rootProject.property("architectury_version")}") + + common(project(":common", configuration = "namedElements")) { isTransitive = false } + shadowCommon(project(":common", configuration = "transformProductionFabric")) { isTransitive = false } + common(kotlin("stdlib-jdk8")) + modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:${rootProject.property("rei_version")}") + modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:${rootProject.property("devauth_version")}") + modRuntimeOnly("maven.modrinth:modmenu:${rootProject.property("modmenu_version")}") +} + +val javaComponent = components.getByName("java", AdhocComponentWithVariants::class) +javaComponent.withVariantsFromConfiguration(configurations["sourcesElements"]) { + skip() +} + +tasks { + processResources { + inputs.property("version", project.version) + + filesMatching("fabric.mod.json") { + expand("version" to project.version) + } + } + + shadowJar { + exclude("architectury.common.json") + /** + * magic! + * groovy -> kotlin dsl + * [project.configurations.shadowCommon] -> listOf(project.configurations["shadowCommon"]) + * */ + configurations = listOf(project.configurations["shadowCommon"]) + archiveClassifier.set("dev-shadow") + } + + remapJar { + injectAccessWidener.set(true) + /** + * magic! + * groovy -> kotlin dsl + * shadowJar.archiveFile -> shadowJar.flatMap { it.archiveFile } + * */ + inputFile.set(shadowJar.flatMap { it.archiveFile }) + dependsOn(shadowJar) + /** + * affect suffix of build jar name + * if { archiveClassifier.set("fabric") } + * name will be examplemod-1.0.0-fabric.jar + */ + archiveClassifier.set("fabric") + } + + jar { + archiveClassifier.set("dev") + } + + sourcesJar { + val commonSources = project(":common").tasks.getByName("sourcesJar", Jar::class) + dependsOn(commonSources) + from(commonSources.archiveFile.map { zipTree(it) }) + } + + + + publishing { + publications { + create("mavenFabric") { + artifactId = "${rootProject.property("archives_base_name")}-${project.name}" + from(javaComponent) + } + } + + // 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/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt b/fabric/src/main/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt new file mode 100644 index 0000000..8982dfc --- /dev/null +++ b/fabric/src/main/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt @@ -0,0 +1,13 @@ +package net.examplemod.fabric + +import net.fabricmc.loader.api.FabricLoader +import java.nio.file.Path +import net.examplemod.ExampleExpectPlatform + +object ExampleExpectPlatformImpl { + /** + * This is our actual method to [ExampleExpectPlatform.getConfigDirectory]. + */ + @JvmStatic + fun getConfigDirectory(): Path = FabricLoader.getInstance().configDir +} \ No newline at end of file diff --git a/fabric/src/main/kotlin/net/examplemod/fabric/ExampleModFabric.kt b/fabric/src/main/kotlin/net/examplemod/fabric/ExampleModFabric.kt new file mode 100644 index 0000000..c11491c --- /dev/null +++ b/fabric/src/main/kotlin/net/examplemod/fabric/ExampleModFabric.kt @@ -0,0 +1,10 @@ +package net.examplemod.fabric + +import net.examplemod.ExampleMod.init +import net.fabricmc.api.ModInitializer + +class ExampleModFabric : ModInitializer { + override fun onInitialize() { + init() + } +} \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..21eaec0 --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,34 @@ +{ + "schemaVersion": 1, + "id": "notenoughupdates", + "version": "${version}", + "name": "Not Enough Updates", + "description": "Not Enough Updates - A mod for Hypixel Skyblock", + "authors": [ + "nea89" + ], + "contact": { + "homepage": "https://github.com/romangraef/TODO", + "sources": "https://github.com/romangraef/TODO" + }, + "license": "LGPL-3.0", + "icon": "assets/notenoughupdates/icon.png", + "environment": "client", + "entrypoints": { + "main": [ + "net.examplemod.fabric.ExampleModFabric" + ], + "rei": [ + "moe.nea.notenoughupdates.rei.NEUReiPlugin" + ] + }, + "mixins": [ + "notenoughupdates.mixins.json", + "notenoughupdates-common.mixins.json" + ], + "depends": { + "fabric": "*", + "minecraft": ">=1.18.2", + "architectury": ">=4.2.50" + } +} diff --git a/fabric/src/main/resources/notenoughupdates.mixins.json b/fabric/src/main/resources/notenoughupdates.mixins.json new file mode 100644 index 0000000..ab40cb1 --- /dev/null +++ b/fabric/src/main/resources/notenoughupdates.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "package": "net.examplemod.mixin.fabric", + "compatibilityLevel": "JAVA_16", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts new file mode 100644 index 0000000..47a56db --- /dev/null +++ b/forge/build.gradle.kts @@ -0,0 +1,108 @@ +plugins { + id("com.github.johnrengelman.shadow") version "7.1.2" +} + +architectury { + platformSetupLoomIde() + forge() +} + +loom { + accessWidenerPath.set(project(":common").loom.accessWidenerPath) + + forge { + convertAccessWideners.set(true) + extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name) + } +} + +/** + * @see: https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html + * */ +val common: Configuration by configurations.creating +val shadowCommon: Configuration by configurations.creating // Don't use shadow from the shadow plugin because we don't want IDEA to index this. +val developmentForge: Configuration = configurations.getByName("developmentForge") +configurations { + compileClasspath.get().extendsFrom(configurations["common"]) + runtimeClasspath.get().extendsFrom(configurations["common"]) + developmentForge.extendsFrom(configurations["common"]) +} + +dependencies { + forge("net.minecraftforge:forge:${rootProject.property("forge_version")}") + // Remove the next line if you don't want to depend on the API + modApi("dev.architectury:architectury-forge:${rootProject.property("architectury_version")}") + common(project(":common", configuration = "namedElements")) { isTransitive = false } + shadowCommon(project(":common", configuration = "transformProductionForge")) { isTransitive = false } + common(kotlin("stdlib-jdk8")) + modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-forge:${rootProject.property("rei_version")}") +} + +val javaComponent = components["java"] as AdhocComponentWithVariants +javaComponent.withVariantsFromConfiguration(configurations["sourcesElements"]) { + skip() +} + +tasks { + processResources { + inputs.property("version", project.version) + + filesMatching("META-INF/mods.toml") { + expand("version" to project.version) + } + } + + shadowJar { + exclude("fabric.mod.json") + exclude("architectury.common.json") + + /** + * magic! + * groovy -> kotlin dsl + * [project.configurations.shadowCommon] -> listOf(project.configurations["shadowCommon"]) + * */ + configurations = listOf(project.configurations["shadowCommon"]) + archiveClassifier.set("dev-shadow") + } + + remapJar { + /** + * magic! + * groovy -> kotlin dsl + * shadowJar.archiveFile -> shadowJar.flatMap { it.archiveFile } + * */ + inputFile.set(shadowJar.flatMap { it.archiveFile }) + dependsOn(shadowJar) + /** + * affect suffix of build jar name + * if { archiveClassifier.set("forge") } + * name will be examplemod-1.0.0-forge.jar + */ + archiveClassifier.set("forge") + } + + jar { + archiveClassifier.set("dev") + } + + sourcesJar { + val commonSources = project(":common").tasks.getByName("sourcesJar", Jar::class) + dependsOn(commonSources) + from(commonSources.archiveFile.map { zipTree(it) }) + } + + + publishing { + publications { + create("mavenForge") { + artifactId = "${rootProject.property("archives_base_name")}-${project.name}" + from(javaComponent) + } + } + + // 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/kotlin/net/examplemod/forge/ExampleExpectPlatformImpl.kt b/forge/src/main/kotlin/net/examplemod/forge/ExampleExpectPlatformImpl.kt new file mode 100644 index 0000000..8617e69 --- /dev/null +++ b/forge/src/main/kotlin/net/examplemod/forge/ExampleExpectPlatformImpl.kt @@ -0,0 +1,14 @@ +package net.examplemod.forge + +import net.minecraftforge.fml.loading.FMLPaths +import java.nio.file.Path +import net.examplemod.ExampleExpectPlatform + +@Suppress("unused") +object ExampleExpectPlatformImpl { + /** + * This is our actual method to [ExampleExpectPlatform.getConfigDirectory]. + */ + @JvmStatic + fun getConfigDirectory(): Path = FMLPaths.CONFIGDIR.get() +} \ No newline at end of file diff --git a/forge/src/main/kotlin/net/examplemod/forge/ExampleModForge.kt b/forge/src/main/kotlin/net/examplemod/forge/ExampleModForge.kt new file mode 100644 index 0000000..7dc906c --- /dev/null +++ b/forge/src/main/kotlin/net/examplemod/forge/ExampleModForge.kt @@ -0,0 +1,16 @@ +package net.examplemod.forge + +import dev.architectury.platform.forge.EventBuses +import net.examplemod.ExampleMod +import net.examplemod.ExampleMod.init +import net.minecraftforge.fml.common.Mod +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext + +@Mod(ExampleMod.MOD_ID) +class ExampleModForge { + init { + // Submit our event bus to let architectury register our content on the right time + EventBuses.registerModEventBus(ExampleMod.MOD_ID, FMLJavaModLoadingContext.get().modEventBus) + init() + } +} \ No newline at end of file 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..4c3d869 --- /dev/null +++ b/forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,35 @@ +modLoader = "javafml" +loaderVersion = "[40,)" +#issueTrackerURL = "TODO" +license = "LGPL-3.0" + +[[mods]] +modId = "notenoughupdates" +version = "${version}" +displayName = "Not Enough Updates" +authors = "nea89" +description = ''' +Not Enough Updates - A mod for Hypixel Skyblock +''' +#logoFile = "" + +[[dependencies.notenoughupdates]] +modId = "forge" +mandatory = true +versionRange = "[40,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.notenoughupdates]] +modId = "minecraft" +mandatory = true +versionRange = "[1.18.2,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.notenoughupdates]] +modId = "architectury" +mandatory = true +versionRange = "[4.2.50,)" +ordering = "AFTER" +side = "BOTH" diff --git a/forge/src/main/resources/examplemod.mixins.json b/forge/src/main/resources/examplemod.mixins.json new file mode 100644 index 0000000..50eba1c --- /dev/null +++ b/forge/src/main/resources/examplemod.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "package": "net.examplemod.mixin.forge", + "compatibilityLevel": "JAVA_16", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..9252d3d --- /dev/null +++ b/forge/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Example Mod", + "pack_format": 8 + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..f18c603 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,25 @@ +org.gradle.jvmargs=-Xmx4096M + +minecraft_version=1.18.2 +enabled_platforms=quilt,fabric,forge + +archives_base_name=notenoughupdates +mod_version=1.0.0 +maven_group=moe.nea.notenoughupdates + +architectury_version=4.2.50 + +fabric_loader_version=0.14.0 +fabric_api_version=0.51.1+1.18.2 + +forge_version=1.18.2-40.1.0 + +quilt_loader_version=0.16.0-beta.7 +quilt_fabric_api_version=1.0.0-beta.7+0.51.1-1.18.2 + +kotlin_version=1.7.0-RC + + +rei_version=8.0.+ +devauth_version=1.0.0 +modmenu_version=3.2.3 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/quilt/build.gradle.kts b/quilt/build.gradle.kts new file mode 100644 index 0000000..5f859c1 --- /dev/null +++ b/quilt/build.gradle.kts @@ -0,0 +1,118 @@ +plugins { + id("com.github.johnrengelman.shadow") version "7.1.2" +} + +repositories { + maven { url = uri("https://maven.quiltmc.org/repository/release/") } + mavenCentral() +} + +architectury { + platformSetupLoomIde() + loader("quilt") +} + +loom { + accessWidenerPath.set(project(":common").loom.accessWidenerPath) +} + +/** + * @see: https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html + * */ +val common: Configuration by configurations.creating +val shadowCommon: Configuration by configurations.creating // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + +val developmentQuilt: Configuration = configurations.getByName("developmentQuilt") +configurations { + compileClasspath.get().extendsFrom(configurations["common"]) + runtimeClasspath.get().extendsFrom(configurations["common"]) + developmentQuilt.extendsFrom(configurations["common"]) +} + +dependencies { + modImplementation("org.quiltmc:quilt-loader:${rootProject.property("quilt_loader_version")}") + modApi("org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.property("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.property("architectury_version")}") { + // We must not pull Fabric Loader from Architectury Fabric + exclude(group = "net.fabricmc") + exclude(group = "net.fabricmc.fabric-api") + } + + common(project(":common", configuration = "namedElements")) { isTransitive = false } + shadowCommon(project(":common", configuration = "transformProductionQuilt")) { isTransitive = false } + common(kotlin("stdlib-jdk8")) +} + +val javaComponent = components.getByName("java", AdhocComponentWithVariants::class) +javaComponent.withVariantsFromConfiguration(configurations["sourcesElements"]) { + skip() +} + +tasks { + processResources { + inputs.property("group", rootProject.property("maven_group")) + inputs.property("version", project.version) + + filesMatching("quilt.mod.json") { + expand( + "group" to rootProject.property("maven_group"), + "version" to project.version + ) + } + } + + shadowJar { + exclude("architectury.common.json") + /** + * magic! + * groovy -> kotlin dsl + * [project.configurations.shadowCommon] -> listOf(project.configurations["shadowCommon"]) + * */ + configurations = listOf(project.configurations["shadowCommon"]) + archiveClassifier.set("dev-shadow") + } + + remapJar { + injectAccessWidener.set(true) + /** + * magic! + * groovy -> kotlin dsl + * shadowJar.archiveFile -> shadowJar.flatMap { it.archiveFile } + * */ + inputFile.set(shadowJar.flatMap { it.archiveFile }) + dependsOn(shadowJar) + /** + * affect suffix of build jar name + * if { archiveClassifier.set("quilt") } + * name will be examplemod-1.0.0-quilt.jar + */ + archiveClassifier.set("quilt") + } + + jar { + archiveClassifier.set("dev") + } + + + sourcesJar { + val commonSources = project(":common").tasks.getByName("sourcesJar", Jar::class) + dependsOn(commonSources) + from(commonSources.archiveFile.map { zipTree(it) }) + } + + + publishing { + publications { + create("mavenQuilt") { + artifactId = "${rootProject.property("archives_base_name")}-${project.name}" + from(javaComponent) + } + } + + // 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. + } + } +} \ No newline at end of file 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/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt b/quilt/src/main/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt new file mode 100644 index 0000000..6f78162 --- /dev/null +++ b/quilt/src/main/kotlin/net/examplemod/fabric/ExampleExpectPlatformImpl.kt @@ -0,0 +1,13 @@ +package net.examplemod.fabric + +import org.quiltmc.loader.api.QuiltLoader +import java.nio.file.Path +import net.examplemod.ExampleExpectPlatform + +object ExampleExpectPlatformImpl { + /** + * This is our actual method to [ExampleExpectPlatform.getConfigDirectory]. + */ + @JvmStatic + fun getConfigDirectory(): Path = QuiltLoader.getConfigDir() +} \ No newline at end of file diff --git a/quilt/src/main/kotlin/net/examplemod/quilt/ExampleModQuilt.kt b/quilt/src/main/kotlin/net/examplemod/quilt/ExampleModQuilt.kt new file mode 100644 index 0000000..94a36c9 --- /dev/null +++ b/quilt/src/main/kotlin/net/examplemod/quilt/ExampleModQuilt.kt @@ -0,0 +1,12 @@ +package net.examplemod.quilt + +import net.examplemod.ExampleMod.init +import org.quiltmc.loader.api.ModContainer +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer + +@Suppress("unused") +class ExampleModQuilt : ModInitializer { + override fun onInitialize(mod: ModContainer) { + init() + } +} \ No newline at end of file diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json new file mode 100644 index 0000000..6cdf9ae --- /dev/null +++ b/quilt/src/main/resources/quilt.mod.json @@ -0,0 +1,45 @@ +{ + "schema_version": 1, + "mixins": [ + "notenoughupdates.mixins.json", + "notenoughupdates-common.mixins.json" + ], + "quilt_loader": { + "group": "${group}", + "id": "notenoughupdates", + "version": "${version}", + "name": "Not Enough Updates", + "description": "Not Enough Updates - A mod for Hypixel Skyblock", + "authors": ["nea89"], + "contact": { + "sources": "https://github.com/romangraef/TODO" + }, + "license": "LGPL-3.0", + "icon": "assets/notenoughupdates/icon.png", + "intermediate_mappings": "net.fabricmc:intermediary", + "environment": "*", + "entrypoints": { + "init": [ + "net.examplemod.quilt.ExampleModQuilt" + ] + }, + "depends": [ + { + "id": "quilt_loader", + "version": "*" + }, + { + "id": "quilt_base", + "version": "*" + }, + { + "id": "minecraft", + "version": ">=1.18.2" + }, + { + "id": "architectury", + "version": ">=4.2.50" + } + ] + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..b775ae5 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,25 @@ +pluginManagement { + repositories { + maven { + name = "fabricmc" + url = uri("https://maven.fabricmc.net/") + } + maven { + name = "architectury" + url = uri("https://maven.architectury.dev/") + } + maven { + name = "forgemc" + url = uri("https://maven.minecraftforge.net/") + } + gradlePluginPortal() + } +} + +include("common") +include("fabric") +include("quilt") +include("forge") + +rootProject.name = "NotEnoughApdates" + -- cgit