Fix access widener remapping
parent
58fe59491a
commit
7a56779368
|
@ -36,7 +36,6 @@ import java.nio.file.Path;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ public class ModProcessor {
|
||||||
}))});
|
}))});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] remapaccessWidener(byte[] input, Remapper remapper) {
|
private static byte[] remapAccessWidener(byte[] input, Remapper remapper) {
|
||||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(input), StandardCharsets.UTF_8))) {
|
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(input), StandardCharsets.UTF_8))) {
|
||||||
AccessWidener accessWidener = new AccessWidener();
|
AccessWidener accessWidener = new AccessWidener();
|
||||||
accessWidener.read(bufferedReader);
|
accessWidener.read(bufferedReader);
|
||||||
|
@ -137,6 +136,7 @@ public class ModProcessor {
|
||||||
|
|
||||||
final Map<ModDependencyInfo, InputTag> tagMap = new HashMap<>();
|
final Map<ModDependencyInfo, InputTag> tagMap = new HashMap<>();
|
||||||
final Map<ModDependencyInfo, OutputConsumerPath> outputConsumerMap = new HashMap<>();
|
final Map<ModDependencyInfo, OutputConsumerPath> outputConsumerMap = new HashMap<>();
|
||||||
|
final Map<ModDependencyInfo, byte[]> accessWidenerMap = new HashMap<>();
|
||||||
|
|
||||||
for (ModDependencyInfo info : processList) {
|
for (ModDependencyInfo info : processList) {
|
||||||
InputTag tag = remapper.createInputTag();
|
InputTag tag = remapper.createInputTag();
|
||||||
|
@ -151,28 +151,23 @@ public class ModProcessor {
|
||||||
outputConsumerMap.put(info, outputConsumer);
|
outputConsumerMap.put(info, outputConsumer);
|
||||||
String accessWidener = info.getAccessWidener();
|
String accessWidener = info.getAccessWidener();
|
||||||
|
|
||||||
if (accessWidener == null) {
|
if (accessWidener != null) {
|
||||||
remapper.apply(outputConsumer, tagMap.get(info));
|
accessWidenerMap.put(info, remapAccessWidener(ZipUtil.unpackEntry(info.inputFile, accessWidener), remapper.getRemapper()));
|
||||||
} else {
|
|
||||||
remapper.apply(remapAccessWidener(remapper.getRemapper(), accessWidener, outputConsumer), tagMap.get(info));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remapper.apply(outputConsumer, tagMap.get(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
remapper.finish();
|
remapper.finish();
|
||||||
|
|
||||||
for (ModDependencyInfo info : processList) {
|
for (ModDependencyInfo info : processList) {
|
||||||
outputConsumerMap.get(info).close();
|
outputConsumerMap.get(info).close();
|
||||||
}
|
byte[] accessWidener = accessWidenerMap.get(info);
|
||||||
}
|
|
||||||
|
|
||||||
static BiConsumer<String, byte[]> remapAccessWidener(Remapper remapper, String accessWidener, BiConsumer<String, byte[]> output) {
|
if (accessWidener != null) {
|
||||||
return (s, bytes) -> {
|
ZipUtil.replaceEntry(info.getRemappedOutput(), info.getAccessWidener(), accessWidener);
|
||||||
if (s.equals(accessWidener)) {
|
}
|
||||||
output.accept(s, remapaccessWidener(bytes, remapper));
|
|
||||||
} else {
|
|
||||||
output.accept(s, bytes);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static JsonObject readInstallerJson(File file, Project project) {
|
static JsonObject readInstallerJson(File file, Project project) {
|
||||||
|
|
Loading…
Reference in New Issue