Tweak AsmTransformer error handling
This commit is contained in:
parent
8847f02e41
commit
968e3e22e2
|
@ -1,9 +1,9 @@
|
|||
org.gradle.jvmargs=-Xmx1G
|
||||
# https://fabricmc.net/versions.html
|
||||
minecraft_version=1.18
|
||||
yarn_mappings=build.1
|
||||
loader_version=0.12.6
|
||||
fabric_version=0.43.1+1.18
|
||||
minecraft_version=1.18.1
|
||||
yarn_mappings=build.12
|
||||
loader_version=0.12.12
|
||||
fabric_version=0.45.0+1.18
|
||||
maven_group=io.gitlab.jfronny.libjf
|
||||
archive_base_name=libjf
|
||||
dev_only_module=libjf-devutil-v0
|
||||
|
|
|
@ -78,8 +78,6 @@ public class EntryInfoWidgetBuilder {
|
|||
|
||||
Number value = 0;
|
||||
boolean inLimits = false;
|
||||
System.out.println(((isNumber ^ s.isEmpty())));
|
||||
System.out.println(!s.equals("-") && !s.equals("."));
|
||||
info.error = null;
|
||||
if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) {
|
||||
value = f.apply(s);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.gitlab.jfronny.libjf.unsafe;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.impl.ModContainerImpl;
|
||||
|
@ -8,6 +7,8 @@ import net.fabricmc.loader.impl.metadata.EntrypointMetadata;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -22,9 +23,7 @@ public class DynamicEntry {
|
|||
*/
|
||||
public static <T> void execute(final String name, final Class<T> entrypointType, final Consumer<ConsumableEntrypoint<T>> onExecute) {
|
||||
final List<ConsumableEntrypoint<T>> targets = new ArrayList<>();
|
||||
final ReferenceArrayList<EntrypointContainer> entrypoints = getEntrypointTargets(name);
|
||||
|
||||
for (final EntrypointContainer entrypoint : entrypoints) {
|
||||
for (final EntrypointContainer entrypoint : getEntrypointTargets(name)) {
|
||||
try {
|
||||
targets.add(new ConsumableEntrypoint<>(
|
||||
entrypointType.cast(Class.forName(entrypoint.entrypoint).getConstructor().newInstance()),
|
||||
|
@ -44,8 +43,8 @@ public class DynamicEntry {
|
|||
}
|
||||
}
|
||||
|
||||
private static ReferenceArrayList<EntrypointContainer> getEntrypointTargets(final String entrypoint) {
|
||||
final ReferenceArrayList<EntrypointContainer> entrypoints = ReferenceArrayList.wrap(new EntrypointContainer[1], 0);
|
||||
private static Collection<EntrypointContainer> getEntrypointTargets(final String entrypoint) {
|
||||
final List<EntrypointContainer> entrypoints = new LinkedList<>();
|
||||
for (final ModContainer mod : FabricLoader.getInstance().getAllMods()) {
|
||||
final List<EntrypointMetadata> modEntrypoints = ((ModContainerImpl)mod).getInfo().getEntrypoints(entrypoint);
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ public class AsmTransformer implements IMixinTransformer {
|
|||
@Override
|
||||
public byte[] transformClassBytes(String name, String transformedName, byte[] classBytes) {
|
||||
classBytes = delegate.transformClassBytes(name, transformedName, classBytes);
|
||||
if (classBytes == null || name == null)
|
||||
return classBytes;
|
||||
if (classBytes == null || name == null) return classBytes;
|
||||
if (isClassUnmoddable(name, null)) {
|
||||
if (debugLogsEnabled()) LibJf.LOGGER.info("Skipping " + name);
|
||||
return classBytes;
|
||||
|
@ -84,19 +83,24 @@ public class AsmTransformer implements IMixinTransformer {
|
|||
|
||||
ClassNode klazz = new ClassNode();
|
||||
ClassReader reader = new ClassReader(classBytes);
|
||||
reader.accept(klazz, ClassReader.EXPAND_FRAMES); //ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG
|
||||
reader.accept(klazz, ClassReader.EXPAND_FRAMES);
|
||||
|
||||
for (AsmConfig config : asmConfigs) {
|
||||
currentConfig = config;
|
||||
if (!isClassUnmoddable(name, config)) {
|
||||
for (Patch patch : config.getPatches()) {
|
||||
patch.apply(klazz);
|
||||
try {
|
||||
patch.apply(klazz);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
LibJf.LOGGER.error("Could not apply patch: " + patch.getClass() + " on " + name, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
currentConfig = null;
|
||||
|
||||
ClassWriter writer = new MixinClassWriter(reader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
ClassWriter writer = new MixinClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
|
||||
try {
|
||||
klazz.accept(writer);
|
||||
}
|
||||
|
@ -110,9 +114,6 @@ public class AsmTransformer implements IMixinTransformer {
|
|||
Path path = FabricLoader.getInstance().getGameDir().resolve("libjf").resolve("asm").resolve(name.replace('.', '/') + ".class");
|
||||
if (!Files.exists(path)) Files.createDirectories(path.getParent());
|
||||
Files.write(path, classBytes);
|
||||
//Path path = Path.of(FabricLoader.getInstance().getGameDir().toString(), ".meteor.asm.out", name.replace('.', '/') + ".class");
|
||||
//new File(path.toUri()).getParentFile().mkdirs();
|
||||
//Files.write(path, classBytes);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -122,25 +123,21 @@ public class AsmTransformer implements IMixinTransformer {
|
|||
|
||||
@Override
|
||||
public byte[] transformClass(MixinEnvironment environment, String name, byte[] classBytes) {
|
||||
LibJf.LOGGER.error("transformClass called");
|
||||
return delegate.transformClass(environment, name, classBytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transformClass(MixinEnvironment environment, String name, ClassNode classNode) {
|
||||
LibJf.LOGGER.error("transformClass called");
|
||||
return delegate.transformClass(environment, name, classNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] generateClass(MixinEnvironment environment, String name) {
|
||||
LibJf.LOGGER.error("generateClass called");
|
||||
return delegate.generateClass(environment, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateClass(MixinEnvironment environment, String name, ClassNode classNode) {
|
||||
LibJf.LOGGER.error("generateClass called");
|
||||
return delegate.generateClass(environment, name, classNode);
|
||||
}
|
||||
|
||||
|
@ -150,7 +147,9 @@ public class AsmTransformer implements IMixinTransformer {
|
|||
}
|
||||
|
||||
public static boolean isClassUnmoddable(String className, AsmConfig config) {
|
||||
if (className.replace('/', '.').startsWith("org.objectweb.asm")
|
||||
className = className.replace('/', '.');
|
||||
if (className.startsWith("org.objectweb.asm")
|
||||
|| className.startsWith("org.spongepowered.asm")
|
||||
//|| className.startsWith("net.fabricmc.loader")
|
||||
//|| className.startsWith("io.gitlab.jfronny.libjf.unsafe.asm")
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue