mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Add back support for architectury.common.json and quilt in AW remapping
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -28,6 +28,7 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
|
||||
@@ -58,14 +59,41 @@ public class AccessWidenerUtils {
|
||||
}
|
||||
|
||||
public static AccessWidenerData readAccessWidenerData(Path inputJar) throws IOException {
|
||||
byte[] modJsonBytes = ZipUtils.unpack(inputJar, "fabric.mod.json");
|
||||
JsonObject jsonObject = LoomGradlePlugin.GSON.fromJson(new String(modJsonBytes, StandardCharsets.UTF_8), JsonObject.class);
|
||||
String fieldName = "accessWidener";
|
||||
byte[] modJsonBytes = ZipUtils.unpackNullable(inputJar, "fabric.mod.json");
|
||||
|
||||
if (!jsonObject.has("accessWidener")) {
|
||||
return null;
|
||||
if (modJsonBytes == null) {
|
||||
modJsonBytes = ZipUtils.unpackNullable(inputJar, "architectury.common.json");
|
||||
|
||||
if (modJsonBytes == null) {
|
||||
modJsonBytes = ZipUtils.unpackNullable(inputJar, "quilt.mod.json");
|
||||
|
||||
if (modJsonBytes != null) {
|
||||
fieldName = "access_widener";
|
||||
} else {
|
||||
// No access widener data
|
||||
// We can just ignore in architectury
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JsonObject jsonObject = LoomGradlePlugin.GSON.fromJson(new String(modJsonBytes, StandardCharsets.UTF_8), JsonObject.class);
|
||||
|
||||
String accessWidenerPath;
|
||||
|
||||
if (fieldName.equals("access_widener") && jsonObject.get(fieldName).isJsonArray()) {
|
||||
JsonArray array = jsonObject.get(fieldName).getAsJsonArray();
|
||||
|
||||
if (array.size() != 1) {
|
||||
throw new UnsupportedOperationException("Loom does not support multiple access wideners in one mod!");
|
||||
}
|
||||
|
||||
accessWidenerPath = array.get(0).getAsString();
|
||||
} else {
|
||||
accessWidenerPath = jsonObject.get(fieldName).getAsString();
|
||||
}
|
||||
|
||||
String accessWidenerPath = jsonObject.get("accessWidener").getAsString();
|
||||
byte[] accessWidener = ZipUtils.unpack(inputJar, accessWidenerPath);
|
||||
AccessWidenerReader.Header header = AccessWidenerReader.readHeader(accessWidener);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user