Fix #309 - Unbounded texture variable lookup
This commit is contained in:
parent
f85b441041
commit
354888c099
@ -309,16 +309,25 @@ cdef class BlockModels(object):
|
|||||||
|
|
||||||
# grab textures and elements from this model, then get parent and merge its textures and elements
|
# grab textures and elements from this model, then get parent and merge its textures and elements
|
||||||
# continue until no parent is found
|
# continue until no parent is found
|
||||||
rawTextureVars = {}
|
textureVars = {}
|
||||||
allElements = []
|
allElements = []
|
||||||
|
|
||||||
for i in range(MAX_TEXTURE_RECURSIONS):
|
for i in range(MAX_TEXTURE_RECURSIONS):
|
||||||
textures = modelDict.get("textures")
|
textures = modelDict.get("textures")
|
||||||
if textures is not None:
|
if textures is not None:
|
||||||
rawTextureVars.update(textures)
|
# Resolve texture variables in parent to values in child
|
||||||
|
for k, v in textures.iteritems():
|
||||||
|
if k in textureVars:
|
||||||
|
# Child always overrides parent
|
||||||
|
continue
|
||||||
|
if v.startswith("#"):
|
||||||
|
v = textureVars.get(v[1:], v)
|
||||||
|
textureVars[k] = v
|
||||||
|
|
||||||
elements = modelDict.get("elements")
|
elements = modelDict.get("elements")
|
||||||
if elements is not None:
|
if elements is not None:
|
||||||
allElements.extend(elements)
|
allElements.extend(elements)
|
||||||
|
|
||||||
parentName = modelDict.get("parent")
|
parentName = modelDict.get("parent")
|
||||||
if parentName is None:
|
if parentName is None:
|
||||||
break
|
break
|
||||||
@ -333,17 +342,7 @@ cdef class BlockModels(object):
|
|||||||
|
|
||||||
if block.forcedModelTextures: # user-configured model textures
|
if block.forcedModelTextures: # user-configured model textures
|
||||||
for var, tex in block.forcedModelTextures.iteritems():
|
for var, tex in block.forcedModelTextures.iteritems():
|
||||||
rawTextureVars[var[1:]] = tex
|
textureVars[var[1:]] = tex
|
||||||
|
|
||||||
# pre-resolve texture vars
|
|
||||||
|
|
||||||
textureVars = {}
|
|
||||||
for k, v in rawTextureVars.iteritems():
|
|
||||||
while v is not None and v.startswith("#"):
|
|
||||||
v = rawTextureVars.get(v[1:])
|
|
||||||
if v:
|
|
||||||
textureVars[k] = v
|
|
||||||
|
|
||||||
|
|
||||||
if block.biomeTintType == "grass":
|
if block.biomeTintType == "grass":
|
||||||
biomeTintType = BIOME_GRASS
|
biomeTintType = BIOME_GRASS
|
||||||
@ -382,8 +381,8 @@ cdef class BlockModels(object):
|
|||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("Failed to parse variant of block %s\nelements:\n%s\ntextures:\n%s",
|
log.exception("Failed to parse variant of block %s\nelements:\n%s\ntextures:\n%s",
|
||||||
block.nameAndState, allElements, rawTextureVars)
|
block.nameAndState, allElements, textureVars)
|
||||||
|
|
||||||
return allQuads
|
return allQuads
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user