added block rotation mappings for more block types

This commit is contained in:
David Vierra 2010-09-18 01:45:27 -10:00
parent c1a9436aa1
commit 34a08d8550

View File

@ -2,6 +2,8 @@ from materials import alphaMaterials
from numpy import array from numpy import array
def RotateLeft(blocks, data): def RotateLeft(blocks, data):
# Torches
torchRotation = array([0, 4, 3, 1, 2, 5, torchRotation = array([0, 4, 3, 1, 2, 5,
6, 7, 6, 7,
@ -15,6 +17,7 @@ def RotateLeft(blocks, data):
data[torchIndexes] = torchRotation[data[torchIndexes]] data[torchIndexes] = torchRotation[data[torchIndexes]]
# Rails
railRotation = array([1, 0, 4, 5, 3, 2, 9, 6, railRotation = array([1, 0, 4, 5, 3, 2, 9, 6,
7, 8, 7, 8,
@ -23,7 +26,9 @@ def RotateLeft(blocks, data):
railIndexes = (blocks == alphaMaterials.materialNamed("Rail")) railIndexes = (blocks == alphaMaterials.materialNamed("Rail"))
print "Rotating rails: ", len(railIndexes.nonzero()[0]); print "Rotating rails: ", len(railIndexes.nonzero()[0]);
data[railIndexes] = railRotation[data[railIndexes]] data[railIndexes] = railRotation[data[railIndexes]]
# Ladders
ladderRotation = array([0, 1, 4, 5, 3, 2, ladderRotation = array([0, 1, 4, 5, 3, 2,
6, 7, #xxx more ladders 6, 7, #xxx more ladders
@ -33,15 +38,63 @@ def RotateLeft(blocks, data):
print "Rotating ladders: ", len(ladderIndexes.nonzero()[0]); print "Rotating ladders: ", len(ladderIndexes.nonzero()[0]);
data[ladderIndexes] = ladderRotation[data[ladderIndexes]] data[ladderIndexes] = ladderRotation[data[ladderIndexes]]
# Standing signs
signIndexes = (blocks == alphaMaterials.materialNamed("Sign")) signIndexes = (blocks == alphaMaterials.materialNamed("Sign"))
print "Rotating signs: ", len(signIndexes.nonzero()[0]); print "Rotating signs: ", len(signIndexes.nonzero()[0]);
data[signIndexes] -= 4 data[signIndexes] -= 4
data[signIndexes] &= 0xf data[signIndexes] &= 0xf
# Wall signs
wallSignRotation = array([0, 1, 4, 5, 3, 2, 6, 7, wallSignRotation = array([0, 1, 4, 5, 3, 2, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15]); 8, 9, 10, 11, 12, 13, 14, 15]);
wallSignIndexes = (blocks == alphaMaterials.materialNamed("Wall Sign")) wallSignIndexes = (blocks == alphaMaterials.materialNamed("Wall Sign"))
print "Rotating wallsigns: ", len(wallSignIndexes.nonzero()[0]); print "Rotating wallsigns: ", len(wallSignIndexes.nonzero()[0]);
data[wallSignIndexes] = wallSignRotation[data[wallSignIndexes]] data[wallSignIndexes] = wallSignRotation[data[wallSignIndexes]]
# Levers
leverRotation = array([0, 4, 3, 1, 2, 6, 5, 7,
8, 12, 11, 9, 10, 14, 13, 15]) #thrown levers
leverIndexes = (blocks == alphaMaterials.materialNamed("Lever"))
print "Rotating levers: ", len(leverIndexes.nonzero()[0]);
data[leverIndexes] = leverRotation[data[leverIndexes]]
# Doors
doorRotation = array([3, 2, 1, 0,
7, 6, 5, 4, #swung door
11, 10, 9, 8, #top half
15, 14, 13, 12]) #top half swung
doorIndexes = (blocks == alphaMaterials.materialNamed("Iron Door") ) | (blocks == alphaMaterials.materialNamed("Wooden Door"))
print "Rotating doors: ", len(doorIndexes.nonzero()[0]);
data[doorIndexes] = doorRotation[data[doorIndexes]]
# Buttons
buttonRotation = array([0, 4, 3, 1, 2, 5, 6, 7,
8, 12, 11, 9, 10, 13, 14, 15]) #pressed buttons, unusual
buttonIndexes = (blocks == alphaMaterials.materialNamed("Stone Button"))
print "Rotating buttons: ", len(buttonIndexes.nonzero()[0]);
data[buttonIndexes] = buttonRotation[data[buttonIndexes]]
# Stairs
stairRotation = array([3, 2, 0, 1, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15])
stairIndexes = (blocks == alphaMaterials.materialNamed("Wooden Stair")) | (blocks == alphaMaterials.materialNamed("Stone Stair"))
print "Rotating stairs: ", len(stairIndexes.nonzero()[0]);
data[stairIndexes] = stairRotation[data[stairIndexes]]