dump resourceVariants from minecraft
This commit is contained in:
parent
3f9c56c226
commit
8ce6571f88
@ -48,8 +48,7 @@ class BlockModels(object):
|
||||
log.warn("Could not get blockstates resource for %s, skipping...", block)
|
||||
continue
|
||||
variants = statesJson['variants']
|
||||
# variants is a dict with each key a blockstate, without the "[]" around them
|
||||
# for blocks without blockstates, the key is "normal"
|
||||
# variants is a dict with each key a resourceVariant value (from the block's ModelResourceLocation)
|
||||
# the value for this key is either a dict describing which model to use
|
||||
# ... or a list of such models to be selected from randomly
|
||||
#
|
||||
@ -58,21 +57,8 @@ class BlockModels(object):
|
||||
# around that axis
|
||||
# another optional key is 'uvlock', which needs investigating
|
||||
|
||||
def matchVariantState(variantState, blockState):
|
||||
# if not all keys in variantState are found in blockState, return false
|
||||
if variantState == "all":
|
||||
return True
|
||||
blockState = blockState[1:-1]
|
||||
vd = [s.split("=") for s in variantState.split(",")]
|
||||
bd = {k: v for (k, v) in (s.split("=") for s in blockState.split(","))}
|
||||
for k, v in vd:
|
||||
if bd.get(k) != v:
|
||||
return False
|
||||
return True
|
||||
variantBlockState = block.resourceVariant
|
||||
|
||||
for variantBlockState in variants:
|
||||
if variantBlockState != "normal" and not matchVariantState(variantBlockState, block.blockState):
|
||||
continue
|
||||
variantDict = variants[variantBlockState]
|
||||
if isinstance(variantDict, list):
|
||||
variantDict = variantDict[0] # do the random pick thing later, if at all
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user