mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
Fix dev launch for fabric and forge
This commit is contained in:
parent
d7be33fa55
commit
18de2c3f99
5
.gitignore
vendored
5
.gitignore
vendored
@ -246,4 +246,7 @@ nbdist/
|
|||||||
/run/
|
/run/
|
||||||
|
|
||||||
**/testDir/
|
**/testDir/
|
||||||
platforms/fabric/run/config/Terra/config.yml
|
|
||||||
|
platforms/fabric/run/**
|
||||||
|
|
||||||
|
platforms/forge/run/**
|
||||||
|
@ -20,11 +20,8 @@ object Versions {
|
|||||||
object Fabric {
|
object Fabric {
|
||||||
const val fabricLoader = "0.14.2"
|
const val fabricLoader = "0.14.2"
|
||||||
const val fabricAPI = "0.56.0+1.19"
|
const val fabricAPI = "0.56.0+1.19"
|
||||||
const val minecraft = "1.19"
|
|
||||||
const val yarn = "$minecraft+build.1"
|
|
||||||
const val mixin = "0.11.2+mixin.0.8.5"
|
const val mixin = "0.11.2+mixin.0.8.5"
|
||||||
const val loom = "0.12-SNAPSHOT"
|
const val loom = "0.12-SNAPSHOT"
|
||||||
const val loomQuiltflower = "1.7.1"
|
|
||||||
const val minotaur = "1.1.0"
|
const val minotaur = "1.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,13 +32,13 @@ object Versions {
|
|||||||
|
|
||||||
const val architecuryLoom = "0.12.0-SNAPSHOT"
|
const val architecuryLoom = "0.12.0-SNAPSHOT"
|
||||||
const val architectutyPlugin = "3.4-SNAPSHOT"
|
const val architectutyPlugin = "3.4-SNAPSHOT"
|
||||||
|
|
||||||
|
const val loomQuiltflower = "1.7.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
object Forge {
|
object Forge {
|
||||||
const val minecraft = "1.19"
|
const val forge = "${Mod.minecraft}-41.0.38"
|
||||||
const val forge = "$minecraft-41.0.38"
|
const val burningwave = ""
|
||||||
const val yarn = "$minecraft+build.1"
|
|
||||||
const val architecuryLoom = "0.12.0-SNAPSHOT"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object Bukkit {
|
object Bukkit {
|
||||||
|
@ -96,7 +96,6 @@ public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAdd
|
|||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getID() {
|
public String getID() {
|
||||||
return "BOOTSTRAP";
|
return "BOOTSTRAP";
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("fabric-loom") version Versions.Fabric.loom
|
id("fabric-loom") version Versions.Fabric.loom
|
||||||
id("io.github.juuxel.loom-quiltflower") version Versions.Fabric.loomQuiltflower
|
id("architectury-plugin") version Versions.Mod.architectutyPlugin
|
||||||
|
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -20,12 +21,12 @@ dependencies {
|
|||||||
"common"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
"common"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||||
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionFabric")) { isTransitive = false }
|
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionFabric")) { isTransitive = false }
|
||||||
|
|
||||||
minecraft("com.mojang:minecraft:${Versions.Fabric.minecraft}")
|
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||||
mappings("net.fabricmc:yarn:${Versions.Fabric.yarn}:v2")
|
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||||
|
|
||||||
modImplementation("net.fabricmc:fabric-loader:${Versions.Fabric.fabricLoader}")
|
modImplementation("net.fabricmc:fabric-loader:${Versions.Fabric.fabricLoader}")
|
||||||
|
|
||||||
setOf("fabric-lifecycle-events-v1", "fabric-resource-loader-v0", "fabric-api-base", "fabric-command-api-v2").forEach { apiModule ->
|
setOf("fabric-lifecycle-events-v1", "fabric-resource-loader-v0", "fabric-api-base", "fabric-command-api-v2", "fabric-networking-api-v1").forEach { apiModule ->
|
||||||
val module = fabricApi.module(apiModule, Versions.Fabric.fabricAPI)
|
val module = fabricApi.module(apiModule, Versions.Fabric.fabricAPI)
|
||||||
modImplementation(module)
|
modImplementation(module)
|
||||||
include(module)
|
include(module)
|
||||||
@ -36,16 +37,16 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
accessWidenerPath.set(project(":platforms:mixin-common").file("src/main/resources/terra.accesswidener"))
|
accessWidenerPath.set(project(":platforms:mixin-common").file("terra.accesswidener"))
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
defaultRefmapName.set("terra-fabric-refmap.json")
|
defaultRefmapName.set("terra.fabric.refmap.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addonDir(project.file("./run/config/Terra/addons"), tasks.named("runClient").get())
|
addonDir(project.file("./run/config/Terra/addons"), tasks.named("configureLaunch").get())
|
||||||
addonDir(project.file("./run/config/Terra/addons"), tasks.named("runServer").get())
|
|
||||||
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
compileJava {
|
compileJava {
|
||||||
@ -56,4 +57,8 @@ tasks {
|
|||||||
inputFile.set(shadowJar.get().archiveFile)
|
inputFile.set(shadowJar.get().archiveFile)
|
||||||
archiveFileName.set("${rootProject.name.capitalize()}-${project.version}.jar")
|
archiveFileName.set("${rootProject.name.capitalize()}-${project.version}.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
from(project(":platforms:mixin-common").file("terra.accesswidener"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"terra.fabric.mixins.json"
|
"terra.fabric.mixins.json",
|
||||||
|
"terra.common.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.2",
|
"fabricloader": ">=0.14.2",
|
||||||
|
@ -16,6 +16,5 @@
|
|||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
}
|
||||||
"refmap": "terra-fabric-refmap.json"
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Forge.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architectutyPlugin
|
id("architectury-plugin") version Versions.Mod.architectutyPlugin
|
||||||
id("io.github.juuxel.loom-quiltflower") version Versions.Fabric.loomQuiltflower
|
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
@ -17,34 +17,43 @@ configurations {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
shadedApi(project(":common:implementation:base"))
|
shadedApi(project(":common:implementation:base"))
|
||||||
|
"forgeRuntimeLibrary"(project(":common:implementation:base"))
|
||||||
|
|
||||||
|
|
||||||
"common"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
"common"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||||
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionForge")) { isTransitive = false }
|
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionForge")) { isTransitive = false }
|
||||||
"developmentForge"(project(":platforms:mixin-common", configuration = "namedElements")) {
|
"developmentForge"(project(path = ":platforms:mixin-common", configuration = "namedElements")) {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
forge(group = "net.minecraftforge", name = "forge", version = Versions.Forge.forge)
|
forge(group = "net.minecraftforge", name = "forge", version = Versions.Forge.forge)
|
||||||
|
|
||||||
minecraft("com.mojang:minecraft:${Versions.Forge.minecraft}")
|
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||||
mappings("net.fabricmc:yarn:${Versions.Forge.yarn}:v2")
|
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||||
|
|
||||||
|
//forge is not ok.
|
||||||
|
compileOnly("org.burningwave:core:12.53.0")
|
||||||
|
"forgeRuntimeLibrary"("org.burningwave:core:12.53.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
accessWidenerPath.set(project(":platforms:mixin-common").file("src/main/resources/terra.accesswidener"))
|
accessWidenerPath.set(project(":platforms:mixin-common").file("terra.accesswidener"))
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
defaultRefmapName.set("terra-forge-refmap.json")
|
defaultRefmapName.set("terra.forge.refmap.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
forge {
|
forge {
|
||||||
convertAccessWideners.set(true)
|
convertAccessWideners.set(true)
|
||||||
mixinConfig("terra.common.mixins.json")
|
mixinConfig("terra.common.mixins.json")
|
||||||
mixinConfig("terra.forge.mixins.json")
|
mixinConfig("terra.forge.mixins.json")
|
||||||
|
extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addonDir(project.file("./run/config/Terra/addons"), tasks.named("configureLaunch").get())
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
jar {
|
jar {
|
||||||
@ -66,4 +75,8 @@ tasks {
|
|||||||
inputFile.set(shadowJar.get().archiveFile)
|
inputFile.set(shadowJar.get().archiveFile)
|
||||||
archiveFileName.set("${rootProject.name.capitalize()}-${project.version}.jar")
|
archiveFileName.set("${rootProject.name.capitalize()}-${project.version}.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
from(project(":platforms:mixin-common").file("terra.accesswidener"))
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,16 +1,34 @@
|
|||||||
package com.dfsek.terra.forge;
|
package com.dfsek.terra.forge;
|
||||||
|
|
||||||
|
import com.dfsek.terra.AbstractPlatform;
|
||||||
|
|
||||||
|
import cpw.mods.cl.ModuleClassLoader;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import org.burningwave.core.classes.Classes;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.file.FileVisitOption;
|
import java.nio.file.FileVisitOption;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forge is really wacky and screws with class resolution in the addon loader. Loading every single Terra class *manually* on startup
|
* Forge is really wacky and screws with class resolution in the addon loader. Loading every single Terra class *manually* on startup
|
||||||
@ -33,7 +51,7 @@ public final class AwfulForgeHacks {
|
|||||||
*/
|
*/
|
||||||
public static JarFile getTerraJar() throws IOException {
|
public static JarFile getTerraJar() throws IOException {
|
||||||
LOGGER.info("Scanning for Terra JAR...");
|
LOGGER.info("Scanning for Terra JAR...");
|
||||||
return Files.walk(Path.of("./", "mods"), 1, FileVisitOption.FOLLOW_LINKS)
|
return Files.walk(Path.of(System.getProperty("user.dir"), "mods"), 1, FileVisitOption.FOLLOW_LINKS)
|
||||||
.filter(it -> it.getFileName().toString().endsWith(".jar"))
|
.filter(it -> it.getFileName().toString().endsWith(".jar"))
|
||||||
.peek(path -> LOGGER.info("Found mod: {}", path))
|
.peek(path -> LOGGER.info("Found mod: {}", path))
|
||||||
.map(Path::toFile)
|
.map(Path::toFile)
|
||||||
@ -52,11 +70,10 @@ public final class AwfulForgeHacks {
|
|||||||
.equals(ForgeEntryPoint.class.getName().replace('.', '/') + ".class")))
|
.equals(ForgeEntryPoint.class.getName().replace('.', '/') + ".class")))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow(() -> new IllegalStateException("Could not find Terra JAR"));
|
.orElseThrow(() -> new IllegalStateException("Could not find Terra JAR"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAllTerraClasses() {
|
public static void loadAllTerraClasses() {
|
||||||
|
if (FMLLoader.isProduction()) {
|
||||||
try(JarFile jar = getTerraJar()) {
|
try(JarFile jar = getTerraJar()) {
|
||||||
jar.stream()
|
jar.stream()
|
||||||
.forEach(jarEntry -> {
|
.forEach(jarEntry -> {
|
||||||
@ -77,6 +94,52 @@ public final class AwfulForgeHacks {
|
|||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new IllegalStateException("Could not load all Terra classes", e);
|
throw new IllegalStateException("Could not load all Terra classes", e);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Forgive me for what I'm about to do...
|
||||||
|
LOGGER.warn("I felt a great disturbance in the JVM, as if millions of class not found exceptions suddenly cried out in terror and were suddenly silenced.");
|
||||||
|
ArrayList<Path> pathsToLoad = new ArrayList<>();
|
||||||
|
|
||||||
|
Path terraRoot = Path.of(System.getProperty("user.dir")).getParent().getParent().getParent();
|
||||||
|
Path commonRoot = terraRoot.resolve("common");
|
||||||
|
Path implementationRoot = commonRoot.resolve("implementation");
|
||||||
|
|
||||||
|
pathsToLoad.add(commonRoot.resolve("api"));
|
||||||
|
pathsToLoad.add(implementationRoot.resolve("base"));
|
||||||
|
pathsToLoad.add(implementationRoot.resolve("bootstrap-addon-loader"));
|
||||||
|
for (Path path : pathsToLoad) {
|
||||||
|
try {
|
||||||
|
Path target = path.resolve("build").resolve("classes").resolve("java").resolve("main");
|
||||||
|
|
||||||
|
BootstrapAddonClassLoader cl = new BootstrapAddonClassLoader(new URL[] { path.toUri().toURL()});
|
||||||
|
|
||||||
|
Classes.Loaders omegaCL = Classes.Loaders.create();
|
||||||
|
Files.walk(target, Integer.MAX_VALUE, FileVisitOption.FOLLOW_LINKS)
|
||||||
|
.filter(it -> it.getFileName().toString().endsWith(".class"))
|
||||||
|
.map(Path::toFile)
|
||||||
|
.forEach(it -> {
|
||||||
|
String name = it.getAbsolutePath().replace(target + "/", "").replace('\\', '.').replace('/', '.');
|
||||||
|
name = name.substring(0, name.length() - 6);
|
||||||
|
LOGGER.info("Loading class {}", name);
|
||||||
|
try {
|
||||||
|
Class.forName(name);
|
||||||
|
} catch(ClassNotFoundException e) {
|
||||||
|
try {
|
||||||
|
String pathToJar = cl.loadClass(name).getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
|
||||||
|
|
||||||
|
cl.addURL(new URL("jar:file:" + pathToJar + "!/"));
|
||||||
|
Class newClassLoad = Class.forName(name, true, cl);
|
||||||
|
omegaCL.loadOrDefine(newClassLoad, AbstractPlatform.class.getClassLoader());
|
||||||
|
} catch(ClassNotFoundException | URISyntaxException | IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(IOException e) {
|
||||||
|
throw new IllegalStateException("Could not load all Terra classes", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RegistryStep {
|
public enum RegistryStep {
|
||||||
|
@ -12,6 +12,5 @@
|
|||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
}
|
||||||
"refmap": "terra-forge-refmap.json"
|
|
||||||
}
|
}
|
@ -1,13 +1,15 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architectutyPlugin
|
id("architectury-plugin") version Versions.Mod.architectutyPlugin
|
||||||
|
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
accessWidenerPath.set(file("terra.accesswidener"))
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
defaultRefmapName.set("terra-common-refmap.json")
|
defaultRefmapName.set("terra.common.refmap.json")
|
||||||
}
|
}
|
||||||
accessWidenerPath.set(file("src/main/resources/terra.accesswidener"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -23,3 +25,4 @@ architectury {
|
|||||||
common("fabric", "forge")
|
common("fabric", "forge")
|
||||||
minecraft = Versions.Mod.minecraft
|
minecraft = Versions.Mod.minecraft
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,6 @@ public final class MinecraftAddon implements BaseAddon {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getID() {
|
public String getID() {
|
||||||
return "terra-fabric";
|
return "terra-mod";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"id": "terra-common",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"mixins": [
|
|
||||||
"terra.common.mixins.json"
|
|
||||||
]
|
|
||||||
}
|
|
@ -4,6 +4,7 @@
|
|||||||
"package": "com.dfsek.terra.mod.mixin",
|
"package": "com.dfsek.terra.mod.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"access.BiomeAccessor",
|
||||||
"access.MobSpawnerLogicAccessor",
|
"access.MobSpawnerLogicAccessor",
|
||||||
"access.StateAccessor",
|
"access.StateAccessor",
|
||||||
"access.StructureAccessorAccessor",
|
"access.StructureAccessorAccessor",
|
||||||
@ -42,6 +43,5 @@
|
|||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
}
|
||||||
"refmap": "terra-common-refmap.json"
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user