<s> from materials import alphaMaterials <EOL> from numpy import arange , zeros <EOL> def genericVerticalFlip ( cls ) : <EOL> rotation = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> if hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) : <EOL> rotation [ cls . Up ] = cls . Down <EOL> rotation [ cls . Down ] = cls . Up <EOL> if hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) : <EOL> rotation [ cls . North ] = cls . TopNorth <EOL> rotation [ cls . West ] = cls . TopWest <EOL> rotation [ cls . South ] = cls . TopSouth <EOL> rotation [ cls . East ] = cls . TopEast <EOL> rotation [ cls . TopNorth ] = cls . North <EOL> rotation [ cls . TopWest ] = cls . West <EOL> rotation [ cls . TopSouth ] = cls . South <EOL> rotation [ cls . TopEast ] = cls . East <EOL> return rotation <EOL> def genericRotation ( cls ) : <EOL> rotation = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> rotation [ cls . North ] = cls . West <EOL> rotation [ cls . West ] = cls . South <EOL> rotation [ cls . South ] = cls . East <EOL> rotation [ cls . East ] = cls . North <EOL> if hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) : <EOL> rotation [ cls . TopNorth ] = cls . TopWest <EOL> rotation [ cls . TopWest ] = cls . TopSouth <EOL> rotation [ cls . TopSouth ] = cls . TopEast <EOL> rotation [ cls . TopEast ] = cls . TopNorth <EOL> return rotation <EOL> def genericEastWestFlip ( cls ) : <EOL> rotation = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> rotation [ cls . West ] = cls . East <EOL> rotation [ cls . East ] = cls . West <EOL> if hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) : <EOL> rotation [ cls . TopWest ] = cls . TopEast <EOL> rotation [ cls . TopEast ] = cls . TopWest <EOL> return rotation <EOL> def genericNorthSouthFlip ( cls ) : <EOL> rotation = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> rotation [ cls . South ] = cls . North <EOL> rotation [ cls . North ] = cls . South <EOL> if hasattr ( cls , "<STR_LIT>" ) and hasattr ( cls , "<STR_LIT>" ) : <EOL> rotation [ cls . TopSouth ] = cls . TopNorth <EOL> rotation [ cls . TopNorth ] = cls . TopSouth <EOL> return rotation <EOL> rotationClasses = [ ] <EOL> def genericFlipRotation ( cls ) : <EOL> cls . rotateLeft = genericRotation ( cls ) <EOL> cls . flipVertical = genericVerticalFlip ( cls ) <EOL> cls . flipEastWest = genericEastWestFlip ( cls ) <EOL> cls . flipNorthSouth = genericNorthSouthFlip ( cls ) <EOL> rotationClasses . append ( cls ) <EOL> class Torch : <EOL> blocktypes = [ <EOL> alphaMaterials . Torch . ID , <EOL> alphaMaterials . RedstoneTorchOn . ID , <EOL> alphaMaterials . RedstoneTorchOff . ID , <EOL> ] <EOL> South = <NUM_LIT:1> <EOL> North = <NUM_LIT:2> <EOL> West = <NUM_LIT:3> <EOL> East = <NUM_LIT:4> <EOL> genericFlipRotation ( Torch ) <EOL> class Ladder : <EOL> blocktypes = [ alphaMaterials . Ladder . ID ] <EOL> East = <NUM_LIT:2> <EOL> West = <NUM_LIT:3> <EOL> North = <NUM_LIT:4> <EOL> South = <NUM_LIT:5> <EOL> genericFlipRotation ( Ladder ) <EOL> class Stair : <EOL> blocktypes = [ b . ID for b in alphaMaterials . AllStairs ] <EOL> South = <NUM_LIT:0> <EOL> North = <NUM_LIT:1> <EOL> West = <NUM_LIT:2> <EOL> East = <NUM_LIT:3> <EOL> TopSouth = <NUM_LIT:4> <EOL> TopNorth = <NUM_LIT:5> <EOL> TopWest = <NUM_LIT:6> <EOL> TopEast = <NUM_LIT:7> <EOL> genericFlipRotation ( Stair ) <EOL> class HalfSlab : <EOL> blocktypes = [ alphaMaterials . StoneSlab . ID ] <EOL> StoneSlab = <NUM_LIT:0> <EOL> SandstoneSlab = <NUM_LIT:1> <EOL> WoodenSlab = <NUM_LIT:2> <EOL> CobblestoneSlab = <NUM_LIT:3> <EOL> BrickSlab = <NUM_LIT:4> <EOL> StoneBrickSlab = <NUM_LIT:5> <EOL> TopStoneSlab = <NUM_LIT:8> <EOL> TopSandstoneSlab = <NUM_LIT:9> <EOL> TopWoodenSlab = <NUM_LIT:10> <EOL> TopCobblestoneSlab = <NUM_LIT:11> <EOL> TopBrickSlab = <NUM_LIT:12> <EOL> TopStoneBrickSlab = <NUM_LIT> <EOL> HalfSlab . flipVertical = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> HalfSlab . flipVertical [ HalfSlab . StoneSlab ] = HalfSlab . TopStoneSlab <EOL> HalfSlab . flipVertical [ HalfSlab . SandstoneSlab ] = HalfSlab . TopSandstoneSlab <EOL> HalfSlab . flipVertical [ HalfSlab . WoodenSlab ] = HalfSlab . TopWoodenSlab <EOL> HalfSlab . flipVertical [ HalfSlab . CobblestoneSlab ] = HalfSlab . TopCobblestoneSlab <EOL> HalfSlab . flipVertical [ HalfSlab . BrickSlab ] = HalfSlab . TopBrickSlab <EOL> HalfSlab . flipVertical [ HalfSlab . StoneBrickSlab ] = HalfSlab . TopStoneBrickSlab <EOL> HalfSlab . flipVertical [ HalfSlab . TopStoneSlab ] = HalfSlab . StoneSlab <EOL> HalfSlab . flipVertical [ HalfSlab . TopSandstoneSlab ] = HalfSlab . SandstoneSlab <EOL> HalfSlab . flipVertical [ HalfSlab . TopWoodenSlab ] = HalfSlab . WoodenSlab <EOL> HalfSlab . flipVertical [ HalfSlab . TopCobblestoneSlab ] = HalfSlab . CobblestoneSlab <EOL> HalfSlab . flipVertical [ HalfSlab . TopBrickSlab ] = HalfSlab . BrickSlab <EOL> HalfSlab . flipVertical [ HalfSlab . TopStoneBrickSlab ] = HalfSlab . StoneBrickSlab <EOL> rotationClasses . append ( HalfSlab ) <EOL> class WallSign : <EOL> blocktypes = [ alphaMaterials . WallSign . ID ] <EOL> East = <NUM_LIT:2> <EOL> West = <NUM_LIT:3> <EOL> North = <NUM_LIT:4> <EOL> South = <NUM_LIT:5> <EOL> genericFlipRotation ( WallSign ) <EOL> class FurnaceDispenserChest : <EOL> blocktypes = [ <EOL> alphaMaterials . Furnace . ID , <EOL> alphaMaterials . LitFurnace . ID , <EOL> alphaMaterials . Dispenser . ID , <EOL> alphaMaterials . Chest . ID , <EOL> ] <EOL> East = <NUM_LIT:2> <EOL> West = <NUM_LIT:3> <EOL> North = <NUM_LIT:4> <EOL> South = <NUM_LIT:5> <EOL> genericFlipRotation ( FurnaceDispenserChest ) <EOL> class Pumpkin : <EOL> blocktypes = [ <EOL> alphaMaterials . Pumpkin . ID , <EOL> alphaMaterials . JackOLantern . ID , <EOL> ] <EOL> East = <NUM_LIT:0> <EOL> South = <NUM_LIT:1> <EOL> West = <NUM_LIT:2> <EOL> North = <NUM_LIT:3> <EOL> genericFlipRotation ( Pumpkin ) <EOL> class Rail : <EOL> blocktypes = [ alphaMaterials . Rail . ID ] <EOL> EastWest = <NUM_LIT:0> <EOL> NorthSouth = <NUM_LIT:1> <EOL> South = <NUM_LIT:2> <EOL> North = <NUM_LIT:3> <EOL> East = <NUM_LIT:4> <EOL> West = <NUM_LIT:5> <EOL> Northeast = <NUM_LIT:6> <EOL> Southeast = <NUM_LIT:7> <EOL> Southwest = <NUM_LIT:8> <EOL> Northwest = <NUM_LIT:9> <EOL> def generic8wayRotation ( cls ) : <EOL> cls . rotateLeft = genericRotation ( cls ) <EOL> cls . rotateLeft [ cls . Northeast ] = cls . Northwest <EOL> cls . rotateLeft [ cls . Southeast ] = cls . Northeast <EOL> cls . rotateLeft [ cls . Southwest ] = cls . Southeast <EOL> cls . rotateLeft [ cls . Northwest ] = cls . Southwest <EOL> cls . flipEastWest = genericEastWestFlip ( cls ) <EOL> cls . flipEastWest [ cls . Northeast ] = cls . Northwest <EOL> cls . flipEastWest [ cls . Northwest ] = cls . Northeast <EOL> cls . flipEastWest [ cls . Southwest ] = cls . Southeast <EOL> cls . flipEastWest [ cls . Southeast ] = cls . Southwest <EOL> cls . flipNorthSouth = genericNorthSouthFlip ( cls ) <EOL> cls . flipNorthSouth [ cls . Northeast ] = cls . Southeast <EOL> cls . flipNorthSouth [ cls . Southeast ] = cls . Northeast <EOL> cls . flipNorthSouth [ cls . Southwest ] = cls . Northwest <EOL> cls . flipNorthSouth [ cls . Northwest ] = cls . Southwest <EOL> rotationClasses . append ( cls ) <EOL> generic8wayRotation ( Rail ) <EOL> Rail . rotateLeft [ Rail . NorthSouth ] = Rail . EastWest <EOL> Rail . rotateLeft [ Rail . EastWest ] = Rail . NorthSouth <EOL> def applyBit ( apply ) : <EOL> def _applyBit ( class_or_array ) : <EOL> if hasattr ( class_or_array , "<STR_LIT>" ) : <EOL> for a in ( class_or_array . flipEastWest , <EOL> class_or_array . flipNorthSouth , <EOL> class_or_array . rotateLeft ) : <EOL> apply ( a ) <EOL> else : <EOL> array = class_or_array <EOL> apply ( array ) <EOL> return _applyBit <EOL> @ applyBit <EOL> def applyBit8 ( array ) : <EOL> array [ <NUM_LIT:8> : <NUM_LIT:16> ] = array [ <NUM_LIT:0> : <NUM_LIT:8> ] | <NUM_LIT> <EOL> @ applyBit <EOL> def applyBit4 ( array ) : <EOL> array [ <NUM_LIT:4> : <NUM_LIT:8> ] = array [ <NUM_LIT:0> : <NUM_LIT:4> ] | <NUM_LIT> <EOL> array [ <NUM_LIT:12> : <NUM_LIT:16> ] = array [ <NUM_LIT:8> : <NUM_LIT:12> ] | <NUM_LIT> <EOL> @ applyBit <EOL> def applyBits48 ( array ) : <EOL> array [ <NUM_LIT:4> : <NUM_LIT:8> ] = array [ <NUM_LIT:0> : <NUM_LIT:4> ] | <NUM_LIT> <EOL> array [ <NUM_LIT:8> : <NUM_LIT:16> ] = array [ <NUM_LIT:0> : <NUM_LIT:8> ] | <NUM_LIT> <EOL> applyThrownBit = applyBit8 <EOL> class PoweredDetectorRail ( Rail ) : <EOL> blocktypes = [ alphaMaterials . PoweredRail . ID , alphaMaterials . DetectorRail . ID ] <EOL> PoweredDetectorRail . rotateLeft = genericRotation ( PoweredDetectorRail ) <EOL> PoweredDetectorRail . rotateLeft [ PoweredDetectorRail . NorthSouth ] = PoweredDetectorRail . EastWest <EOL> PoweredDetectorRail . rotateLeft [ PoweredDetectorRail . EastWest ] = PoweredDetectorRail . NorthSouth <EOL> PoweredDetectorRail . flipEastWest = genericEastWestFlip ( PoweredDetectorRail ) <EOL> PoweredDetectorRail . flipNorthSouth = genericNorthSouthFlip ( PoweredDetectorRail ) <EOL> applyThrownBit ( PoweredDetectorRail ) <EOL> rotationClasses . append ( PoweredDetectorRail ) <EOL> class Lever : <EOL> blocktypes = [ alphaMaterials . Lever . ID ] <EOL> ThrownBit = <NUM_LIT> <EOL> South = <NUM_LIT:1> <EOL> North = <NUM_LIT:2> <EOL> West = <NUM_LIT:3> <EOL> East = <NUM_LIT:4> <EOL> EastWest = <NUM_LIT:5> <EOL> NorthSouth = <NUM_LIT:6> <EOL> Lever . rotateLeft = genericRotation ( Lever ) <EOL> Lever . rotateLeft [ Lever . NorthSouth ] = Lever . EastWest <EOL> Lever . rotateLeft [ Lever . EastWest ] = Lever . NorthSouth <EOL> Lever . flipEastWest = genericEastWestFlip ( Lever ) <EOL> Lever . flipNorthSouth = genericNorthSouthFlip ( Lever ) <EOL> applyThrownBit ( Lever ) <EOL> rotationClasses . append ( Lever ) <EOL> class Button : <EOL> blocktypes = [ alphaMaterials . Button . ID ] <EOL> PressedBit = <NUM_LIT> <EOL> South = <NUM_LIT:1> <EOL> North = <NUM_LIT:2> <EOL> West = <NUM_LIT:3> <EOL> East = <NUM_LIT:4> <EOL> Button . rotateLeft = genericRotation ( Button ) <EOL> Button . flipEastWest = genericEastWestFlip ( Button ) <EOL> Button . flipNorthSouth = genericNorthSouthFlip ( Button ) <EOL> applyThrownBit ( Button ) <EOL> rotationClasses . append ( Button ) <EOL> class SignPost : <EOL> blocktypes = [ alphaMaterials . Sign . ID ] <EOL> rotateLeft = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> rotateLeft -= <NUM_LIT:4> <EOL> rotateLeft &= <NUM_LIT> <EOL> flipEastWest = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> flipNorthSouth = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> pass <EOL> rotationClasses . append ( SignPost ) <EOL> class Bed : <EOL> blocktypes = [ alphaMaterials . Bed . ID ] <EOL> West = <NUM_LIT:0> <EOL> North = <NUM_LIT:1> <EOL> East = <NUM_LIT:2> <EOL> South = <NUM_LIT:3> <EOL> genericFlipRotation ( Bed ) <EOL> applyBit8 ( Bed ) <EOL> applyBit4 ( Bed ) <EOL> class Door : <EOL> blocktypes = [ <EOL> alphaMaterials . IronDoor . ID , <EOL> alphaMaterials . WoodenDoor . ID , <EOL> ] <EOL> TopHalfBit = <NUM_LIT> <EOL> SwungCCWBit = <NUM_LIT> <EOL> Northeast = <NUM_LIT:0> <EOL> Southeast = <NUM_LIT:1> <EOL> Southwest = <NUM_LIT:2> <EOL> Northwest = <NUM_LIT:3> <EOL> rotateLeft = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> Door . rotateLeft [ Door . Northeast ] = Door . Northwest <EOL> Door . rotateLeft [ Door . Southeast ] = Door . Northeast <EOL> Door . rotateLeft [ Door . Southwest ] = Door . Southeast <EOL> Door . rotateLeft [ Door . Northwest ] = Door . Southwest <EOL> applyBit4 ( Door . rotateLeft ) <EOL> Door . flipEastWest = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> Door . flipEastWest [ Door . Northeast ] = Door . Northwest <EOL> Door . flipEastWest [ Door . Northwest ] = Door . Northeast <EOL> Door . flipEastWest [ Door . Southwest ] = Door . Southeast <EOL> Door . flipEastWest [ Door . Southeast ] = Door . Southwest <EOL> Door . flipEastWest [ <NUM_LIT:4> : <NUM_LIT:8> ] = Door . flipEastWest [ <NUM_LIT:0> : <NUM_LIT:4> ] <EOL> Door . flipEastWest [ <NUM_LIT:0> : <NUM_LIT:4> ] = Door . flipEastWest [ <NUM_LIT:4> : <NUM_LIT:8> ] | <NUM_LIT> <EOL> Door . flipEastWest [ <NUM_LIT:8> : <NUM_LIT:16> ] = Door . flipEastWest [ <NUM_LIT:0> : <NUM_LIT:8> ] | <NUM_LIT> <EOL> Door . flipNorthSouth = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> Door . flipNorthSouth [ Door . Northeast ] = Door . Southeast <EOL> Door . flipNorthSouth [ Door . Northwest ] = Door . Southwest <EOL> Door . flipNorthSouth [ Door . Southwest ] = Door . Northwest <EOL> Door . flipNorthSouth [ Door . Southeast ] = Door . Northeast <EOL> Door . flipNorthSouth [ <NUM_LIT:4> : <NUM_LIT:8> ] = Door . flipNorthSouth [ <NUM_LIT:0> : <NUM_LIT:4> ] <EOL> Door . flipNorthSouth [ <NUM_LIT:0> : <NUM_LIT:4> ] = Door . flipNorthSouth [ <NUM_LIT:4> : <NUM_LIT:8> ] | <NUM_LIT> <EOL> Door . flipNorthSouth [ <NUM_LIT:8> : <NUM_LIT:16> ] = Door . flipNorthSouth [ <NUM_LIT:0> : <NUM_LIT:8> ] | <NUM_LIT> <EOL> rotationClasses . append ( Door ) <EOL> class RedstoneRepeater : <EOL> blocktypes = [ <EOL> alphaMaterials . RedstoneRepeaterOff . ID , <EOL> alphaMaterials . RedstoneRepeaterOn . ID , <EOL> ] <EOL> East = <NUM_LIT:0> <EOL> South = <NUM_LIT:1> <EOL> West = <NUM_LIT:2> <EOL> North = <NUM_LIT:3> <EOL> genericFlipRotation ( RedstoneRepeater ) <EOL> applyBits48 ( RedstoneRepeater ) <EOL> class Trapdoor : <EOL> blocktypes = [ alphaMaterials . Trapdoor . ID ] <EOL> West = <NUM_LIT:0> <EOL> East = <NUM_LIT:1> <EOL> South = <NUM_LIT:2> <EOL> North = <NUM_LIT:3> <EOL> genericFlipRotation ( Trapdoor ) <EOL> applyOpenedBit = applyBit4 <EOL> applyOpenedBit ( Trapdoor ) <EOL> class PistonBody : <EOL> blocktypes = [ alphaMaterials . StickyPiston . ID , alphaMaterials . Piston . ID ] <EOL> Down = <NUM_LIT:0> <EOL> Up = <NUM_LIT:1> <EOL> East = <NUM_LIT:2> <EOL> West = <NUM_LIT:3> <EOL> North = <NUM_LIT:4> <EOL> South = <NUM_LIT:5> <EOL> genericFlipRotation ( PistonBody ) <EOL> applyPistonBit = applyBit8 <EOL> applyPistonBit ( PistonBody ) <EOL> class PistonHead ( PistonBody ) : <EOL> blocktypes = [ alphaMaterials . PistonHead . ID ] <EOL> rotationClasses . append ( PistonHead ) <EOL> class Vines : <EOL> blocktypes = [ alphaMaterials . Vines . ID ] <EOL> WestBit = <NUM_LIT:1> <EOL> NorthBit = <NUM_LIT:2> <EOL> EastBit = <NUM_LIT:4> <EOL> SouthBit = <NUM_LIT:8> <EOL> rotateLeft = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> flipEastWest = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> flipNorthSouth = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> class HugeMushroom : <EOL> blocktypes = [ alphaMaterials . HugeRedMushroom . ID , alphaMaterials . HugeBrownMushroom . ID ] <EOL> Northeast = <NUM_LIT:1> <EOL> East = <NUM_LIT:2> <EOL> Southeast = <NUM_LIT:3> <EOL> South = <NUM_LIT:6> <EOL> Southwest = <NUM_LIT:9> <EOL> West = <NUM_LIT:8> <EOL> Northwest = <NUM_LIT:7> <EOL> North = <NUM_LIT:4> <EOL> generic8wayRotation ( HugeMushroom ) <EOL> Vines . rotateLeft = <NUM_LIT> & ( ( Vines . rotateLeft >> <NUM_LIT:1> ) | ( Vines . rotateLeft << <NUM_LIT:3> ) ) <EOL> EastWestBits = ( Vines . EastBit | Vines . WestBit ) <EOL> Vines . flipEastWest [ ( Vines . flipEastWest & EastWestBits ) > <NUM_LIT:0> ] ^= EastWestBits <EOL> NorthSouthBits = ( Vines . NorthBit | Vines . SouthBit ) <EOL> Vines . flipNorthSouth [ ( Vines . flipNorthSouth & NorthSouthBits ) > <NUM_LIT:0> ] ^= NorthSouthBits <EOL> rotationClasses . append ( Vines ) <EOL> def masterRotationTable ( attrname ) : <EOL> table = zeros ( ( <NUM_LIT> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> table [ : ] = arange ( <NUM_LIT:16> , dtype = '<STR_LIT>' ) <EOL> for cls in rotationClasses : <EOL> if hasattr ( cls , attrname ) : <EOL> blocktable = getattr ( cls , attrname ) <EOL> for blocktype in cls . blocktypes : <EOL> table [ blocktype ] = blocktable <EOL> return table <EOL> def rotationTypeTable ( ) : <EOL> table = { } <EOL> for cls in rotationClasses : <EOL> for b in cls . blocktypes : <EOL> table [ b ] = cls <EOL> return table <EOL> class BlockRotation : <EOL> rotateLeft = masterRotationTable ( "<STR_LIT>" ) <EOL> flipEastWest = masterRotationTable ( "<STR_LIT>" ) <EOL> flipNorthSouth = masterRotationTable ( "<STR_LIT>" ) <EOL> flipVertical = masterRotationTable ( "<STR_LIT>" ) <EOL> typeTable = rotationTypeTable ( ) <EOL> def SameRotationType ( blocktype1 , blocktype2 ) : <EOL> return BlockRotation . typeTable . get ( blocktype1 . ID ) == BlockRotation . typeTable . get ( blocktype2 . ID , BlockRotation ) <EOL> def FlipVertical ( blocks , data ) : <EOL> data [ : ] = BlockRotation . flipVertical [ blocks , data ] <EOL> def FlipNorthSouth ( blocks , data ) : <EOL> data [ : ] = BlockRotation . flipNorthSouth [ blocks , data ] <EOL> def FlipEastWest ( blocks , data ) : <EOL> data [ : ] = BlockRotation . flipEastWest [ blocks , data ] <EOL> def RotateLeft ( blocks , data ) : <EOL> data [ : ] = BlockRotation . rotateLeft [ blocks , data ] </s>
