Use upstream loader during dev
This commit is contained in:
parent
30ebdf1402
commit
69f4d7f02b
18
build.gradle
18
build.gradle
|
@ -1,13 +1,6 @@
|
|||
apply from: "https://jfmods.gitlab.io/scripts/jfmod.gradle"
|
||||
|
||||
allprojects {
|
||||
sourceSets {
|
||||
testmod {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
runs {
|
||||
testmodClient {
|
||||
|
@ -23,18 +16,15 @@ allprojects {
|
|||
source sourceSets.testmod
|
||||
}
|
||||
}
|
||||
|
||||
runConfigs.configureEach {
|
||||
vmArgs "-Dfabric.debug.classPathIsolationBypassClasses=io/gitlab/jfronny/libjf"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation("com.terraformersmc:modmenu:3.1.0")
|
||||
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:$project.fabric_version")
|
||||
modImplementation("io.gitlab.jfronny:commons:$project.commons_version")
|
||||
modImplementation("io.gitlab.jfronny:commons-gson:$project.commons_version")
|
||||
modImplementation("io.gitlab.jfronny:commons-slf4j:$rootProject.commons_version")
|
||||
//TODO update for 1.19
|
||||
implementation("io.gitlab.jfronny:commons:$project.commons_version")
|
||||
implementation("io.gitlab.jfronny:commons-gson:$project.commons_version")
|
||||
implementation("io.gitlab.jfronny:commons-slf4j:$rootProject.commons_version")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# https://fabricmc.net/develop/
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=build.3
|
||||
loader_version=0.14.5+local
|
||||
loader_version=0.14.5
|
||||
fabric_version=0.51.1+1.18.2
|
||||
|
||||
maven_group=io.gitlab.jfronny.libjf
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package io.gitlab.jfronny.libjf.config.impl.entrypoint;
|
||||
|
||||
import io.gitlab.jfronny.libjf.LibJf;
|
||||
import io.gitlab.jfronny.libjf.config.api.ConfigHolder;
|
||||
import io.gitlab.jfronny.libjf.config.api.JfConfig;
|
||||
import io.gitlab.jfronny.libjf.config.impl.ConfigHolderImpl;
|
||||
import io.gitlab.jfronny.libjf.unsafe.SafeLog;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
|
||||
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
|
||||
import net.minecraft.util.Language;
|
||||
import io.gitlab.jfronny.libjf.config.api.*;
|
||||
import io.gitlab.jfronny.libjf.config.impl.*;
|
||||
import io.gitlab.jfronny.libjf.unsafe.*;
|
||||
import net.fabricmc.loader.api.*;
|
||||
import net.fabricmc.loader.api.entrypoint.*;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.*;
|
||||
|
||||
public class JfConfigSafe implements PreLaunchEntrypoint {
|
||||
public static Function<String, String> TRANSLATION_SUPPLIER = s -> null;
|
||||
|
|
|
@ -17,11 +17,12 @@ public class JfLanguageAdapter implements LanguageAdapter {
|
|||
public native <T> T create(net.fabricmc.loader.api.ModContainer mod, String value, Class<T> type);
|
||||
|
||||
static {
|
||||
Logger.registerFactory(FLLogger::new); // Reset in mixin plugin
|
||||
Logger.registerFactory(FLLogger::new); // Reset in SafeLog entrypoint
|
||||
Set<Flags.BooleanFlag> flags = Flags.getBoolFlags("unsafe.unlock");
|
||||
if (flags.stream().map(Flags.BooleanFlag::value).reduce(false, (left, right) -> left || right)) {
|
||||
SafeLog.warn("Unlocking classpath due to: " + flags.stream().map(Flags.BooleanFlag::source).collect(Collectors.joining(", ")));
|
||||
FabricLoaderImpl.INSTANCE.getGameProvider().unlockClassPath(new FabricLauncherClassUnlocker(new KnotClassLoaderInterfaceAccessor(Thread.currentThread().getContextClassLoader())));
|
||||
SafeLog.warn("Completed classpath unlock");
|
||||
}
|
||||
HiddenAnnotationExclusionStrategy.register();
|
||||
GsonHolder.register();
|
||||
|
|
|
@ -1,27 +1,18 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import io.gitlab.jfronny.libjf.unsafe.asm.AsmConfig;
|
||||
import io.gitlab.jfronny.libjf.unsafe.asm.AsmTransformer;
|
||||
import io.gitlab.jfronny.libjf.unsafe.asm.BakedAsmConfig;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.IMixinTransformer;
|
||||
import sun.misc.Unsafe;
|
||||
import io.gitlab.jfronny.libjf.unsafe.asm.*;
|
||||
import org.objectweb.asm.tree.*;
|
||||
import org.spongepowered.asm.mixin.extensibility.*;
|
||||
import org.spongepowered.asm.mixin.transformer.*;
|
||||
import sun.misc.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
public class MixinPlugin implements IMixinConfigPlugin {
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
try {
|
||||
Logger.resetFactory();
|
||||
SafeLog.BACKEND = Logger.forName("libjf");
|
||||
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
Class<?> classLoaderClass = classLoader.getClass();
|
||||
|
||||
|
@ -46,7 +37,7 @@ public class MixinPlugin implements IMixinConfigPlugin {
|
|||
});
|
||||
AsmTransformer.INSTANCE.init();
|
||||
mixinTransformerField.set(delegate, AsmTransformer.INSTANCE);
|
||||
} catch (NoSuchFieldException | IllegalAccessException | InstantiationException e) {
|
||||
} catch (Throwable e) {
|
||||
SafeLog.error("Could not initialize LibJF ASM", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import net.fabricmc.api.*;
|
||||
|
||||
public class SafeLog {
|
||||
public static Logger BACKEND = Logger.forName("LibJF");
|
||||
public class SafeLog implements ModInitializer {
|
||||
private static Logger BACKEND = Logger.forName("LibJF");
|
||||
|
||||
public static void debug(String text) {
|
||||
BACKEND.debug(text);
|
||||
}
|
||||
|
||||
public static void info(String text) {
|
||||
BACKEND.info(text);
|
||||
|
@ -20,4 +25,10 @@ public class SafeLog {
|
|||
public static void error(String text, Throwable e) {
|
||||
BACKEND.error(text, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Logger.resetFactory();
|
||||
BACKEND = Logger.forName("libjf");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe.inject;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.impl.launch.FabricLauncher;
|
||||
import net.fabricmc.loader.impl.launch.MappingConfiguration;
|
||||
import net.fabricmc.loader.impl.util.log.Log;
|
||||
import net.fabricmc.loader.impl.util.log.LogCategory;
|
||||
import io.gitlab.jfronny.libjf.unsafe.*;
|
||||
import net.fabricmc.api.*;
|
||||
import net.fabricmc.loader.impl.launch.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.jar.Manifest;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
|
||||
public record FabricLauncherClassUnlocker(KnotClassLoaderInterfaceAccessor classLoader) implements FabricLauncher {
|
||||
static {
|
||||
System.err.println("[libjf-unsafe-v0] Preparing to unlock classpath via reflection. This might cause issues");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingConfiguration getMappingConfiguration() {
|
||||
return invalidCall();
|
||||
|
@ -25,7 +17,7 @@ public record FabricLauncherClassUnlocker(KnotClassLoaderInterfaceAccessor class
|
|||
|
||||
@Override
|
||||
public void addToClassPath(Path path, String... allowedPrefixes) {
|
||||
Log.debug(LogCategory.KNOT, "Adding " + path + " to classpath.");
|
||||
SafeLog.debug("Adding " + path + " to classpath.");
|
||||
|
||||
classLoader.getDelegate().setAllowedPrefixes(path, allowedPrefixes);
|
||||
classLoader.getDelegate().addCodeSource(path);
|
||||
|
@ -97,6 +89,7 @@ public record FabricLauncherClassUnlocker(KnotClassLoaderInterfaceAccessor class
|
|||
}
|
||||
|
||||
private <T> T invalidCall() {
|
||||
SafeLog.warn("Attempted invalid call in class path unlocker");
|
||||
throw new IllegalStateException("unlockClassPath attempted to call a method not implemented here");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe.inject;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.file.*;
|
||||
|
||||
public record KnotClassDelegateAccessor(Object delegate) {
|
||||
private static final Method addCodeSourceMethod;
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
"minecraft": "*",
|
||||
"libjf-base": ">=${version}"
|
||||
},
|
||||
"entrypoints": {
|
||||
"main": ["io.gitlab.jfronny.libjf.unsafe.SafeLog"]
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"parent": "libjf",
|
||||
|
|
Loading…
Reference in New Issue