use of binnie.core.resource.IBinnieTexture in project Binnie by ForestryMC.
the class StyleSheetParser method parseTextures.
private static Map<String, Texture> parseTextures(JsonObject jsonObject, Map<String, ParsedTextureSheet> textureSheets) {
JsonArray texturesJson = JsonUtils.getJsonArray(jsonObject, TEXTURES_KEY);
if (texturesJson == null) {
return Collections.emptyMap();
}
Map<String, Texture> textures = new HashMap<>();
for (JsonElement element : texturesJson) {
if (!element.isJsonObject()) {
continue;
}
try {
JsonObject sheetJson = element.getAsJsonObject();
String name = JsonUtils.getString(sheetJson, NAME_KEY);
String sheet = JsonUtils.getString(sheetJson, SHEET_KEY);
JsonArray uvArray = JsonUtils.getJsonArray(sheetJson, UV_KEY);
IBinnieTexture textureSheet = textureSheets.get(sheet);
Area uv = parseArea(uvArray);
Border border = Border.ZERO;
Border padding = Border.ZERO;
if (sheetJson.has(BORDER_KEY)) {
JsonArray array = JsonUtils.getJsonArray(sheetJson, BORDER_KEY);
border = parseBorder(array);
}
if (sheetJson.has(PADDING_KEY)) {
JsonArray array = JsonUtils.getJsonArray(sheetJson, PADDING_KEY);
padding = parseBorder(array);
}
Texture texture = new Texture(uv, padding, border, textureSheet);
textures.put(name, texture);
} catch (Exception e) {
Log.warning("Failed to load stylesheet for Binnie's Mods.", e);
}
}
return textures;
}
Aggregations