Skip to content

Commit

Permalink
Remapper debug
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyxlandlee committed Aug 7, 2022
1 parent f293d7b commit 7e25caa
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class F2FRemapper extends Remapper {

public F2FRemapper(Mapping mapping) {
this.mapping = mapping;
if ("true".equals(System.getProperty("fa2fomapper.export"))) org.apache.logging.log4j.LogManager.getLogger().warn("[F2F] Using mapping: {}", mapping);
}

@Override
Expand Down
39 changes: 39 additions & 0 deletions src/test/java/xland/mctestmod/fa2fomapper/test/MappingTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package xland.mctestmod.fa2fomapper.test;

import org.junit.jupiter.api.Test;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.commons.ClassRemapper;
import xland.mcmodbridge.fa2fomapper.api.Mapping;
import xland.mcmodbridge.fa2fomapper.api.tiny.TinyUtils;
import xland.mcmodbridge.fa2fomapper.map.F2FClassRemapper;
import xland.mcmodbridge.fa2fomapper.map.F2FRemapper;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class MappingTest {
Mapping mapping = TinyUtils.read(new BufferedReader(new StringReader(TinyMappingTest.MAPPING)),
"base", "forge17");

@Test
public void test() throws IOException {
final Path path = Paths.get(
"/tmp/input-463fc9ae-a779-413c-8f16-a9d5d518a0c2.class");
if (!Files.exists(path)) return;
ClassReader input = new ClassReader(Files.newInputStream(path));
ClassWriter out = new ClassWriter(3);
ClassRemapper remapper = new F2FClassRemapper(out, new F2FRemapper(mapping));
input.accept(remapper, 8);

try (OutputStream os = Files.newOutputStream(Paths.get(
"/tmp/export-463fc9ae-a779-413c-8f16-a9d5d518a0c2.class"))) {
os.write(out.toByteArray());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package xland.mctestmod.fa2fomapper.test;

import org.junit.jupiter.api.Test;
import xland.mcmodbridge.fa2fomapper.api.Mapping;
import xland.mcmodbridge.fa2fomapper.api.tiny.TinyUtils;

import java.io.BufferedReader;
import java.io.StringReader;

public class TinyMappingTest {
@Test
public void test() {
Mapping mapping = TinyUtils.read(new BufferedReader(new StringReader(MAPPING)),
"base", "forge17");
System.out.println(mapping);
}

static final String MAPPING = "v1\tbase\tforge16\tforge17\n" +
"CLASS\tnet/minecraft/class_2960\tnet/minecraft/util/ResourceLocation\tnet/minecraft/resources/ResourceLocation\n" +
"METHOD\tnet/minecraft/class_2960\t()Ljava/lang/String;\tmethod_12836\tfunc_110624_b\tm_135827_\n" +
"METHOD\tnet/minecraft/class_2960\t()Ljava/lang/String;\tmethod_12832\tfunc_110623_a\tm_135815_\n";
}

0 comments on commit 7e25caa

Please sign in to comment.