Advertisement
wiresegal

Helped

Oct 13th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.99 KB | None | 0 0
  1. from pymclevel import TAG_Compound, TAG_String, TAG_Int
  2. import random, mcplatform
  3.  
  4. displayName = "Random Motion"
  5.  
  6. inputs = (
  7.     ("Value",(0,-1000,1000)),
  8.     ("Entity Properties",("string","value=@e[type=ArmorStand]")),
  9.     ("Loop?",False),
  10. )
  11.  
  12. def perform(level,box,options):
  13.     val = options["Value"]
  14.     ep = options["Entity Properties"]
  15.     cmd1 = "setblock ~1 ~-1 ~ minecraft:redstone_block"
  16.     cmd2 = "setblock ~ ~ ~-1 minecraft:air"
  17.     cmd3 = "setblock ~-{} ~-1 ~ minecraft:redstone_block".format(val)
  18.     loop = options["Loop?"]
  19.    
  20.     #Create new command blocks
  21.     for x in range(box.minx, box.maxx):
  22.         for y in range(box.miny, box.maxy):
  23.             for z in range(box.minz, box.maxz):
  24.                 place = 0
  25.                 for i in range(val):
  26.                     level.setBlockAt(x+i,y,z,137)
  27.                     rots = rrot(level,box,options)
  28.                     newcommand = """entitydata {0} {{{1}}}""".format(ep,rots)
  29.                     level.setBlockAt(x+i,y+2,z,137)
  30.                     level.setBlockAt(x+i,y+1,z+1,137)
  31.                     chunk = level.getChunk((x+i)/16, z/16)
  32.                     if z/16 != (z+1)/16:
  33.                         chunk2 = level.getChunk((x+i)/16, (z+1)/16)
  34.                     else:
  35.                         chunk2 = chunk
  36.                     chunk.TileEntities.append(command_block_NBT(x+i,y,z,newcommand))
  37.                     chunk.TileEntities.append(command_block_NBT(x+i,y+2,z,cmd1))
  38.                     chunk2.TileEntities.append(command_block_NBT(x+i,y+1,z+1,cmd2))
  39.     if loop:
  40.         level.setBlockAt(x+val,y+2,z,137)
  41.         chunk.TileEntities.append(command_block_NBT(x+val,y+2,z,cmd3))
  42.         level.setBlockAt(x+val,y+1,z+1,137)
  43.         chunk.TileEntities.append(command_block_NBT(x+val,y+1,z+1,cmd2))
  44.         level.setBlockAt(x+val,y,z,159)
  45.         level.setBlockDataAt(x+val,y,z,14)
  46.    
  47. def rrot(level,box,options):
  48.     rots = """Pose:{{RightArm:[{0}f,{1}f,{2}f]}}""".format(random.randint(0,360), random.randint(0,360), random.randint(0,360))
  49.     return rots
  50.  
  51. def command_block_NBT(x,y,z,command):
  52.     root = TAG_Compound()
  53.     root["Command"] = TAG_String(command)
  54.     root["id"] = TAG_String(u'Control')
  55.     root["CustomName"] = TAG_String(u'@')
  56.     root["z"] = TAG_Int(z)
  57.     root["y"] = TAG_Int(y)
  58.     root["x"] = TAG_Int(x)
  59.    
  60.     return root
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement