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

View File

@ -269,7 +269,6 @@ private BlockModelResource buildNoReset(String modelPath, boolean renderElements
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 @@ private Vector4f readVector4f(ConfigurationNode node) throws ParseResourceExcept
}
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);