Skip to content

Commit

Permalink
Load the blockstate as a json file
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrybig committed Feb 6, 2019
1 parent 9ee07d9 commit d3d7544
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -7,10 +7,14 @@
package me.ferrybig.java.minecraft.overview.mapper.textures;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
Expand Down Expand Up @@ -63,10 +67,19 @@ public void readAll(List<File> files) throws IOException {
}
}
// Discovery done, its now time to resolve all files
JsonParser parser = new JsonParser();
Map<String, Model> modelCache = new HashMap<>();
for(String material : materials) {
try(InputStream materialInputStream = readFromZipList(zipFiles, BLOCKSTATES_PREFIX + material + BLOCKSTATES_SUFFIX)) {

try {
JsonObject mainMaterial;
try(Reader materialInputStream = new InputStreamReader(
readFromZipList(zipFiles, BLOCKSTATES_PREFIX + material + BLOCKSTATES_SUFFIX),
StandardCharsets.UTF_8
)) {
mainMaterial = parser.parse(materialInputStream).getAsJsonObject();
}
} catch(IOException e) {
throw new IOException("Unable to parse material " + material, e);
}
}
} finally {
Expand Down

0 comments on commit d3d7544

Please sign in to comment.