aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java
blob: 10fc99b8dc26475bf97754c6b23b01c55444c0b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package ftbsc.lll.mapper.writer.impl;

import com.google.auto.service.AutoService;
import ftbsc.lll.mapper.utils.Mapper;
import ftbsc.lll.mapper.writer.IWriter;

import java.io.PrintWriter;

/**
 * An {@link IWriter} that writes in the TSRG format,
 * an intermediary format used by Forge.
 */
@AutoService(IWriter.class)
public class TSRGWriter implements IWriter {
   @Override
   public String uniqueId() {
      return "tsrg";
   }

   @Override
   public void write(Mapper mapper, PrintWriter writer, String... args) {
      if(args.length < 2)
         args = new String[] { "left", "right" };
      writer.printf("tsrg2 %s %s\n", args[0], args[1]);
      mapper.getRawMappings().forEach((name, data) -> {
         writer.printf("%s %s\n", 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)));
      });
   }
}