Glowstone Perimeter

Just wanted to share a quick MCEdit filter that I put together. Given a selection, this replaces the top layer of the perimeter circle with glowstone. On our server we use this to mark off private land borders so that people don’t accidentally interfere with one another or set up camp on top of one another. Feel free to use it as you like.

from pymclevel.materials import alphaMaterials
import math

displayName = "Player Boundary"

inputs = (

replacableblocks = [
replacableIDs = [b.ID for b in replacableblocks]

def replacable(block):
    return block in replacableIDs
def borderblock(x, z, radius):
    distance = math.sqrt(math.pow(radius - x, 2) + math.pow(radius - z, 2))
    return math.fabs(radius - distance) < .5

def replaceblock(level, box, x, z):
    x += box.minx
    z += box.minz
    for y in xrange(box.maxy, box.miny, -1):
        block = level.blockAt(x, y, z)
        if replacable(block):
            level.setBlockAt(x, y, z, alphaMaterials.Glowstone.ID)
            return y

def perform(level, box, options):
    width = box.maxx - box.minx
    depth = box.maxz - box.minz
    radius = width / 2
    for x in xrange(width):
        for z in xrange(depth):
            if borderblock(x, z, radius):
                replaceblock(level, box, x, z)