From b71369c88c27ad388c9f3361312539957bd57b6e Mon Sep 17 00:00:00 2001 From: object-Object Date: Tue, 28 May 2024 17:35:46 -0400 Subject: [PATCH] Add all subprojects and most of the platform code (not yet mapping-ed) --- .../{{ common_path }}/build.gradle.kts.jinja | 22 +++++ .../{{ common_path }}/gradle.properties | 1 + .../{{ fabric_path }}/build.gradle.kts.jinja | 90 +++++++++++++++++++ .../{{ fabric_path }}/gradle.properties | 1 + .../Fabric{{ base_classname }}.kt.jinja | 10 +++ .../Fabric{{ base_classname }}Client.kt.jinja | 13 +++ ...Fabric{{ base_classname }}ModMenu.kt.jinja | 12 +++ ...base_classname }}AbstractionsImpl.kt.jinja | 11 +++ .../src/main/resources/fabric.mod.json.jinja | 46 ++++++++++ .../{{ forge_path }}/build.gradle.kts.jinja | 81 +++++++++++++++++ .../1.20.1/{{ forge_path }}/gradle.properties | 2 + .../mixin/ForgeMixinConfigPlugin.java.jinja | 42 +++++++++ .../forge/mixin/MixinDatagenMain.java.jinja | 17 ++++ .../forge/Forge{{ base_classname }}.kt.jinja | 39 ++++++++ .../Forge{{ base_classname }}Client.kt.jinja | 16 ++++ .../{{ base_classname }}Models.kt.jinja | 37 ++++++++ .../{{ base_classname }}Recipes.kt.jinja | 26 ++++++ ...base_classname }}AbstractionsImpl.kt.jinja | 15 ++++ .../main/resources/META-INF/mods.toml.jinja | 46 ++++++++++ .../src/main/resources/pack.mcmeta.jinja | 6 ++ .../resources/{{ modid }}.mixins.json.jinja | 15 ++++ 21 files changed, 548 insertions(+) create mode 100644 templates/1.20.1/{{ common_path }}/build.gradle.kts.jinja create mode 100644 templates/1.20.1/{{ common_path }}/gradle.properties create mode 100644 templates/1.20.1/{{ fabric_path }}/build.gradle.kts.jinja create mode 100644 templates/1.20.1/{{ fabric_path }}/gradle.properties create mode 100644 templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}.kt.jinja create mode 100644 templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}Client.kt.jinja create mode 100644 templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}ModMenu.kt.jinja create mode 100644 templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/{{ base_classname }}AbstractionsImpl.kt.jinja create mode 100644 templates/1.20.1/{{ fabric_path }}/src/main/resources/fabric.mod.json.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/build.gradle.kts.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/gradle.properties create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/ForgeMixinConfigPlugin.java.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/MixinDatagenMain.java.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}.kt.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}Client.kt.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Models.kt.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Recipes.kt.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/{{ base_classname }}AbstractionsImpl.kt.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/resources/META-INF/mods.toml.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/resources/pack.mcmeta.jinja create mode 100644 templates/1.20.1/{{ forge_path }}/src/main/resources/{{ modid }}.mixins.json.jinja diff --git a/templates/1.20.1/{{ common_path }}/build.gradle.kts.jinja b/templates/1.20.1/{{ common_path }}/build.gradle.kts.jinja new file mode 100644 index 00000000..fafed281 --- /dev/null +++ b/templates/1.20.1/{{ common_path }}/build.gradle.kts.jinja @@ -0,0 +1,22 @@ +plugins { + id("{{ modid }}.minecraft") +} + +architectury { + common("fabric", "forge") +} + +dependencies { + implementation(libs.kotlin.stdlib) + + // 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(libs.fabric.loader) + modApi(libs.architectury) + + modApi(libs.hexcasting.common) + + modApi(libs.clothConfig.common) + + implementation(libs.mixinExtras) +} diff --git a/templates/1.20.1/{{ common_path }}/gradle.properties b/templates/1.20.1/{{ common_path }}/gradle.properties new file mode 100644 index 00000000..9170c91f --- /dev/null +++ b/templates/1.20.1/{{ common_path }}/gradle.properties @@ -0,0 +1 @@ +platform=common diff --git a/templates/1.20.1/{{ fabric_path }}/build.gradle.kts.jinja b/templates/1.20.1/{{ fabric_path }}/build.gradle.kts.jinja new file mode 100644 index 00000000..5dfc182a --- /dev/null +++ b/templates/1.20.1/{{ fabric_path }}/build.gradle.kts.jinja @@ -0,0 +1,90 @@ +plugins { + id("{{ modid }}.platform") +} + +architectury { + fabric() +} + +{{ modid }}ModDependencies { + filesMatching.add("fabric.mod.json") + + anyVersion = "*" + mapVersions { + replace(",", " ") + replace(Regex("""\s+"""), " ") + replace(Regex("""\[(\S+)"""), ">=$1") + replace(Regex("""(\S+)\]"""), "<=$1") + replace(Regex("""\](\S+)"""), ">$1") + replace(Regex("""(\S+)\["""), "<$1") + } + + requires("architectury-api") + requires("cloth-config") + requires(curseforge = "hexcasting", modrinth = "hex-casting") + + requires("fabric-api") + requires("fabric-language-kotlin") + + optional("modmenu") +} + +dependencies { + modApi(libs.fabric.api) + modImplementation(libs.fabric.loader) + + modImplementation(libs.kotlin.fabric) + + modApi(libs.architectury.fabric) { + // Fix for the "two fabric loaders" loading crash + exclude(group = "net.fabricmc", module = "fabric-loader") + } + + modApi(libs.hexcasting.fabric) { + // If not excluded here, calls a nonexistent method and crashes the dev client + exclude(module = "phosphor") + } + modLocalRuntime(libs.paucal.fabric) + modLocalRuntime(libs.patchouli.fabric) + modLocalRuntime(libs.cardinalComponents) + modLocalRuntime(libs.serializationHooks) + modLocalRuntime(libs.trinkets) + + libs.mixinExtras.also { + localRuntime(it) + include(it) + } + + modApi(libs.clothConfig.fabric) { + exclude(group = "net.fabricmc.fabric-api") + } + modImplementation(libs.modMenu) +} + +publishMods { + modLoaders.add("quilt") + + // this fails if we do it for all projects, since the tag already exists :/ + // see https://github.com/modmuss50/mod-publish-plugin/issues/3 + github { + accessToken = System.getenv("GITHUB_TOKEN") ?: "" + repository = System.getenv("GITHUB_REPOSITORY") ?: "" + commitish = System.getenv("GITHUB_SHA") ?: "" + + type = STABLE + displayName = "v${project.version}" + tagName = "v${project.version}" + + additionalFiles.from(project(":Common").tasks.remapJar.get().archiveFile) + project(":Forge").afterEvaluate { + additionalFiles.from(tasks.remapJar.get().archiveFile) + } + } +} + +tasks { + named("publishGithub") { + dependsOn(project(":Common").tasks.remapJar) + dependsOn(project(":Forge").tasks.remapJar) + } +} diff --git a/templates/1.20.1/{{ fabric_path }}/gradle.properties b/templates/1.20.1/{{ fabric_path }}/gradle.properties new file mode 100644 index 00000000..556a8ec3 --- /dev/null +++ b/templates/1.20.1/{{ fabric_path }}/gradle.properties @@ -0,0 +1 @@ +platform=fabric diff --git a/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}.kt.jinja b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}.kt.jinja new file mode 100644 index 00000000..2647d28a --- /dev/null +++ b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}.kt.jinja @@ -0,0 +1,10 @@ +package {{ package }}.fabric + +import {{ package }}.{{ base_classname }} +import net.fabricmc.api.ModInitializer + +object Fabric{{ base_classname }} : ModInitializer { + override fun onInitialize() { + {{ base_classname }}.init() + } +} diff --git a/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}Client.kt.jinja b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}Client.kt.jinja new file mode 100644 index 00000000..c372c0d3 --- /dev/null +++ b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}Client.kt.jinja @@ -0,0 +1,13 @@ +package {{ package }}.fabric + +import {{ package }}.{{ base_classname }}Client +import net.fabricmc.api.ClientModInitializer +import net.fabricmc.api.EnvType.CLIENT +import net.fabricmc.api.Environment + +@Environment(CLIENT) +object Fabric{{ base_classname }}Client : ClientModInitializer { + override fun onInitializeClient() { + {{ base_classname }}Client.init() + } +} diff --git a/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}ModMenu.kt.jinja b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}ModMenu.kt.jinja new file mode 100644 index 00000000..10689368 --- /dev/null +++ b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}ModMenu.kt.jinja @@ -0,0 +1,12 @@ +package {{ package }}.fabric + +import com.terraformersmc.modmenu.api.ConfigScreenFactory +import com.terraformersmc.modmenu.api.ModMenuApi +import {{ package }}.config.{{ base_classname }}Config +import net.fabricmc.api.EnvType.CLIENT +import net.fabricmc.api.Environment + +@Environment(CLIENT) +object Fabric{{ base_classname }}ModMenu : ModMenuApi { + override fun getModConfigScreenFactory() = ConfigScreenFactory({{ base_classname }}Config::getConfigScreen) +} diff --git a/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/{{ base_classname }}AbstractionsImpl.kt.jinja b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/{{ base_classname }}AbstractionsImpl.kt.jinja new file mode 100644 index 00000000..bfd228bf --- /dev/null +++ b/templates/1.20.1/{{ fabric_path }}/src/main/kotlin/{{ package_path }}/{{ base_classname }}AbstractionsImpl.kt.jinja @@ -0,0 +1,11 @@ +@file:JvmName("{{ base_classname }}AbstractionsImpl") + +package {{ package }}.fabric + +import {{ package }}.registry.HexDebugRegistrar +import net.minecraft.core.Registry + +fun initRegistry(registrar: HexDebugRegistrar) { + val registry = registrar.registry + registrar.init { id, value -> Registry.register(registry, id, value) } +} diff --git a/templates/1.20.1/{{ fabric_path }}/src/main/resources/fabric.mod.json.jinja b/templates/1.20.1/{{ fabric_path }}/src/main/resources/fabric.mod.json.jinja new file mode 100644 index 00000000..bee55dd9 --- /dev/null +++ b/templates/1.20.1/{{ fabric_path }}/src/main/resources/fabric.mod.json.jinja @@ -0,0 +1,46 @@ +{ + "schemaVersion": 1, + "id": "{{ modid }}", + "version": "${modVersion}", + "name": "{{ display_name }}", + "description": "{{ description }}", + "authors": [ + "{{ github_user }}" + ], + "contact": { + "homepage": "{{ homepage_url }}", + "sources": "{{ sources_url }}" + }, + "license": "MIT", + "icon": "icon.png", + "environment": "*", + "entrypoints": { + "main": [{ + "adapter": "kotlin", + "value": "{{ package }}.fabric.Fabric{{ base_classname }}" + }], + "client": [{ + "adapter": "kotlin", + "value": "{{ package }}.fabric.Fabric{{ base_classname }}Client" + }], + "modmenu": [{ + "adapter": "kotlin", + "value": "{{ package }}.fabric.Fabric{{ base_classname }}ModMenu" + }] + }, + "mixins": [ + "{{ modid }}-common.mixins.json" + ], + "depends": { + "minecraft": "${versions.minecraft}", + "fabricloader": ">=${versions.fabric_loader}", + "fabric-api": ">=${versions.fabric_api}", + "fabric-language-kotlin": ">=${versions.kotlin_fabric}", + "architectury": ">=${versions.architectury}", + "hexcasting": ">=${versions.hexcasting}", + "cloth-config": ">=${versions.clothConfig}" + }, + "suggests": { + "modmenu": ">=${versions.modMenu}" + } +} diff --git a/templates/1.20.1/{{ forge_path }}/build.gradle.kts.jinja b/templates/1.20.1/{{ forge_path }}/build.gradle.kts.jinja new file mode 100644 index 00000000..7c1fcf58 --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/build.gradle.kts.jinja @@ -0,0 +1,81 @@ +plugins { + id("{{ modid }}.platform") +} + +val modId: String by project + +architectury { + forge() +} + +loom { + forge { + convertAccessWideners = true + extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name) + + mixinConfig("{{ modid }}-common.mixins.json", "{{ modid }}.mixins.json") + } + + runs { + register("commonDatagen") { + data() + programArgs( + "--mod", modId, + "--all", + // we use forge to do the common datagen because fabric's datagen kind of sucks + "--output", project(":Common").file("src/generated/resources").absolutePath, + "--existing", file("src/main/resources").absolutePath, + "--existing", project(":Common").file("src/main/resources").absolutePath, + ) + property("{{ modid }}.apply-datagen-mixin", "true") + } + } +} + +{{ modid }}ModDependencies { + filesMatching.add("META-INF/mods.toml") + + anyVersion = "" + mapVersions { + replace(Regex("""\](\S+)"""), "($1") + replace(Regex("""(\S+)\["""), "$1)") + } + + requires("architectury-api") + requires("cloth-config") + requires(curseforge = "hexcasting", modrinth = "hex-casting") + + requires("kotlin-for-forge") +} + +dependencies { + forge(libs.forge) + modApi(libs.architectury.forge) + + implementation(libs.kotlin.forge) + + modApi(libs.hexcasting.forge) { isTransitive = false } + modImplementation(libs.paucal.forge) + modLocalRuntime(libs.patchouli.forge) + modLocalRuntime(libs.caelus) + + modApi(libs.clothConfig.forge) + + libs.mixinExtras.also { + localRuntime(it) + include(it) + } +} + +tasks { + shadowJar { + exclude("fabric.mod.json") + } + + named("runCommonDatagen") { + doFirst { + // avoid keeping stale generated resources + project(":{{ common_path }}").delete("src/generated/resources") + } + } +} diff --git a/templates/1.20.1/{{ forge_path }}/gradle.properties b/templates/1.20.1/{{ forge_path }}/gradle.properties new file mode 100644 index 00000000..b8881f18 --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/gradle.properties @@ -0,0 +1,2 @@ +platform=forge +loom.platform=forge diff --git a/templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/ForgeMixinConfigPlugin.java.jinja b/templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/ForgeMixinConfigPlugin.java.jinja new file mode 100644 index 00000000..d8224067 --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/ForgeMixinConfigPlugin.java.jinja @@ -0,0 +1,42 @@ +package {{ package }}.forge.mixin; + +import {{ package }}.{{ base_classname }}; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +// disable MixinDatagenMain if we're not running the datagen task, since it's not necessary at any other time +public class ForgeMixinConfigPlugin implements IMixinConfigPlugin { + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (mixinClassName.equals("{{ package }}.forge.mixin.MixinDatagenMain")) { + var shouldApply = System.getProperty("{{ modid }}.apply-datagen-mixin", "false").equals("true"); + if (shouldApply) { + {{ base_classname }}.LOGGER.error("Applying scuffed datagen mixin. This should not happen if not running datagen!"); + } + return shouldApply; + } + return true; + } + + @Override + public void onLoad(String mixinPackage) {} + + @Override + public String getRefMapperConfig() { return null; } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) {} + + @Override + public List getMixins() { return null; } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} +} diff --git a/templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/MixinDatagenMain.java.jinja b/templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/MixinDatagenMain.java.jinja new file mode 100644 index 00000000..8f192d8c --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/MixinDatagenMain.java.jinja @@ -0,0 +1,17 @@ +package {{ package }}.forge.mixin; + +import {{ package }}.{{ base_classname }}; +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; + +// scuffed workaround for https://github.com/architectury/architectury-loom/issues/189 +@Mixin(net.minecraft.data.Main.class) +public class MixinDatagenMain { + @Inject(method = "main", at = @At("TAIL"), remap = false) + private static void {{ modid }}$systemExitAfterDatagenFinishes(String[] strings, CallbackInfo ci) { + {{ base_classname }}.LOGGER.info("Terminating datagen."); + System.exit(0); + } +} diff --git a/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}.kt.jinja b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}.kt.jinja new file mode 100644 index 00000000..4b600f32 --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}.kt.jinja @@ -0,0 +1,39 @@ +package {{ package }}.forge + +import dev.architectury.platform.forge.EventBuses +import {{ package }}.{{ base_classname }} +import {{ package }}.forge.datagen.{{ base_classname }}Models +import {{ package }}.forge.datagen.{{ base_classname }}Recipes +import net.minecraft.data.DataProvider +import net.minecraft.data.DataProvider.Factory +import net.minecraft.data.PackOutput +import net.minecraftforge.data.event.GatherDataEvent +import net.minecraftforge.fml.common.Mod +import thedarkcolour.kotlinforforge.forge.MOD_BUS + +/** + * This is your loading entrypoint on forge, in case you need to initialize + * something platform-specific. + */ +@Mod({{ base_classname }}.MODID) +class {{ base_classname }}Forge { + init { + MOD_BUS.apply { + EventBuses.registerModEventBus({{ base_classname }}.MODID, this) + addListener(Forge{{ base_classname }}Client::init) + addListener(::gatherData) + } + {{ base_classname }}.init() + } + + private fun gatherData(event: GatherDataEvent) { + event.apply { + val efh = existingFileHelper + addProvider(includeClient()) { {{ base_classname }}Models(it, efh) } + addProvider(includeServer()) { {{ base_classname }}Recipes(it) } + } + } +} + +fun GatherDataEvent.addProvider(run: Boolean, factory: (PackOutput) -> T) = + generator.addProvider(run, Factory { factory(it) }) diff --git a/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}Client.kt.jinja b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}Client.kt.jinja new file mode 100644 index 00000000..958ca39b --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/Forge{{ base_classname }}Client.kt.jinja @@ -0,0 +1,16 @@ +package {{ package }}.forge + +import {{ package }}.{{ base_classname }}Client +import {{ package }}.config.{{ base_classname }}Config +import net.minecraftforge.client.ConfigScreenHandler.ConfigScreenFactory +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent +import thedarkcolour.kotlinforforge.forge.LOADING_CONTEXT + +object Forge{{ base_classname }}Client { + fun init(event: FMLClientSetupEvent) { + {{ base_classname }}Client.init() + LOADING_CONTEXT.registerExtensionPoint(ConfigScreenFactory::class.java) { + ConfigScreenFactory { _, parent -> {{ base_classname }}Config.getConfigScreen(parent) } + } + } +} diff --git a/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Models.kt.jinja b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Models.kt.jinja new file mode 100644 index 00000000..384df03a --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Models.kt.jinja @@ -0,0 +1,37 @@ +@file:OptIn(ExperimentalStdlibApi::class) + +package {{ package }}.forge.datagen + +import {{ package }}.{{ base_classname }} +import {{ package }}.items.ItemDebugger +import {{ package }}.items.ItemDebugger.DebugState +import {{ package }}.items.ItemDebugger.StepMode +import {{ package }}.items.ItemEvaluator +import {{ package }}.items.ItemEvaluator.EvalState +import {{ package }}.registry.{{ base_classname }}Items +import {{ package }}.utils.itemPredicate +import net.minecraft.data.PackOutput +import net.minecraft.resources.ResourceLocation +import net.minecraftforge.client.model.generators.ItemModelProvider +import net.minecraftforge.client.model.generators.ModelBuilder +import net.minecraftforge.client.model.generators.ModelFile +import net.minecraftforge.common.data.ExistingFileHelper + +class {{ base_classname }}Models(output: PackOutput, efh: ExistingFileHelper) : ItemModelProvider(output, {{ base_classname }}.MODID, efh) { + override fun registerModels() { + basicItem({{ base_classname }}Items.DUMMY_ITEM.id) + .parent(ModelFile.UncheckedModelFile("item/handheld_rod")) + } +} + +// utility function for adding multiple possibly missing layers to a generated item model +fun > T.layers(start: Int, vararg layers: String?): T { + var index = start + for (layer in layers) { + if (layer != null) { + texture("layer$index", layer) + index += 1 + } + } + return this +} diff --git a/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Recipes.kt.jinja b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Recipes.kt.jinja new file mode 100644 index 00000000..822bd47c --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/datagen/{{ base_classname }}Recipes.kt.jinja @@ -0,0 +1,26 @@ +package {{ package }}.forge.datagen + +import at.petrak.hexcasting.api.mod.HexTags +import at.petrak.paucal.api.datagen.PaucalRecipeProvider +import {{ package }}.{{ base_classname }} +import {{ package }}.registry.{{ base_classname }}Items +import net.minecraft.data.PackOutput +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.ShapedRecipeBuilder +import net.minecraft.world.item.Items +import java.util.function.Consumer + +// we use Paucal's recipe provider as a base because it has a bunch of helpful stuff +class {{ base_classname }}Recipes(output: PackOutput) : PaucalRecipeProvider(output, {{ base_classname }}.MODID) { + override fun buildRecipes(writer: Consumer) { + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, {{ base_classname }}Items.DUMMY_ITEM.value) + .define('S', Items.STICK) + .define('A', Blocks.AMETHYST_BLOCK) + .pattern(" A") + .pattern(" S ") + .pattern("S ") + .unlockedBy("has_item", hasItem(HexTags.Items.STAVES)) + .save(writer) + } +} diff --git a/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/{{ base_classname }}AbstractionsImpl.kt.jinja b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/{{ base_classname }}AbstractionsImpl.kt.jinja new file mode 100644 index 00000000..b70c99df --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/kotlin/{{ package_path }}/forge/{{ base_classname }}AbstractionsImpl.kt.jinja @@ -0,0 +1,15 @@ +@file:JvmName("{{ base_classname }}AbstractionsImpl") + +package {{ package }}.forge + +import {{ package }}.registry.HexDebugRegistrar +import net.minecraftforge.registries.RegisterEvent +import thedarkcolour.kotlinforforge.forge.MOD_BUS + +fun initRegistry(registrar: HexDebugRegistrar) { + MOD_BUS.addListener { event: RegisterEvent -> + event.register(registrar.registryKey) { helper -> + registrar.init(helper::register) + } + } +} diff --git a/templates/1.20.1/{{ forge_path }}/src/main/resources/META-INF/mods.toml.jinja b/templates/1.20.1/{{ forge_path }}/src/main/resources/META-INF/mods.toml.jinja new file mode 100644 index 00000000..e4eac1b8 --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/resources/META-INF/mods.toml.jinja @@ -0,0 +1,46 @@ +modLoader = "kotlinforforge" +loaderVersion = "[${versions.kotlin_forge},)" +license = "MIT" + +[[mods]] +modId = "{{ modid }}" +version = "${modVersion}" +displayName = "{{ display_name }}" +logoFile = "icon.png" +authors = "{{ github_user }}" +description = "{{ description }}" + +[[dependencies.{{ modid }}]] +modId = "forge" +mandatory = true +versionRange = "[${versions.forge_dependency},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.{{ modid }}]] +modId = "minecraft" +mandatory = true +versionRange = "[${versions.minecraft},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.{{ modid }}]] +modId = "architectury" +mandatory = true +versionRange = "[${versions.architectury},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.{{ modid }}]] +modId = "cloth_config" +mandatory = true +versionRange = "[${versions.cloth_config},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.{{ modid }}]] +modId = "hexcasting" +mandatory = true +versionRange = "[${versions.hexcasting},)" +ordering = "NONE" +side = "BOTH" diff --git a/templates/1.20.1/{{ forge_path }}/src/main/resources/pack.mcmeta.jinja b/templates/1.20.1/{{ forge_path }}/src/main/resources/pack.mcmeta.jinja new file mode 100644 index 00000000..74f18bd8 --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/resources/pack.mcmeta.jinja @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "{{ display_name }} Resources", + "pack_format": 9 + } +} diff --git a/templates/1.20.1/{{ forge_path }}/src/main/resources/{{ modid }}.mixins.json.jinja b/templates/1.20.1/{{ forge_path }}/src/main/resources/{{ modid }}.mixins.json.jinja new file mode 100644 index 00000000..bc18b220 --- /dev/null +++ b/templates/1.20.1/{{ forge_path }}/src/main/resources/{{ modid }}.mixins.json.jinja @@ -0,0 +1,15 @@ +{ + "required": true, + "package": "{{ package }}.forge.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + ], + "mixins": [ + "MixinDatagenMain" + ], + "plugin": "{{ package }}.forge.mixin.ForgeMixinConfigPlugin", + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file