summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-08-27 02:04:14 +0200
committer zaaarf <zaaarf@proton.me>2023-08-27 02:04:14 +0200
commit1d13d08565f354c479d860244d2ea9e92ae2e9d2 (patch)
tree0208ddf304ecd7016795e6acf398c2626ac6dc47
parent42438928705a97313497b4297f2143b7ff044e78 (diff)
feat: implemented TSRGWriter
-rw-r--r--build.gradle1
-rw-r--r--src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java31
2 files changed, 31 insertions, 1 deletions
diff --git a/build.gradle b/build.gradle
index d50a20f..3745265 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,7 +24,6 @@ dependencies {
implementation 'ftbsc.lll:mapper:0.2.2'
implementation 'com.google.auto.service:auto-service-annotations:1.1.0'
annotationProcessor 'com.google.auto.service:auto-service:1.1.0'
-
}
jar {
diff --git a/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java b/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java
new file mode 100644
index 0000000..2fbb812
--- /dev/null
+++ b/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java
@@ -0,0 +1,31 @@
+package ftbsc.lll.mapper.writer.impl;
+
+import com.google.auto.service.AutoService;
+import ftbsc.lll.mapper.IMapper;
+import ftbsc.lll.mapper.writer.IWriter;
+
+import java.io.PrintWriter;
+
+/**
+ * Writes to TSRG, an intermediary format used by Forge.
+ */
+@AutoService(IWriter.class)
+public class TSRGWriter implements IWriter {
+ @Override
+ public String uniqueId() {
+ return "tsrg";
+ }
+
+ @Override
+ public void write(IMapper mapper, PrintWriter writer) {
+ writer.println("tsrg2 left right");
+ mapper.getRawMappings().forEach((name, data) -> {
+ writer.printf("%s %s\n", data.name, data.nameMapped);
+ data.getFields().forEach((fieldName, fieldData) ->
+ writer.printf("\t%s %s\n", fieldName, fieldData.nameMapped));
+ data.getMethods().forEach(((methodSignature, methodData) ->
+ writer.printf("\t%s %s %s\n", methodSignature.name,
+ methodSignature.descriptor, methodData.nameMapped)));
+ });
+ }
+}