Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Made by @QuantumWarpCode.
- # Feel free to modify and use this filter however you wish. If you do,
- # please give credit to Elopus001.
- from pymclevel import TAG_List
- from pymclevel import TAG_Byte
- from pymclevel import TAG_Int
- from pymclevel import TAG_Compound
- import random
- displayName = "Generate a City"
- xmod = 0
- ymod = 0
- zmod = 0
- levels = 0
- def perform(level, box, options):
- level.markDirtyBox(box)
- height = box.maxy - box.miny
- width = box.maxx - box.minx
- length = box.maxz - box.minz
- global xmod
- xmod = box.minx
- global ymod
- ymod = box.miny
- global zmod
- zmod = box.minz
- global levels
- levelMod = (height - 2) % 4
- levels = (height - 2 - levelMod) / 4
- createFilledOutline(1, width - 1, 1, length - 1, 0, 43, 0, 2, 0, level)
- createOutline(0, width, 0, length, 0, 43, 0, level)
- createGrid(0, width, 0, length, 0, 43, 0, level)
- callBuild(0, width, 0, length, 0, level)
- def setBlock(x, y, z, block, blockdata, level):
- global xmod
- global ymod
- global zmod
- level.setBlockAt(x + xmod, y + ymod, z + zmod, block)
- level.setBlockDataAt(x + xmod, y + ymod, z + zmod, blockdata)
- def createFilledOutline(xstart, xend, zstart, zend, y, block, blockdata, block2, block2data, level):
- for x in range(xstart, xend):
- for z in range(zstart, zend):
- xEdge = (x == xstart or x == xend - 1)
- zEdge = (z == zstart or z == zend - 1)
- if xEdge or zEdge:
- setBlock(x, y, z, block, blockdata, level)
- else:
- setBlock(x, y, z, block2, block2data, level)
- def createCornerOutline(xstart, xend, zstart, zend, y, block, blockdata, block2, block2data, level):
- for x in range(xstart, xend):
- for z in range(zstart, zend):
- xEdge = (x == xstart or x == xend - 1)
- zEdge = (z == zstart or z == zend - 1)
- if xEdge and zEdge:
- setBlock(x, y, z, block2, block2data, level)
- elif xEdge or zEdge:
- setBlock(x, y, z, block, blockdata, level)
- def createOutline(xstart, xend, zstart, zend, y, block, blockdata, level):
- for x in range(xstart, xend):
- for z in range(zstart, zend):
- xEdge = (x == xstart or x == xend - 1)
- zEdge = (z == zstart or z == zend - 1)
- if xEdge or zEdge:
- setBlock(x, y, z, block, blockdata, level)
- def createGrid(xstart, xend, zstart, zend, y, block, blockdata, level):
- for x in range(xstart, xend):
- for z in range(zstart, zend):
- xEdge = (x % 16 == 0 or (x - 1) % 16 == 0)
- zEdge = (z % 16 == 0 or (z - 1) % 16 == 0)
- if xEdge or zEdge:
- setBlock(x, y, z, block, blockdata, level)
- def createSkyscraper(xstart, zstart, level):
- global levels
- space = random.randint(2, 5)
- height = (random.randint(1, levels)) * 4
- for y in range (0, height + 1):
- if y % 4 == 0:
- createFilledOutline(xstart + space, xstart + 16 - space, zstart + space, zstart + 16 - space, y, 98, 0, 5, 5,level)
- else:
- createCornerOutline(xstart + space, xstart + 16 - space, zstart + space, zstart + 16 - space, y, 102, 0, 98, 0, level)
- createOutline(xstart + space, xstart + 16 - space, zstart + space, zstart + 16 - space, height + 1, 98, 0, level)
- def callBuild(xstart, xend, zstart, zend, y, level):
- for x in range(xstart, xend):
- for z in range(zstart, zend):
- xEdge = ((x - 1) % 16 == 0 and x != xend - 1)
- zEdge = ((z - 1) % 16 == 0 and z != zend - 1)
- if xEdge and zEdge:
- setBlock(x, y + 1, z, 1, 0, level)
- createSkyscraper(x, z, level)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement