Skip to content
Permalink
Browse files

improve castle to hug terrain

  • Loading branch information...
arpruss committed Jul 3, 2015
1 parent 645d935 commit dd0335c88085dd01a294573126c004ff36a1e7f6
Showing with 30 additions and 4 deletions.
  1. +30 −4 python2-scripts/mcpipy/castle.py
@@ -29,8 +29,7 @@ def wall(x1,y1,z1, x2,y2,z2, baseHeight, altHeight, distribution):
height = altHeight
else:
height = baseHeight
h = mc.getHeight(x,z)
y0 = min(h,y1)
y0 = min(mc.getHeight(x,z),y1)
rectangularPrism(x,y0,z,x,y1+height,z,distribution)
if x >= x2 and z >= z2:
return
@@ -39,6 +38,21 @@ def wall(x1,y1,z1, x2,y2,z2, baseHeight, altHeight, distribution):
if z < z2:
z = z + 1

# Note: the first set of coordinates must be smaller than the second
def moatSide(x1,y1,z1, x2,y2,z2, depth):
x = x1
z = z1

while True:
y0 = min(mc.getHeight(x,z),y1)
mc.setBlocks(x,y0-depth+1,z,x,y0,z,WATER_STATIONARY)
if x >= x2 and z >= z2:
return
if x < x2:
x = x + 1
if z < z2:
z = z + 1

def crenellatedSquare(x1,y1,z1,width,height,altHeight,distribution):
wall(x1, y1, z1, x1+width-1, y1, z1, height, altHeight,distribution)
wall(x1, y1, z1, x1, y1, z1+width-1, height, altHeight,distribution)
@@ -48,6 +62,12 @@ def crenellatedSquare(x1,y1,z1,width,height,altHeight,distribution):
def square(x,y,z,width,height,distribution):
crenellatedSquare(x,y,z,width,height,height,distribution)

def moatSquare(x1,y1,z1,width,depth):
moatSide(x1, y1, z1, x1+width-1, y1, z1, depth)
moatSide(x1, y1, z1, x1, y1, z1+width-1, depth)
moatSide(x1+width-1, y1, z1, x1+width-1, y1, z1+width-1, depth)
moatSide(x1, y1, z1+width-1, x1+width-1, y1, z1+width-1, depth)

def crenellatedSquareWithInnerWall(x,y,z,width,baseHeight,altHeight,distribution):
crenellatedSquare(x,y,z,width,baseHeight,altHeight,distribution)
square(x+1,y,z+1,width-2,baseHeight-1,distribution)
@@ -63,27 +83,33 @@ def tower(x,y,z,width,baseHeight,altHeight,innerHeight,distribution):
(.651,Block(STONE_BRICK.id, 0)))

wallSize = 51
groundY = mc.getHeight(pos.x, pos.z)
groundY = 1+mc.getHeight(pos.x, pos.z)

# outer walls
mc.postToChat("Outer walls")
crenellatedSquareWithInnerWall(pos.x,groundY,pos.z, wallSize, 9, 10, distribution)

# towers
mc.postToChat("Towers")
tower(pos.x-7,groundY,pos.z-7, 9, 12, 13, 11, distribution)
tower(pos.x+wallSize-2,groundY,pos.z+wallSize-2, 9, 12, 13, 11, distribution)
tower(pos.x-7,groundY,pos.z+wallSize-2, 9, 12, 13, 11, distribution)
tower(pos.x+wallSize-1,groundY,pos.z-7, 9, 12, 13, 11, distribution)

# keep
mc.postToChat("Keep")
keepStartX = pos.x+wallSize/4
keepStartZ = pos.z+wallSize/4
keepWidth = wallSize / 6 * 3
tower(keepStartX,groundY, keepStartZ,keepWidth, 16, 17, 15, distribution)

# moat
mc.postToChat("Moat")
moatStartX = pos.x - 12
moatStartZ = pos.z - 12
moatInnerSize = wallSize+24

for i in range(6):
square(moatStartX-i,groundY-2,moatStartZ-i,moatInnerSize+2*i,1,WATER)
moatSquare(moatStartX-i,groundY-1,moatStartZ-i,moatInnerSize+2*i,2)

mc.postToChat("Castle done")

0 comments on commit dd0335c

Please sign in to comment.
You can’t perform that action at this time.