From d8a1fcb9d479d90a28b3a1ece1301ee8c5e10bd3 Mon Sep 17 00:00:00 2001 From: wdog5 Date: Thu, 17 Oct 2024 18:10:03 +0800 Subject: [PATCH] Fix remap --- .../bukkit/remapping/RemapSourceHandler.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/banner-api/src/main/java/com/mohistmc/banner/bukkit/remapping/RemapSourceHandler.java b/banner-api/src/main/java/com/mohistmc/banner/bukkit/remapping/RemapSourceHandler.java index 31db2e8e3..c1c3b43b5 100644 --- a/banner-api/src/main/java/com/mohistmc/banner/bukkit/remapping/RemapSourceHandler.java +++ b/banner-api/src/main/java/com/mohistmc/banner/bukkit/remapping/RemapSourceHandler.java @@ -4,6 +4,8 @@ import net.fabricmc.api.EnvType; import net.fabricmc.loader.impl.transformer.FabricTransformer; import org.objectweb.asm.ClassReader; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.asm.mixin.transformer.IMixinTransformer; import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; @@ -43,16 +45,18 @@ public void connect() throws IOException { byte[] bytes = ByteStreams.toByteArray(url.openStream()); String className = new ClassReader(bytes).getClassName(); if (className.startsWith("net/minecraft/") || className.equals("com/mojang/brigadier/tree/CommandNode")) { - String handledName = className.replace('/', '.'); - try { - bytes = FabricTransformer.transform(false, EnvType.SERVER, handledName, bytes); - } catch (Throwable e) { - throw new IOException(e); - } + bytes = fabricRemapClass(bytes); } this.array = Remapper.getResourceMapper().remapClassFile(bytes, GlobalClassRepo.INSTANCE); } + public byte[] fabricRemapClass(byte[] cl) { + var name = new ClassReader(cl).getClassName(); + var bytes = FabricTransformer.transform(false, EnvType.SERVER, name.replace('/', '.'), cl); + bytes = ((IMixinTransformer) MixinEnvironment.getCurrentEnvironment().getActiveTransformer()).transformClassBytes(name, name, bytes); + return bytes; + } + @Override public InputStream getInputStream() throws IOException { connect();