def clone(startPos, endPos, destPos, copyAirBlocks=True, mode='force'): if copyAirBlocks: mask = 'replace' else: mask = 'masked' if re.match('force|move|normal', mode) == None: raise ValueError( 'invalid clone mode option: %s is not one of [force|move|normal]' % mode) return mcfunctions.write_output( 'clone %s %s %s %s %s' % (Pos(startPos), Pos(endPos), Pos(destPos), mask, mode))
def spreadplayers(center, spreadDistance, maxRange, respectTeams=True, target='@a'): if len(Pos(center)) != 2: raise ValueError( 'Error: %s is invalid for this argument. You must use 2D (X,Z) coordinate' % center) return mcfunctions.write_output('spreadplayers %s %s %s %s %s' % (Pos(center), spreadDistance, maxRange, str(bool(respectTeams)).lower(), target))
def forceload_add(from_pos, to=None): if len(Pos(from_pos)) != 2: raise ValueError( 'Error: %s is invalid for this argument. You must use 2D (X,Z) coordinate' % from_pos) if to is None: if len(Pos(to)) != 2: raise ValueError( 'Error: %s is invalid for this argument. You must use 2D (X,Z) coordinate' % to) return mcfunctions.write_output('forceload add %s' % Pos(from_pos)) else: return mcfunctions.write_output('forceload add %s %s' % (Pos(from_pos), Pos(to)))
def forceload_remove(from_pos, to=None): if len(Pos(from_pos)) != 2: raise ValueError( 'Error: %s is invalid for this argument. You must use 2D (X,Z) coordinate' % from_pos) if str(from_pos).lower() == 'all': return forceload_remove_all() if to is None: if len(Pos(to)) != 2: raise ValueError( 'Error: %s is invalid for this argument. You must use 2D (X,Z) coordinate' % to) return mcfunctions.write_output('forceload remove %s' % Pos(from_pos)) else: return mcfunctions.write_output('forceload remove %s %s' % (Pos(from_pos), Pos(to)))
def spawnpoint(target, pos, angle=None): command = 'spawnpoint %s %s' % (target, Pos(pos)) if angle is not None: a = float(angle) while a < -180: a += 360 while a > 180: a -= 360 command += ' %.3f' % a return mcfunctions.write_output(command)
def fill(pos1, pos2, block, blockstate=None, data=None, dest=''): if len(str(dest)) > 0 and re.match('destroy|hollow|keep|outline|replace', dest) == None: raise ValueError( 'invalid fill option: %s is not one of [destroy|hollow|keep|outline|replace]' % dest) blockstr = block if blockstate is not None: blockstr += '[' for key in blockstate: value = blockstate[key] blockstr += '%s=%s' % (key, value) blockstr += ']' if data is not None: if type(data) == str: if data.strip()[0] != '{': blockstr += '{%s}' % data.strip() else: blockstr += data.strip() else: blockstr += json.dumps(data) command = 'fill %s %s %s %s' % (Pos(pos1), Pos(pos2), blockstr, dest) command = command.strip() return mcfunctions.write_output(command)
def teleport(target, pos): command = 'tp %s %s' % (target, Pos(pos)) return mcfunctions.write_output(command)
from mcfunctions.data import Pos p1 = Pos('~1 64 ~0') p2 = p1 + (10,20,30) print(p1) print(p2-p1) print(p1 * 2) print(p1 / 2) print(p1 // 2)