[unsafe] Update for fabric loader 0.14
This commit is contained in:
parent
a4aac90aed
commit
d14d063eef
|
@ -25,11 +25,15 @@ allprojects {
|
|||
}
|
||||
}
|
||||
|
||||
// If dev startup fails, add:
|
||||
// -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# https://fabricmc.net/develop/
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=build.2
|
||||
loader_version=0.13.3
|
||||
fabric_version=0.48.0+1.18.2
|
||||
yarn_mappings=build.3
|
||||
loader_version=0.14.5+local
|
||||
fabric_version=0.51.1+1.18.2
|
||||
|
||||
maven_group=io.gitlab.jfronny.libjf
|
||||
archive_base_name=libjf
|
||||
|
@ -13,4 +13,4 @@ modrinth_optional_dependencies=P7dR8mSH
|
|||
curseforge_id=482600
|
||||
curseforge_optional_dependencies=fabric-api
|
||||
|
||||
commons_version=0.1.0.2022.4.29.11.8.31
|
||||
commons_version=2022.5.9+20-3-39
|
|
@ -4,4 +4,5 @@ dependencies {
|
|||
include modImplementation(fabricApi.module("fabric-lifecycle-events-v1", "$rootProject.fabric_version"))
|
||||
shadow "io.gitlab.jfronny:commons:$rootProject.commons_version"
|
||||
shadow "io.gitlab.jfronny:commons-gson:$rootProject.commons_version"
|
||||
shadow "io.gitlab.jfronny:commons-slf4j:$rootProject.commons_version"
|
||||
}
|
|
@ -3,18 +3,17 @@ package io.gitlab.jfronny.libjf;
|
|||
import io.gitlab.jfronny.commons.serialize.gson.GsonHolder;
|
||||
import io.gitlab.jfronny.gson.Gson;
|
||||
import io.gitlab.jfronny.gson.GsonBuilder;
|
||||
import io.gitlab.jfronny.libjf.gson.HiddenAnnotationExclusionStrategy;
|
||||
import io.gitlab.jfronny.libjf.gson.GsonAdapter;
|
||||
import io.gitlab.jfronny.libjf.gson.HiddenAnnotationExclusionStrategy;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class LibJf {
|
||||
private LibJf() {
|
||||
}
|
||||
public static final String MOD_ID = "libjf";
|
||||
@Deprecated(forRemoval = true) // This should be a jf java-commons logger
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
@Deprecated(forRemoval = true)
|
||||
public static final Gson GSON;
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import net.fabricmc.loader.impl.util.log.Log;
|
||||
import net.fabricmc.loader.impl.util.log.LogCategory;
|
||||
|
||||
public class FLLogger implements Logger {
|
||||
private final LogCategory category;
|
||||
|
||||
public FLLogger(String context, String... names) {
|
||||
this.category = LogCategory.createCustom(context, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return category.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String msg) {
|
||||
Log.trace(category, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object arg) {
|
||||
Log.trace(category, format, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object... args) {
|
||||
Log.trace(category, format, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String msg, Throwable t) {
|
||||
Log.trace(category, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg) {
|
||||
Log.debug(category, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object arg) {
|
||||
Log.debug(category, format, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object... args) {
|
||||
Log.debug(category, format, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg, Throwable t) {
|
||||
Log.debug(category, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String msg) {
|
||||
Log.info(category, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object arg) {
|
||||
Log.info(category, format, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object... args) {
|
||||
Log.info(category, format, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String msg, Throwable t) {
|
||||
Log.info(category, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String msg) {
|
||||
Log.warn(category, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object arg) {
|
||||
Log.warn(category, format, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object... args) {
|
||||
Log.warn(category, format, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String msg, Throwable t) {
|
||||
Log.warn(category, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {
|
||||
Log.error(category, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object arg) {
|
||||
Log.error(category, format, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object... args) {
|
||||
Log.error(category, format, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg, Throwable t) {
|
||||
Log.error(category, msg, t);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
import io.gitlab.jfronny.commons.serialize.gson.GsonHolder;
|
||||
import io.gitlab.jfronny.libjf.Flags;
|
||||
import io.gitlab.jfronny.libjf.gson.HiddenAnnotationExclusionStrategy;
|
||||
|
@ -23,6 +24,7 @@ public class JfLanguageAdapter implements LanguageAdapter {
|
|||
}
|
||||
HiddenAnnotationExclusionStrategy.register();
|
||||
GsonHolder.register();
|
||||
Logger.registerFactory(FLLogger::new); // Reset in mixin plugin
|
||||
DynamicEntry.execute("libjf:preEarly", UltraEarlyInit.class, s -> s.instance().init());
|
||||
DynamicEntry.execute("libjf:early", UltraEarlyInit.class, s -> s.instance().init());
|
||||
SafeLog.info("LibJF unsafe init completed");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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;
|
||||
|
@ -18,6 +19,9 @@ 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();
|
||||
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import net.fabricmc.loader.impl.util.log.Log;
|
||||
import net.fabricmc.loader.impl.util.log.LogCategory;
|
||||
import io.gitlab.jfronny.commons.log.Logger;
|
||||
|
||||
public class SafeLog {
|
||||
private static final LogCategory LOG_CATEGORY = new LogCategory("libjf");
|
||||
public static Logger BACKEND = Logger.forName("LibJF");
|
||||
|
||||
public static void info(String text) {
|
||||
Log.info(LOG_CATEGORY, text);
|
||||
BACKEND.info(text);
|
||||
}
|
||||
|
||||
public static void warn(String text) {
|
||||
Log.warn(LOG_CATEGORY, text);
|
||||
BACKEND.warn(text);
|
||||
}
|
||||
|
||||
public static void error(String text) {
|
||||
Log.error(LOG_CATEGORY, text);
|
||||
BACKEND.error(text);
|
||||
}
|
||||
|
||||
public static void error(String text, Throwable e) {
|
||||
Log.error(LOG_CATEGORY, text, e);
|
||||
BACKEND.error(text, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class InterfaceImplTargetPatch implements Patch {
|
|||
&& !className.startsWith("net/minecraft/")
|
||||
&& !className.startsWith("jdk/")
|
||||
&& !className.startsWith("it/unimi/dsi/fastutil/")
|
||||
&& !className.startsWith("com/google/")
|
||||
//&& !className.startsWith("com/google/")
|
||||
) {
|
||||
if (AsmTransformer.INSTANCE.debugLogsEnabled()) SafeLog.info("Non-default class not considered for interface scanning: " + className);
|
||||
INTERFACES.put(className, Set.of());
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.io.InputStream;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
|
@ -47,6 +48,11 @@ public record FabricLauncherClassUnlocker(KnotClassLoaderInterfaceAccessor class
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidParentClassPath(Collection<Path> paths) {
|
||||
invalidCall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnvType getEnvironmentType() {
|
||||
return invalidCall();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
},
|
||||
"mixins": ["libjf-unsafe-v0.mixins.json"],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.12",
|
||||
"fabricloader": ">=0.14.5",
|
||||
"minecraft": "*",
|
||||
"libjf-base": ">=${version}"
|
||||
},
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe.test;
|
||||
|
||||
import io.gitlab.jfronny.libjf.LibJf;
|
||||
import io.gitlab.jfronny.libjf.unsafe.SafeLog;
|
||||
import io.gitlab.jfronny.libjf.unsafe.UltraEarlyInit;
|
||||
|
||||
public class UnsafeEntryTest implements UltraEarlyInit {
|
||||
@Override
|
||||
public void init() {
|
||||
LibJf.LOGGER.info("Successfully executed code before that should be possible\n" +
|
||||
SafeLog.info("Successfully executed code before that should be possible\n" +
|
||||
"'||' '|' '|| . '||''''| '|| \n" +
|
||||
" || | || .||. ... .. .... || . .... ... .. || .... ... \n" +
|
||||
" || | || || ||' '' '' .|| ||''| '' .|| ||' '' || '|. | \n" +
|
||||
|
|
Loading…
Reference in New Issue