mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 06:11:24 +00:00
reformat all code
This commit is contained in:
@@ -30,7 +30,7 @@ dependencies {
|
||||
modImplementation("org.quiltmc:quilt-loader:${Versions.Quilt.quiltLoader}")
|
||||
|
||||
modImplementation("org.quiltmc.quilted-fabric-api:quilted-fabric-api:${Versions.Quilt.fabricApi}")
|
||||
|
||||
|
||||
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) {
|
||||
exclude("net.fabricmc")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
|
||||
@@ -4,40 +4,41 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
/**
|
||||
* So you want to Mixin into Authlib/Brigadier/DataFixerUpper, on Fabric you'll need this guy.
|
||||
*
|
||||
* <p>YOU SHOULD ONLY USE THIS CLASS DURING "preLaunch" and ONLY TARGET A CLASS WHICH IS NOT ANY CLASS YOU MIXIN TO.
|
||||
*
|
||||
* <p>
|
||||
* This will likely not work on Gson because FabricLoader has some special logic related to Gson.
|
||||
*/
|
||||
public final class AwfulQuiltHacks {
|
||||
private AwfulQuiltHacks() {}
|
||||
private static final ClassLoader KNOT_CLASSLOADER = Thread.currentThread().getContextClassLoader();
|
||||
private static final Method ADD_URL_METHOD;
|
||||
static {
|
||||
Method tempAddUrlMethod = null;
|
||||
try {
|
||||
tempAddUrlMethod = KNOT_CLASSLOADER.getClass().getMethod("addURL", URL.class);
|
||||
tempAddUrlMethod.setAccessible(true);
|
||||
} catch(ReflectiveOperationException e) {
|
||||
throw new RuntimeException("Failed to load Classloader fields", e);
|
||||
}
|
||||
|
||||
private static final ClassLoader KNOT_CLASSLOADER = Thread.currentThread().getContextClassLoader();
|
||||
private static final Method ADD_URL_METHOD;
|
||||
ADD_URL_METHOD = tempAddUrlMethod;
|
||||
}
|
||||
|
||||
static {
|
||||
Method tempAddUrlMethod = null;
|
||||
try {
|
||||
tempAddUrlMethod = KNOT_CLASSLOADER.getClass().getMethod("addURL", URL.class);
|
||||
tempAddUrlMethod.setAccessible(true);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException("Failed to load Classloader fields", e);
|
||||
}
|
||||
private AwfulQuiltHacks() { }
|
||||
|
||||
ADD_URL_METHOD = tempAddUrlMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hackily load the package which a mixin may exist within.
|
||||
*
|
||||
* YOU SHOULD NOT TARGET A CLASS WHICH YOU MIXIN TO.
|
||||
*
|
||||
* @param pathOfAClass The path of any class within the package.
|
||||
*/
|
||||
public static void hackilyLoadForMixin(String pathOfAClass) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
|
||||
URL url = Class.forName(pathOfAClass).getProtectionDomain().getCodeSource().getLocation();
|
||||
ADD_URL_METHOD.invoke(KNOT_CLASSLOADER, url);
|
||||
}
|
||||
/**
|
||||
* Hackily load the package which a mixin may exist within.
|
||||
* <p>
|
||||
* YOU SHOULD NOT TARGET A CLASS WHICH YOU MIXIN TO.
|
||||
*
|
||||
* @param pathOfAClass The path of any class within the package.
|
||||
*/
|
||||
public static void hackilyLoadForMixin(String pathOfAClass)
|
||||
throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
|
||||
URL url = Class.forName(pathOfAClass).getProtectionDomain().getCodeSource().getLocation();
|
||||
ADD_URL_METHOD.invoke(KNOT_CLASSLOADER, url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.quilt;
|
||||
import com.dfsek.terra.mod.MinecraftAddon;
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
|
||||
public class QuiltAddon extends MinecraftAddon {
|
||||
|
||||
public QuiltAddon(ModPlatform modPlatform) {
|
||||
|
||||
@@ -33,6 +33,7 @@ public class QuiltEntryPoint implements ModInitializer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(QuiltEntryPoint.class);
|
||||
|
||||
private static final QuiltPlatform TERRA_PLUGIN = new QuiltPlatform();
|
||||
|
||||
@Override
|
||||
public void onInitialize(ModContainer container) {
|
||||
logger.info("Initializing Terra Quilt mod...");
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.stream.Stream;
|
||||
|
||||
import com.dfsek.terra.addon.EphemeralAddon;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
||||
|
||||
|
||||
@@ -41,7 +40,7 @@ public class QuiltPlatform extends LifecyclePlatform {
|
||||
|
||||
@Override
|
||||
protected Collection<BaseAddon> getPlatformMods() {
|
||||
return QuiltLoader.getAllMods().stream().flatMap(mod -> {
|
||||
return QuiltLoader.getAllMods().stream().flatMap(mod -> {
|
||||
String id = mod.metadata().id();
|
||||
if(id.equals("terra") || id.equals("minecraft") || id.equals("java")) return Stream.empty();
|
||||
try {
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public class QuiltPreLaunchEntryPoint implements PreLaunchEntrypoint {
|
||||
@Override
|
||||
public void onPreLaunch(ModContainer mod) {
|
||||
if (QuiltLoader.isDevelopmentEnvironment()) {
|
||||
if(QuiltLoader.isDevelopmentEnvironment()) {
|
||||
try {
|
||||
AwfulQuiltHacks.hackilyLoadForMixin(BrigadierMappingBuilder.class.getName());
|
||||
} catch(ClassNotFoundException | InvocationTargetException | IllegalAccessException e) {
|
||||
|
||||
Reference in New Issue
Block a user