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.
- # Version : 1
- 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"
- inputs = (
- ("Basements (These require 4 blocks of height each)", 3),
- ("Minimum Height", 1),
- )
- xmod = 0
- ymod = 0
- zmod = 0
- levels = 0
- basements = 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 basements
- basements = options["Basements (These require 4 blocks of height each)"]
- global minHeight
- minHeight = options["Minimum Height"]
- global levels
- levelMod = (height - (basements * 4) - 2) % 4
- levels = ((height - (basements * 4)) - 2 - levelMod) / 4
- fillCube(0, width, 0, length, 0, basements * 4, 3, 0, level)
- createFilledOutline(1, width - 1, 1, length - 1, 0 + (basements * 4), 43, 0, 2, 0, level)
- createOutline(0, width, 0, length, 0 + (basements * 4), 43, 0, level)
- createGrid(0, width, 0, length, 0 + (basements * 4), 43, 0, level)
- callBuild(0, width, 0, length, 0 + (basements * 4), level)
- def setBlock(x, y, z, block, blockdata, level):
- global xmod
- global ymod
- global zmod
- global basements
- level.setBlockAt(x + xmod, y + ymod, z + zmod, block)
- level.setBlockDataAt(x + xmod, y + ymod, z + zmod, blockdata)
- def fillRectangle(xstart, xend, zstart, zend, y, block, blockdata, level):
- for x in range(xstart, xend):
- for z in range(zstart, zend):
- setBlock(x, y, z, block, blockdata, level)
- def fillCube(xstart, xend, zstart, zend, ystart, yend, block, blockdata, level):
- for x in range(xstart, xend):
- for y in range(ystart, yend):
- for z in range(zstart, zend):
- setBlock(x, y, z, block, blockdata, level)
- 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, ystart, level):
- global levels
- global basements
- space = random.randint(2, 5)
- global minHeight
- height = (random.randint(minHeight, levels)) * 4
- bheight = random.randint(0, basements) * 4
- ladderPos = (random.randint(1, 4))
- ladderRot = (random.randint(1, 2))
- if ladderPos == 1:
- ladderTowerXPos = xstart + 7
- ladderTowerZPos = zstart + 7
- if ladderRot == 1:
- ladderXPos = ladderTowerXPos + 1
- ladderZPos = ladderTowerZPos
- ladderData = 5
- elif ladderRot == 2:
- ladderXPos = ladderTowerXPos
- ladderZPos = ladderTowerZPos + 1
- ladderData = 3
- elif ladderPos == 2:
- ladderTowerXPos = xstart + 8
- ladderTowerZPos = zstart + 7
- if ladderRot == 1:
- ladderXPos = ladderTowerXPos - 1
- ladderZPos = ladderTowerZPos
- ladderData = 4
- elif ladderRot == 2:
- ladderXPos = ladderTowerXPos
- ladderZPos = ladderTowerZPos + 1
- ladderData = 3
- elif ladderPos == 3:
- ladderTowerXPos = xstart + 7
- ladderTowerZPos = zstart + 8
- if ladderRot == 1:
- ladderXPos = ladderTowerXPos + 1
- ladderZPos = ladderTowerZPos
- ladderData = 5
- elif ladderRot == 2:
- ladderXPos = ladderTowerXPos
- ladderZPos = ladderTowerZPos - 1
- ladderData = 2
- elif ladderPos == 4:
- ladderTowerXPos = xstart + 8
- ladderTowerZPos = zstart + 8
- if ladderRot == 1:
- ladderXPos = ladderTowerXPos - 1
- ladderZPos = ladderTowerZPos
- ladderData = 4
- elif ladderRot == 2:
- ladderXPos = ladderTowerXPos
- ladderZPos = ladderTowerZPos - 1
- ladderData = 2
- for y in range (0, height + bheight + 1):
- if y % 4 == 0:
- createFilledOutline(xstart + space, xstart + 16 - space, zstart + space, zstart + 16 - space, y + ystart - bheight, 98, 0, 5, 5, level)
- if y != height + bheight:
- setBlock(ladderTowerXPos, y + ystart - bheight, ladderTowerZPos, 98, 0, level)
- if y != 0:
- setBlock(ladderXPos, y + ystart - bheight, ladderZPos, 65, ladderData, level)
- else:
- if y > bheight:
- createCornerOutline(xstart + space, xstart + 16 - space, zstart + space, zstart + 16 - space, y + ystart - bheight, 102, 0, 98, 0, level)
- setBlock(ladderTowerXPos, y + ystart - bheight, ladderTowerZPos, 98, 0, level)
- setBlock(ladderXPos, y + ystart - bheight, ladderZPos, 65, ladderData, level)
- else:
- createFilledOutline(xstart + space, xstart + 16 - space, zstart + space, zstart + 16 - space, y + ystart - bheight, 98, 0, 0, 0, level)
- setBlock(ladderTowerXPos, y + ystart - bheight, ladderTowerZPos, 98, 0, level)
- setBlock(ladderXPos, y + ystart - bheight, ladderZPos, 65, ladderData, level)
- createOutline(xstart + space, xstart + 16 - space, zstart + space, zstart + 16 - space, height + ystart + 1, 98, 0, level)
- if space == 4:
- hedge = random.randint(1, 3)
- if hedge == 1:
- createOutline(xstart + 2, xstart + 16 - 2, zstart + 2, zstart + 16 - 2, 1 + ystart, 18, 3, level)
- doors = (random.randint(1, 15))
- #doors = 4
- if doors == 1 or doors == 5 or doors == 7 or doors == 9 or doors == 11 or doors == 12 or doors == 13 or doors == 15:
- fillRectangle(xstart + 7, xstart + 9, zstart + 1, zstart + space, ystart, 43, 0, level)
- fillRectangle(xstart + 7, xstart + 9, zstart + 1, zstart + space + 1, ystart + 1, 0, 0, level)
- fillRectangle(xstart + 7, xstart + 9, zstart + 1, zstart + space + 1, ystart + 2, 0, 0, level)
- if doors == 2 or doors == 5 or doors == 8 or doors == 10 or doors == 11 or doors == 12 or doors == 14 or doors == 15:
- fillRectangle(xstart + 1, xstart + space, zstart + 7, zstart + 9, ystart, 43, 0, level)
- fillRectangle(xstart + 1, xstart + space + 1, zstart + 7, zstart + 9, ystart + 1, 0, 0, level)
- fillRectangle(xstart + 1, xstart + space + 1, zstart + 7, zstart + 9, ystart + 2, 0, 0, level)
- if doors == 3 or doors == 6 or doors == 7 or doors == 10 or doors == 11 or doors == 13 or doors == 14 or doors == 15:
- fillRectangle(xstart + 7, xstart + 9, zstart + 16 - space, zstart + 16 - 1, ystart, 43, 0, level)
- fillRectangle(xstart + 7, xstart + 9, zstart + 16 - space - 1, zstart + 16 - 1, ystart + 1, 0, 0, level)
- fillRectangle(xstart + 7, xstart + 9, zstart + 16 - space - 1, zstart + 16 - 1, ystart + 2, 0, 0, level)
- if doors == 4 or doors == 6 or doors == 8 or doors == 9 or doors == 12 or doors == 13 or doors == 14 or doors == 15:
- fillRectangle(xstart + 16 - space, xstart + 16 - 1, zstart + 7, zstart + 9, ystart, 43, 0, level)
- fillRectangle(xstart + 16 - space - 1, xstart + 16 - 1, zstart + 7, zstart + 9, ystart + 1, 0, 0, level)
- fillRectangle(xstart + 16 - space - 1, xstart + 16 - 1, zstart + 7, zstart + 9, ystart + 2, 0, 0, level)
- def createDirtLot(xstart, zstart, ystart, level):
- fillRectangle(xstart + 1, xstart + 16 - 1, zstart + 1, zstart + 16 - 1, ystart, 3, 1, level)
- def createFlowerLot(xstart, zstart, ystart, level):
- for x in range(xstart + 1, xstart + 16 - 1):
- for z in range(zstart + 1, zstart + 16 - 1):
- flower = random.randint(1, 5)
- if flower == 5:
- setBlock(x, ystart + 1, z, 38, random.randint(0,8), 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)
- type = random.randint(1,10)
- if type == 10:
- createDirtLot(x, z, y, level)
- elif type == 9:
- createFlowerLot(x, z, y, level)
- else:
- createSkyscraper(x, z, y, level)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement