Add texture-key check. Fixes #53

This commit is contained in:
Blue (Lukas Rieger) 2020-07-02 16:41:19 +02:00
parent ebbdd225cc
commit 0fe7cf94a9
1 changed files with 2 additions and 1 deletions

View File

@ -269,7 +269,6 @@ public class BlockModelResource {
for (Entry<Object, ? extends ConfigurationNode> entry : config.getNode("textures").getChildrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
textures.putIfAbsent(entry.getKey().toString(), entry.getValue().getString(null));
}
@ -426,6 +425,8 @@ public class BlockModelResource {
}
private Texture getTexture(String key) throws NoSuchElementException, FileNotFoundException, IOException {
if (key.isEmpty() || key.equals("#")) throw new NoSuchElementException("Empty texture key or name!");
if (key.charAt(0) == '#') {
String value = textures.get(key.substring(1));
if (value == null) throw new NoSuchElementException("There is no texture defined for the key " + key);