-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f293d7b
commit 7e25caa
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/xland/mctestmod/fa2fomapper/test/MappingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/xland/mctestmod/fa2fomapper/test/TinyMappingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |