Begin implementing 180 degree rotations
This commit is contained in:
parent
bee69153b8
commit
d77c9c9d61
@ -87,13 +87,21 @@ class BlockRotations(object):
|
|||||||
self.rotateY90 = self.buildTable(axis='y')
|
self.rotateY90 = self.buildTable(axis='y')
|
||||||
self.rotateX90 = self.buildTable(axis='x')
|
self.rotateX90 = self.buildTable(axis='x')
|
||||||
self.rotateZ90 = self.buildTable(axis='z')
|
self.rotateZ90 = self.buildTable(axis='z')
|
||||||
|
self.rotateX180 = self.buildTable(axis='x', aboutFace=True)
|
||||||
|
self.rotateZ180 = self.buildTable(axis='z', aboutFace=True)
|
||||||
|
|
||||||
def buildTable(self, axis):
|
def buildTable(self, axis, aboutFace=False):
|
||||||
mapping = self.mappings[axis]
|
mapping = self.mappings[axis]
|
||||||
axisMapping = self.axisMappings[axis]
|
axisMapping = self.axisMappings[axis]
|
||||||
|
|
||||||
|
if aboutFace:
|
||||||
|
mapping90 = mapping
|
||||||
|
mapping = {k: mapping90[v] for k, v in mapping90.iteritems()}
|
||||||
|
|
||||||
table = blankRotationTable()
|
table = blankRotationTable()
|
||||||
|
|
||||||
|
rotIncrement = 8 if aboutFace else 4
|
||||||
|
|
||||||
for block in self.blocktypes:
|
for block in self.blocktypes:
|
||||||
state = block.stateDict
|
state = block.stateDict
|
||||||
if not len(state):
|
if not len(state):
|
||||||
@ -124,7 +132,7 @@ class BlockRotations(object):
|
|||||||
# For signs and banners: rotation=10 and similar
|
# For signs and banners: rotation=10 and similar
|
||||||
|
|
||||||
if 'rotation' in state:
|
if 'rotation' in state:
|
||||||
rotation = (int(state['rotation']) + 4) % 16
|
rotation = (int(state['rotation']) + rotIncrement) % 16
|
||||||
state['rotation'] = unicode(rotation)
|
state['rotation'] = unicode(rotation)
|
||||||
|
|
||||||
# For rails, powered rails, etc: shape=north_east
|
# For rails, powered rails, etc: shape=north_east
|
||||||
@ -138,11 +146,20 @@ class BlockRotations(object):
|
|||||||
|
|
||||||
# For logs and such: axis=x and similar
|
# For logs and such: axis=x and similar
|
||||||
|
|
||||||
if 'axis' in state:
|
if not aboutFace and 'axis' in state:
|
||||||
axis = state['axis']
|
axis = state['axis']
|
||||||
axis = axisMapping.get(axis, axis)
|
axis = axisMapping.get(axis, axis)
|
||||||
state['axis'] = axis
|
state['axis'] = axis
|
||||||
|
|
||||||
|
# For stairs/slabs: if x or z axis and 180-degree rotation, flip "half"
|
||||||
|
|
||||||
|
if axis in 'xz' and aboutFace:
|
||||||
|
if 'half' in state:
|
||||||
|
if state['half'] == 'bottom':
|
||||||
|
state['half'] = 'top'
|
||||||
|
elif state['half'] == 'top':
|
||||||
|
state['half'] = 'bottom'
|
||||||
|
|
||||||
#print("Changed %s \nto %s" % (stateString, newStateString))
|
#print("Changed %s \nto %s" % (stateString, newStateString))
|
||||||
|
|
||||||
newBlock = self.matchingState(block.internalName, state)
|
newBlock = self.matchingState(block.internalName, state)
|
||||||
|
Reference in New Issue
Block a user