def render (self): # add a signpost at groundlevel try: chunk = self.parent.world.getChunk(self.pos.x>>4, self.pos.z>>4) mat = materials.materialById(chunk.Blocks[8,8,self.pos.y]) if mat is materials.Air: self.parent.setblock(self.offset + Vec(8, 0, 8), self.stone,0) except: print 'Cannot identify central material' self.parent.setblock(self.offset + Vec(8, -1, 8), materials.SignPost, random.randint(0,7)) self.parent.addsign(self.offset + Vec(8,-1,8), "", self.parent.owner, "- was here -", "Keep away!")
def render(self): # add a signpost at groundlevel try: chunk = self.parent.world.getChunk(self.pos.x >> 4, self.pos.z >> 4) mat = materials.materialById(chunk.Blocks[8, 8, self.pos.y]) if mat is materials.Air: self.parent.setblock(self.offset + Vec(8, 0, 8), self.stone, 0) except: print 'Cannot identify central material' self.parent.setblock(self.offset + Vec(8, -1, 8), materials.SignPost, random.randint(0, 7)) self.parent.addsign(self.offset + Vec(8, -1, 8), "", self.parent.owner, "- was here -", "Keep away!")
def addclearing(self, center, diam): # flatten a disc of ground, erase any trees # centre is in world coordinates # identify the ground material at the centre try: chunk = self.parent.world.getChunk(center.x >> 4, center.z >> 4) mat = materials.materialById(chunk.Blocks[center.x & 15, center.z & 15, center.y]) except: print 'Cannot identify central material' mat = materials.Dirt # Now make sure we have something solid if mat is None or mat is False or not isinstance( mat, materials.Material): print 'Center material is %s' % mat mat = materials.Dirt if mat.val == materials.Air.val or mat.val == materials.StillWater.val: mat = materials.Dirt self.offset.y -= 1 sel.pos.y += 1 center.y -= 1 p0 = Vec(center.x - diam / 2 - self.parent.position.x, self.parent.position.y - center.y, center.z - diam / 2 - self.parent.position.z) p1 = p0.trans(diam + 1, 0, diam + 1) # Iterate around the entire disc for p in iterate_disc(p0, p1): # At least 4 clear blocks above self.parent.setblock(p.up(1), materials.Air) self.parent.setblock(p.up(2), materials.Air) self.parent.setblock(p.up(3), materials.Air) self.parent.setblock(p.up(4), materials.Air) # Set the disc to the base material self.parent.setblock(p, mat) # In case ground is sloping or has gaps, add underlying blocks self.parent.setblock(p.down(1), mat, soft=True) self.parent.setblock(p.down(2), mat, soft=True) self.parent.setblock(p.down(3), mat, soft=True) # Iterate up to remove any trees # This seems to not be working correctly? i = 5 while chunk.Blocks[p.x & 0xf, p.z & 0xf, center.y - i] == materials.Wood.val: # delete the tree self.parent.setblock(p.up(i), materials.Air) i = i + 1
def addclearing(self, center, diam, clear_surface=True): # flatten a disc of ground, erase any trees # centre is in world coordinates # identify the ground material at the centre try: chunk = self.parent.world.getChunk(center.x >> 4, center.z >> 4) mat = materials.materialById(chunk.Blocks[center.x & 15, center.z & 15, center.y]) except: print 'Cannot identify central material' mat = materials.Dirt # Now make sure we have something solid if mat is None or mat is False or not isinstance( mat, materials.Material): print 'Center material is %s' % mat mat = materials.Dirt if mat.val == materials.Air.val or mat.val == materials.StillWater.val: mat = materials.Dirt self.offset.y -= 1 sel.pos.y += 1 center.y -= 1 p0 = Vec(center.x - diam / 2 - self.parent.position.x, self.parent.position.y - center.y, center.z - diam / 2 - self.parent.position.z) p1 = p0.trans(diam + 1, 0, diam + 1) # Iterate around the entire disc for p in iterate_disc(p0, p1): if clear_surface: # At least 10 clear blocks above # this should delete any trees; there should be nothing above anyway for i in xrange(10): self.parent.setblock(p.up(i), materials.Air) # Set the disc to the base material self.parent.setblock(p, mat) # In case ground is sloping or has gaps, add underlying blocks self.parent.setblock(p.down(1), mat, soft=True) self.parent.setblock(p.down(2), mat, soft=True) self.parent.setblock(p.down(3), mat, soft=True)
def addclearing (self, center, diam, clear_surface=True): # flatten a disc of ground, erase any trees # centre is in world coordinates # identify the ground material at the centre try: chunk = self.parent.world.getChunk(center.x>>4, center.z>>4) mat = materials.materialById(chunk.Blocks[center.x & 15, center.z & 15, center.y]) except: print 'Cannot identify central material' mat = materials.Dirt # Now make sure we have something solid if mat is None or mat is False or not isinstance(mat, materials.Material): print 'Center material is %s' % mat mat = materials.Dirt if mat.val == materials.Air.val or mat.val == materials.StillWater.val: mat = materials.Dirt self.offset.y -= 1 sel.pos.y += 1 center.y -= 1 p0 = Vec(center.x - diam/2 - self.parent.position.x, self.parent.position.y - center.y, center.z - diam/2 - self.parent.position.z ) p1 = p0.trans(diam+1, 0, diam+1) # Iterate around the entire disc for p in iterate_disc(p0,p1): if clear_surface: # At least 10 clear blocks above # this should delete any trees; there should be nothing above anyway for i in xrange(10): self.parent.setblock(p.up(i),materials.Air) # Set the disc to the base material self.parent.setblock(p,mat) # In case ground is sloping or has gaps, add underlying blocks self.parent.setblock(p.down(1),mat,soft=True) self.parent.setblock(p.down(2),mat,soft=True) self.parent.setblock(p.down(3),mat,soft=True)