Create forge and neoforge versions

Changed files
+360 -124
src
main
java
xyz
naomieow
resources
META-INF
resourcepacks
legacy
data
minecraft
worldgen
structure_set
versions
1.19
1.19-fabric
1.19-forge
1.19.3-forge
1.21
1.21-fabric
1.21-neoforge
+54 -28
build.gradle.kts
··· 1 1 plugins { 2 - id("fabric-loom") version "1.7-SNAPSHOT" 2 + id("dev.architectury.loom") version "1.7-SNAPSHOT" apply true 3 3 id("maven-publish") 4 4 } 5 5 ··· 9 9 val name = property("mod.name").toString() 10 10 val version = property("mod.version").toString() 11 11 val group = property("mod.group").toString() 12 + val loader = property("loom.platform").toString() 12 13 } 13 14 14 15 class ModDeps { 15 16 operator fun get(name: String) = property("deps.$name").toString() 16 17 } 17 18 19 + 18 20 val mod = ModData() 19 21 val deps = ModDeps() 20 22 val mcVersion = stonecutter.current.version 21 23 24 + val isFabric = mod.loader == "fabric" 25 + val isForge = mod.loader == "forge" 26 + val isNeoforge = mod.loader == "neoforge" 27 + val isForgelike = isForge || isNeoforge 28 + 22 29 version = "${mod.version}+$mcVersion" 23 30 group = mod.group 31 + 24 32 base { archivesName.set(mod.id) } 25 33 26 34 loom { 27 - splitEnvironmentSourceSets() 28 - 29 - mods { 30 - create("template") { 31 - sourceSet(sourceSets["main"]) 32 - sourceSet(sourceSets["client"]) 33 - } 35 + runConfigs.all { 36 + ideConfigGenerated(false) 37 + runDir("../../run") 34 38 } 35 39 } 36 40 37 41 repositories { 38 42 mavenCentral() 43 + maven("https://maven.parchmentmc.org") 44 + maven("https://maven.neoforged.net/releases/") 39 45 } 40 46 41 47 dependencies { 42 - fun fapi(vararg modules: String) { 43 - modules.forEach { fabricApi.module(it, deps["fapi"]) } 44 - } 48 + mappings(loom.layered { 49 + // breaks for some reason 50 + // parchment("org.parchmentmc.data:parchment-${deps["parchment"]}@zip") 51 + officialMojangMappings() 52 + }) 45 53 54 + if (isFabric) { 55 + modImplementation("net.fabricmc:fabric-loader:${deps["fabric_loader"]}") 56 + fun fapi(vararg modules: String) { 57 + modules.forEach { fabricApi.module(it, deps["fapi"]) } 58 + } 59 + modImplementation("net.fabricmc.fabric-api:fabric-api:${deps["fabric_api"]}") 60 + } 61 + if (isForge) { 62 + "forge"("net.minecraftforge:forge:${deps["forge"]}") 63 + } 64 + if (isNeoforge) { 65 + "neoForge"("net.neoforged:neoforge:${deps["neoforge"]}") 66 + } 46 67 minecraft("com.mojang:minecraft:${deps["minecraft_run"]}") 47 - mappings("net.fabricmc:yarn:${deps["yarn_mappings"]}:v2") 48 - modImplementation("net.fabricmc:fabric-loader:${deps["fabric_loader"]}") 49 - modImplementation("net.fabricmc.fabric-api:fabric-api:${deps["fabric_api"]}") 50 - vineflowerDecompilerClasspath("org.vineflower:vineflower:1.10.1") 51 68 52 69 } 53 70 ··· 59 76 } 60 77 61 78 tasks.processResources { 62 - inputs.property("id", mod.id) 63 - inputs.property("name", mod.name) 64 - inputs.property("version", mod.version) 65 - inputs.property("minecraft", deps["minecraft"]) 66 - inputs.property("incendium", deps["incendium"]) 79 + val props = buildMap { 80 + put("id", mod.id) 81 + put("name", mod.name) 82 + put("version", mod.version) 83 + put("minecraft", deps["minecraft"]) 84 + put("incendium", deps["incendium"]) 85 + if (isForgelike) { 86 + put("forgeId", deps["forge_id"]) 87 + put("forgeConstraint", deps["forge_constraint"]) 88 + } 89 + } 90 + 91 + props.forEach(inputs::property) 67 92 68 - val map = mapOf( 69 - "id" to mod.id, 70 - "name" to mod.name, 71 - "version" to mod.version, 72 - "minecraft" to deps["minecraft"], 73 - "incendium" to deps["incendium"], 74 - ) 93 + if (isFabric) { 94 + filesMatching("fabric.mod.json") { expand(props) } 95 + exclude(listOf("META-INF/mods.toml", "META-INF/neoforge.mods.toml")) 96 + } 75 97 76 - filesMatching("fabric.mod.json") { expand(map) } 98 + if (isForgelike) { 99 + filesMatching(listOf("META-INF/mods.toml", "META-INF/neoforge.mods.toml")) { expand(props) } 100 + exclude("fabric.mod.json") 101 + } 77 102 } 78 103 79 104 tasks.register<Copy>("buildAndCollect") { 80 105 group = "build" 81 106 from(tasks.remapJar.get().archiveFile) 82 107 into(rootProject.layout.buildDirectory.file("libs/${mod.version}")) 108 + rename { "ibo-${mod.version}+${mod.loader}+$mcVersion.jar" } 83 109 dependsOn("build") 84 110 } 85 111
+4 -5
gradle.properties
··· 5 5 # Mod Details 6 6 mod.id=ibo 7 7 mod.name=Incendium Biomes Only 8 - mod.version=2.0.0 8 + mod.version=2.1.0 9 9 mod.group=xyz.naomieow 10 - 11 - # Global deps 12 - deps.fabric_loader=0.15.11 13 10 14 11 # Versioned deps 12 + deps.fabric_loader=[VERSIONED] 15 13 deps.minecraft=[VERSIONED] 16 14 deps.minecraft_run=[VERSIONED] 17 15 deps.fabric_api=[VERSIONED] 18 - deps.yarn_mappings=[VERSIONED] 16 + deps.parchment=[VERSIONED] 17 + deps.forge_id=[VERSIONED]
+13 -3
settings.gradle.kts
··· 4 4 repositories { 5 5 mavenCentral() 6 6 gradlePluginPortal() 7 - maven("https://maven.fabricmc.net/") 8 7 maven("https://maven.kikugie.dev/releases") 8 + maven("https://maven.fabricmc.net/") 9 + maven("https://maven.architectury.dev") 10 + maven("https://maven.neoforged.net/releases/") 11 + maven("https://maven.minecraftforge.net/") 9 12 } 10 13 } 11 14 12 15 plugins { 13 - id("dev.kikugie.stonecutter") version "0.4.3" 16 + id("dev.kikugie.stonecutter") version "0.4.3" apply true 14 17 } 15 18 16 19 ··· 19 22 centralScript = "build.gradle.kts" 20 23 21 24 shared { 22 - versions("1.19", "1.21") 25 + fun mc(version: String, name: String = version, loaders: Iterable<String>) { 26 + for (loader in loaders) { 27 + vers("$name-$loader", version) 28 + } 29 + } 30 + mc("1.19", loaders = listOf("fabric", "forge")) 31 + mc("1.19.3", loaders = listOf("forge")) 32 + mc("1.21", loaders = listOf("fabric", "neoforge")) 23 33 } 24 34 25 35 create(rootProject)
+156 -8
src/main/java/xyz/naomieow/ibo/IboMod.java
··· 1 1 package xyz.naomieow.ibo; 2 2 3 - import net.fabricmc.api.ModInitializer; 3 + import net.minecraft.network.chat.Component; 4 + import net.minecraft.resources.ResourceLocation; 4 5 6 + //? if fabric { 7 + /*import net.fabricmc.api.ModInitializer; 5 8 import net.fabricmc.fabric.api.resource.ResourceManagerHelper; 6 9 import net.fabricmc.fabric.api.resource.ResourcePackActivationType; 7 10 import net.fabricmc.loader.api.FabricLoader; 8 - import net.minecraft.util.Identifier; 11 + *///?} elif neoforge { 12 + /*import net.minecraft.server.packs.PackLocationInfo; 13 + import net.minecraft.server.packs.PackSelectionConfig; 14 + import net.minecraft.server.packs.PackType; 15 + import net.minecraft.server.packs.PathPackResources; 16 + import net.minecraft.server.packs.repository.Pack; 17 + import net.minecraft.server.packs.repository.PackSource; 18 + import net.minecraft.network.chat.Component; 19 + import net.neoforged.bus.api.IEventBus; 20 + import net.neoforged.fml.ModList; 21 + import net.neoforged.fml.common.Mod; 22 + import net.neoforged.neoforge.event.AddPackFindersEvent; 23 + 24 + import java.nio.file.Path; 25 + import java.util.Optional; 26 + *///?} elif forge { 27 + import net.minecraft.server.packs.PackType; 28 + import net.minecraft.server.packs.repository.Pack; 29 + import net.minecraft.server.packs.repository.PackSource; 30 + import net.minecraftforge.event.AddPackFindersEvent; 31 + import net.minecraftforge.eventbus.api.IEventBus; 32 + import net.minecraftforge.fml.ModList; 33 + import net.minecraftforge.fml.common.Mod; 34 + import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; 9 35 10 - public class IboMod implements ModInitializer { 36 + import java.nio.file.Path; 37 + //?} 11 38 12 - public static Identifier getIdentifier(String namespace, String path) { 39 + //? if <1.19.3 && forge { 40 + /*import net.minecraftforge.resource.PathPackResources; 41 + import net.minecraft.server.packs.metadata.pack.PackMetadataSection; 42 + 43 + import java.io.IOException; 44 + *///?} 45 + 46 + //? if >=1.19.3 && forge { 47 + import net.minecraft.server.packs.PathPackResources; 48 + import net.minecraft.server.packs.PackResources; 49 + //?} 50 + 51 + //? if forge-like 52 + @Mod("ibo") 53 + public class IboMod 54 + //? if fabric 55 + /*implements ModInitializer*/ 56 + { 57 + 58 + public static ResourceLocation rl(String namespace, String path) { 13 59 //? if >=1.21 { 14 - /*return Identifier.of(namespace, path); 60 + /*return ResourceLocation.tryBuild(namespace, path); 15 61 *///?} else 16 - return new Identifier(namespace, path); 62 + return new ResourceLocation(namespace, path); 17 63 } 18 64 19 - @Override 65 + 66 + //? if forge { 67 + 68 + public IboMod() { 69 + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); 70 + modEventBus.addListener(this::registerIBOPack); 71 + } 72 + //?} 73 + 74 + //? if <1.19.3 && forge { 75 + /*private void registerIBOPack(final AddPackFindersEvent event) { 76 + if (event.getPackType() == PackType.SERVER_DATA) { 77 + try { 78 + Path path = ModList.get() 79 + .getModFileById("ibo") 80 + .getFile() 81 + .findResource("resourcepacks/ibo"); 82 + PathPackResources datapack = new PathPackResources( 83 + ModList.get() 84 + .getModFileById("ibo") 85 + .getFile() 86 + .getFileName() + ":ibo", 87 + path 88 + ); 89 + PackMetadataSection mcmeta = datapack.m_5550_(PackMetadataSection.SERIALIZER); 90 + if (mcmeta != null) { 91 + event.addRepositorySource((consumer, constructor) -> consumer.accept(constructor.create( 92 + "ibo/ibo", 93 + Component.m_130674_("Incendium Biomes Only"), 94 + true, 95 + () -> datapack, 96 + mcmeta, 97 + Pack.Position.TOP, 98 + PackSource.BUILT_IN 99 + ))); 100 + } 101 + 102 + } catch (IOException e) { 103 + throw new RuntimeException(e); 104 + } 105 + } 106 + } 107 + *///?} 108 + 109 + //? if >=1.19.3 && forge { 110 + private void registerIBOPack(final AddPackFindersEvent event) { 111 + if (event.getPackType() == PackType.SERVER_DATA) { 112 + Path path = ModList.get().getModFileById("ibo").getFile().findResource("resourcepacks/ibo"); 113 + Pack ibo = Pack.readMetaAndCreate( 114 + "", 115 + Component.literal("Incendium Biomes Only"), 116 + false, 117 + new Pack.ResourcesSupplier() {@Override 118 + public PackResources open(String string) { 119 + return new PathPackResources( 120 + path.getFileName().toString(), 121 + path, 122 + false 123 + ); 124 + } 125 + }, 126 + PackType.SERVER_DATA, 127 + Pack.Position.TOP, 128 + PackSource.BUILT_IN 129 + ); 130 + 131 + event.addRepositorySource((consumer) -> consumer.accept(ibo)); 132 + } 133 + } 134 + //?} 135 + 136 + //? if neoforge { 137 + /*public IboMod(IEventBus modEventBus) { 138 + modEventBus.addListener(this::registerIBOPack); 139 + } 140 + 141 + private void registerIBOPack(final AddPackFindersEvent event) { 142 + if (event.getPackType() == PackType.SERVER_DATA) { 143 + Path path = ModList.get().getModFileById("ibo").getFile().findResource("resourcepacks/ibo"); 144 + Pack ibo = Pack.readMetaAndCreate( 145 + new PackLocationInfo( 146 + path.getFileName().toString(), 147 + Component.literal("Incendium Biomes Only"), 148 + PackSource.BUILT_IN, 149 + Optional.empty() 150 + ), 151 + new PathPackResources.PathResourcesSupplier(path), 152 + PackType.SERVER_DATA, 153 + new PackSelectionConfig( 154 + true, 155 + Pack.Position.TOP, 156 + false 157 + ) 158 + ); 159 + 160 + event.addRepositorySource((consumer) -> consumer.accept(ibo)); 161 + } 162 + } 163 + *///?} 164 + 165 + //? if fabric { 166 + /*@Override 20 167 public void onInitialize() { 21 168 FabricLoader.getInstance().getModContainer("ibo").ifPresent((modContainer -> ResourceManagerHelper.registerBuiltinResourcePack( 22 - getIdentifier("ibo", "ibo"), 169 + rl("ibo", "ibo"), 23 170 modContainer, 24 171 "Incendium Biomes Only", 25 172 ResourcePackActivationType.ALWAYS_ENABLED 26 173 ))); 27 174 } 175 + *///?} 28 176 }
+35
src/main/resources/META-INF/mods.toml
··· 1 + modLoader = "javafml" 2 + loaderVersion = "[1,)" 3 + issueTrackerURL = "https://codeberg.org/naomi/ibo/issues" 4 + license = "LGPL-v3" 5 + 6 + [[mods]] 7 + modId = "${id}" 8 + version = "${version}" 9 + displayName = "${name}" 10 + authors = "Naomi Roberts <mia@naomieow.xyz>" 11 + description = ''' 12 + Disables everything but biomes in Incendium 13 + ''' 14 + logoFile = "icon.png" 15 + 16 + [["dependencies.${id}"]] 17 + modId = "${forgeId}" 18 + mandatory = true 19 + versionRange = "${forgeConstraint}" 20 + ordering = "NONE" 21 + side = "BOTH" 22 + 23 + [["dependencies.${id}"]] 24 + modId = "minecraft" 25 + mandatory = true 26 + versionRange = "${minecraft}" 27 + ordering = "NONE" 28 + side = "BOTH" 29 + 30 + [["dependencies.${id}"]] 31 + modId = "incendium" 32 + mandatory = true 33 + versionRange = "${incendium}" 34 + ordering = "AFTER" 35 + side = "SERVER"
+35
src/main/resources/META-INF/neoforge.mods.toml
··· 1 + modLoader = "javafml" 2 + loaderVersion = "[1,)" 3 + issueTrackerURL = "https://codeberg.org/naomi/ibo/issues" 4 + license = "LGPL-v3" 5 + 6 + [[mods]] 7 + modId = "${id}" 8 + version = "${version}" 9 + displayName = "${name}" 10 + authors = "Naomi Roberts <mia@naomieow.xyz>" 11 + description = ''' 12 + Disables everything but biomes in Incendium 13 + ''' 14 + logoFile = "icon.png" 15 + 16 + [["dependencies.${id}"]] 17 + modId = "${forgeId}" 18 + mandatory = true 19 + versionRange = "${forgeConstraint}" 20 + ordering = "NONE" 21 + side = "BOTH" 22 + 23 + [["dependencies.${id}"]] 24 + modId = "minecraft" 25 + mandatory = true 26 + versionRange = "${minecraft}" 27 + ordering = "NONE" 28 + side = "BOTH" 29 + 30 + [["dependencies.${id}"]] 31 + modId = "incendium" 32 + mandatory = true 33 + versionRange = "${incendium}" 34 + ordering = "AFTER" 35 + side = "SERVER"
+1
src/main/resources/fabric.mod.json
··· 4 4 "version": "${version}", 5 5 "name": "${name}", 6 6 "description": "Disables everything but biomes in Incendium", 7 + "icon": "icon.png", 7 8 "authors": [ 8 9 "Naomi Roberts <mia@naomieow.xyz>" 9 10 ],
+6
src/main/resources/pack.mcmeta
··· 1 + { 2 + "pack": { 3 + "pack_format": 10, 4 + "description": "Disables everything but biomes in Incendium" 5 + } 6 + }
-18
src/main/resources/resourcepacks/legacy/data/minecraft/worldgen/structure_set/nether_complexes.json
··· 1 - { 2 - "placement": { 3 - "type": "minecraft:random_spread", 4 - "salt": 30084232, 5 - "separation": 4, 6 - "spacing": 27 7 - }, 8 - "structures": [ 9 - { 10 - "structure": "minecraft:fortress", 11 - "weight": 2 12 - }, 13 - { 14 - "structure": "minecraft:bastion_remnant", 15 - "weight": 3 16 - } 17 - ] 18 - }
-50
src/main/resources/resourcepacks/legacy/pack.mcmeta
··· 1 - { 2 - "pack": { 3 - "pack_format": 10, 4 - "description": "Disables everything but biomes in Incendium" 5 - }, 6 - "filter": { 7 - "block": [ 8 - { 9 - "namespace": "incendium", 10 - "path": "functions/.*" 11 - }, 12 - { 13 - "namespace": "incendium", 14 - "path": "structures/.*" 15 - }, 16 - { 17 - "namespace": "incendium", 18 - "path": "advancements/.*" 19 - }, 20 - { 21 - "namespace": "incendium", 22 - "path": "loot_tables/.*" 23 - }, 24 - { 25 - "namespace": "incendium", 26 - "path": "item_modifiers/.*" 27 - }, 28 - { 29 - "namespace": "incendium", 30 - "path": "predicates/.*" 31 - }, 32 - { 33 - "namespace": "incendium", 34 - "path": "recipes/.*" 35 - }, 36 - { 37 - "namespace": "incendium", 38 - "path": "worldgen/structure/.*" 39 - }, 40 - { 41 - "namespace": "incendium", 42 - "path": "worldgen/structure_set/.*" 43 - }, 44 - { 45 - "namespace": "incendium", 46 - "path": "worldgen/template_pool/.*" 47 - } 48 - ] 49 - } 50 - }
src/main/resources/resourcepacks/legacy/pack.png src/main/resources/icon.png
+13 -2
stonecutter.gradle.kts
··· 1 1 plugins { 2 2 id("dev.kikugie.stonecutter") 3 + id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false 3 4 } 4 - stonecutter active "1.19" /* [SC] DO NOT EDIT */ 5 + stonecutter active "1.19.3-forge" /* [SC] DO NOT EDIT */ 5 6 6 7 stonecutter registerChiseled tasks.register("chiseledBuildAndCollect", stonecutter.chiseled) { 7 8 group = "project" 8 9 ofTask("buildAndCollect") 9 10 } 10 11 11 - stonecutter.configureEach {} 12 + stonecutter.configureEach { 13 + val platform = project.property("loom.platform") 14 + 15 + fun String.propDefined() = project.findProperty(this)?.toString()?.isNotBlank() ?: false 16 + consts(listOf( 17 + "fabric" to (platform == "fabric"), 18 + "forge" to (platform == "forge"), 19 + "neoforge" to (platform == "neoforge"), 20 + "forge-like" to (platform == "forge" || platform == "neoforge"), 21 + )) 22 + }
+8
versions/1.19-fabric/gradle.properties
··· 1 + loom.platform=fabric 2 + 3 + deps.minecraft=>=1.19- <1.21- 4 + deps.minecraft_run=1.19 5 + deps.fabric_api=0.58.0+1.19 6 + deps.parchment=1.19.2:2022.11.27 7 + deps.incendium=>=5.1.0 8 + deps.fabric_loader=0.15.0
+9
versions/1.19-forge/gradle.properties
··· 1 + loom.platform=forge 2 + 3 + deps.minecraft=[1.19,1.19.3) 4 + deps.minecraft_run=1.19 5 + deps.parchment=1.19.2:2022.11.27 6 + deps.incendium=5.1.0 7 + deps.forge=1.19-41.1.0 8 + deps.forge_constraint=[41,) 9 + deps.forge_id=forge
+9
versions/1.19.3-forge/gradle.properties
··· 1 + loom.platform=forge 2 + 3 + deps.minecraft=[1.19.3,1.21) 4 + deps.minecraft_run=1.19.3 5 + deps.parchment=1.19.2:2022.11.27 6 + deps.incendium=5.1.0 7 + deps.forge=1.19.3-44.1.23 8 + deps.forge_constraint=[44,) 9 + deps.forge_id=forge
-5
versions/1.19/gradle.properties
··· 1 - deps.minecraft=>=1.19- <1.21- 2 - deps.minecraft_run=1.19 3 - deps.fabric_api=0.58.0+1.19 4 - deps.yarn_mappings=1.19+build.4 5 - deps.incendium=>=5.1.0
+8
versions/1.21-fabric/gradle.properties
··· 1 + loom.platform=fabric 2 + 3 + deps.minecraft=>=1.21 4 + deps.minecraft_run=1.21 5 + deps.fabric_api=0.101.2+1.21 6 + deps.parchment=1.21:2024.07.28 7 + deps.incendium=5.4.0 8 + deps.fabric_loader=0.15.0
+9
versions/1.21-neoforge/gradle.properties
··· 1 + loom.platform=neoforge 2 + 3 + deps.minecraft=1.21 4 + deps.minecraft_run=1.21 5 + deps.parchment=1.21:2024.07.28 6 + deps.incendium=5.4.0 7 + deps.neoforge=21.0.0-beta 8 + deps.forge_constraint=[21,) 9 + deps.forge_id=neoforge
-5
versions/1.21/gradle.properties
··· 1 - deps.minecraft=>=1.21 2 - deps.minecraft_run=1.21 3 - deps.fabric_api=0.101.2+1.21 4 - deps.yarn_mappings=1.21+build.9 5 - deps.incendium=5.4.0