Advertisement
Guest User

EndGateway

a guest
Aug 2nd, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.96 KB | None | 0 0
  1. # MCEdit filter by daxorion27
  2. # A huge thanks goes to sethbling for his "entity code" filter : https://www.youtube.com/sethbling , http://sethbling.com/downloads/mcedit-filters/entitycode/
  3.  
  4. displayName = "End Gateway"
  5.  
  6. from pymclevel import TAG_List
  7. from pymclevel import TAG_Byte
  8. from pymclevel import TAG_Int
  9. from pymclevel import TAG_Compound
  10. from pymclevel import TAG_Short
  11. from pymclevel import TAG_Double
  12. from pymclevel import TAG_Float
  13. from pymclevel import TAG_String
  14. from pymclevel import TAG_Long
  15. from pymclevel import TAG_Int_Array
  16. from numpy import zeros
  17.  
  18. try:
  19.     exitSetByFunction
  20. except NameError:
  21.     exitSetByFunction = False
  22.  
  23. inputs = (
  24.     ("Function:", (
  25.         "Set Exit Position",
  26.         "Clear Exit Position",
  27.         "Create End Gateway"
  28.     )),
  29.     ("X", 0),
  30.     ("Y", (1,1,255)),
  31.     ("Z", 0),
  32.     ("These values are used to define the exit, but if you set the exit with a function they are overwritten, to use them again run clear exit position.", "label"),
  33. )
  34.  
  35. def perform (level, box, options):
  36.     function = options["Function:"]
  37.     global exitSetByFunction
  38.     global functionExitX
  39.     global functionExitY
  40.     global functionExitZ
  41.     if exitSetByFunction and function == "Create End Gateway":
  42.         exitX = functionExitX
  43.         exitY = functionExitY
  44.         exitZ = functionExitZ
  45.         for x in xrange (box.minx,box.maxx):
  46.             for y in xrange (box.miny,box.maxy):
  47.                 for z in xrange (box.minz,box.maxz):
  48.                     level.setBlockAt (x, y, z, 209)
  49.                     level.setBlockDataAt(x, y, z, 0)
  50.                     createEndGateway(x,y,z,exitX,exitY,exitZ,level)
  51.         print "Incredible Success!"
  52.     elif function == "Create End Gateway":
  53.         exitX = options["X"]
  54.         exitY = options["Y"]
  55.         exitZ = options["Z"]
  56.         for x in xrange (box.minx,box.maxx):
  57.             for y in xrange (box.miny,box.maxy):
  58.                 for z in xrange (box.minz,box.maxz):
  59.                     level.setBlockAt (x, y, z, 209)
  60.                     level.setBlockDataAt(x, y, z, 0)
  61.                     createEndGateway(x,y,z,exitX,exitY,exitZ,level)
  62.         print "Success!"
  63.     elif function == "Clear Exit Position":
  64.         exitSetByFunction = False
  65.         print "Position reset"
  66.     elif function == "Set Exit Position":
  67.         if box.width == 1 and box.height == 1 and box.length == 1:
  68.             functionExitX = box.minx
  69.             functionExitY = box.miny
  70.             functionExitZ = box.minz
  71.             print "Position set successfully:"
  72.             print "X: " + str(functionExitX)
  73.             print "Y: " + str(functionExitY)
  74.             print "Z: " + str(functionExitZ)
  75.             exitSetByFunction = True
  76.         else:
  77.             raise Exception("Your box can only be one block!")
  78.  
  79. def createEndGateway(x,y,z,exitX,exitY,exitZ,level):
  80.     endGateway = TAG_Compound()
  81.     endGateway["x"] = TAG_Int(x)
  82.     endGateway["Life"] = TAG_Long(10000)
  83.     endGateway["y"] = TAG_Int(y)
  84.     exitPortal = TAG_Compound()
  85.     exitPortal["X"] = TAG_Int(exitX + 5)
  86.     exitPortal["Y"] = TAG_Int(exitY)
  87.     exitPortal["Z"] = TAG_Int(exitZ + 5)
  88.     endGateway["ExitPortal"] = exitPortal
  89.     endGateway["z"] = TAG_Int(z)
  90.     endGateway["id"] = TAG_String(u'EndGateway')
  91.    
  92.     chunk = level.getChunk(x/16,z/16)
  93.     chunk.TileEntities.append(endGateway)
  94.     chunk.dirty = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement