def getBuildArea(args): if (args.player): _r = args.radius*2 area = iu.requestPlayerArea(_r, _r) elif (args.buildarea): area = iu.requestBuildArea() elif (args.coordinates): x0, y0, z0, x1, y1, z1 = args.coordinates iu.setBuildArea(*(args.coordinates)) area = iu.requestBuildArea() smallest_side = min(abs(area[0] - area[3]), abs(area[2] - area[5])) if smallest_side < minimum_side: raise ValueError("Smallest side of user-defined build area is too small (should be at least {})".format(minimum_side)) return area
def getBuildArea(size=128): buildArea = interfaceUtils.requestBuildArea() area = (0, 0, size, size) if buildArea != -1: x1 = buildArea["xFrom"] z1 = buildArea["zFrom"] x2 = buildArea["xTo"] z2 = buildArea["zTo"] area = (x1, z1, x2-x1 + 1, z2-z1 + 1) return area # (x pos, z pos, x size, z size)
import houseUtils import interfaceUtils import mapUtils from houseUtils import House from worldLoader import WorldSlice # x position, z position, x size, z size area = (0, 0, 64, 64) # default build area # Do we send blocks in batches to speed up the generation process? USE_BATCHING = True # see if a build area has been specified # you can set a build area in minecraft using the /setbuildarea command buildArea = interfaceUtils.requestBuildArea() if buildArea != -1: x1 = buildArea["xFrom"] z1 = buildArea["zFrom"] x2 = buildArea["xTo"] z2 = buildArea["zTo"] # print(buildArea) area = (x1, z1, x2 - x1, z2 - z1) print("Build area is at position %s, %s with size %s, %s" % area) # load the world data # this uses the /chunks endpoint in the background worldSlice = WorldSlice(area) heightmap = worldSlice.heightmaps["MOTION_BLOCKING"] heightmap = worldSlice.heightmaps["MOTION_BLOCKING_NO_LEAVES"]
# ! /usr/bin/python3 """### Displays a map of the build area.""" __all__ = ['WorldSlice'] # __version__ import blockColors import cv2 import interfaceUtils import matplotlib.pyplot as plt import numpy as np from worldLoader import WorldSlice if __name__ == '__main__': # see if a different build area was defined ingame x1, y1, z1, x2, y2, z2 = interfaceUtils.requestBuildArea() # load the world data and extract the heightmap(s) slice = WorldSlice(x1, z1, x2, z2) heightmap = np.array(slice.heightmaps["OCEAN_FLOOR"], dtype=np.uint8) # calculate the gradient (steepness) gradientX = cv2.Scharr(heightmap, cv2.CV_16S, 1, 0) gradientY = cv2.Scharr(heightmap, cv2.CV_16S, 0, 1) # create a dictionary mapping block ids ("minecraft:...") to colors palette = {} for hex, blocks in blockColors.PALETTE.items(): for block in blocks: palette[block] = hex
# Change maximum buffer size (default is 1024 blocks, set 4096 for speed) # >>> interfaceUtils.setBufferLimit(100) # Send blocks to world # >>> interfaceUtils.sendBlocks() # NOTE: The buffer will automatically place its blocks once it gets full # NOTE: It is a good idea to call sendBlocks() after completing a task, # so that you can see the result without having to wait # IMPORTANT: A crash may prevent the blocks from being placed # see if a build area has been specified # you can set a build area in minecraft using the /setbuildarea command interfaceUtils.runCommand( "execute at @p run setbuildarea ~-64 0 ~-64 ~64 256 ~64") buildArea = interfaceUtils.requestBuildArea() if buildArea != -1: x1 = buildArea["xFrom"] z1 = buildArea["zFrom"] x2 = buildArea["xTo"] z2 = buildArea["zTo"] # print(buildArea) area = (x1, z1, x2 - x1, z2 - z1) startx, starty, startz, endx, endy, endz = interfaceUtils.requestBuildArea() def heightAt(x, z): """Access height using local coordinates.""" # Warning: # Heightmap coordinates are not equal to world coordinates! return heightmap[(x - startx, z - startz)]