forked from artynova/hexdummy
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add all subprojects and most of the platform code (not yet mapping-ed)
- Loading branch information
1 parent
da68bef
commit b71369c
Showing
21 changed files
with
548 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
platform=common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
platform=fabric |
10 changes: 10 additions & 0 deletions
10
.../{{ fabric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}.kt.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...bric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}Client.kt.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ric_path }}/src/main/kotlin/{{ package_path }}/Fabric{{ base_classname }}ModMenu.kt.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
11 changes: 11 additions & 0 deletions
11
..._path }}/src/main/kotlin/{{ package_path }}/{{ base_classname }}AbstractionsImpl.kt.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@file:JvmName("{{ base_classname }}AbstractionsImpl") | ||
|
||
package {{ package }}.fabric | ||
|
||
import {{ package }}.registry.HexDebugRegistrar | ||
import net.minecraft.core.Registry | ||
|
||
fun <T : Any> initRegistry(registrar: HexDebugRegistrar<T>) { | ||
val registry = registrar.registry | ||
registrar.init { id, value -> Registry.register(registry, id, value) } | ||
} |
46 changes: 46 additions & 0 deletions
46
templates/1.20.1/{{ fabric_path }}/src/main/resources/fabric.mod.json.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
platform=forge | ||
loom.platform=forge |
42 changes: 42 additions & 0 deletions
42
...ge_path }}/src/main/java/{{ package_path }}/forge/mixin/ForgeMixinConfigPlugin.java.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> myTargets, Set<String> otherTargets) {} | ||
|
||
@Override | ||
public List<String> 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) {} | ||
} |
17 changes: 17 additions & 0 deletions
17
...{{ forge_path }}/src/main/java/{{ package_path }}/forge/mixin/MixinDatagenMain.java.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.