def clear(self): _, heights, _ = self._builder.getPlotStats(self._x, self._z, self._size) max_height = max(list(heights.keys())) for i in range(self._size): for j in range(self._size): for y_i in range(10): interfaceUtils.placeBlockBatched(self._x+i, max_height+y_i, self._z+j, "air")
def setBlock(x, y, z, block): """Place blocks or add them to batch.""" if USE_BATCHING: # add block to buffer, send once buffer has 100 items in it interfaceUtils.placeBlockBatched(x, y, z, block, 100) else: interfaceUtils.setBlock(x, y, z, block)
def _layFoundation(self): for i in range(self._x, self._x + self._size): for j in range(self._z, self._z + self._size): curHeight = self._builder.getHeightAt(i, j) while(curHeight < self._base_level): interfaceUtils.placeBlockBatched(i, curHeight, j, 'stone_bricks') curHeight += 1 while(curHeight > self._base_level): interfaceUtils.placeBlockBatched(i, curHeight, j, 'air') curHeight -= 1 interfaceUtils.placeBlockBatched(i, curHeight, j, self._blocks[random.randint(0, len(self._blocks))])
floor = cv2.dilate(floor, strctElmt3x3) cv2.imshow("layers", (mapUtils.normalize(walls) * 255).astype(np.uint8)) cv2.waitKey(1) for dx in range(area[2]): for dz in range(area[3]): x = area[0] + dx z = area[1] + dz y = yBase + dy # color = softPickBlockColor(dy / yHeight) # color = "light_gray" # block = ("%s_concrete" % color) if wallNoiseMask[dx, dz] else "light_gray_stained_glass" block = "smooth_stone" if wallNoiseMask[ dx, dz] else "light_gray_stained_glass" if floor[dx, dz] > 0 and not roof[dx, dz] > 0: interfaceUtils.placeBlockBatched(x, y, z, "light_gray_concrete") elif walls[dx, dz] > 0: interfaceUtils.placeBlockBatched(x, y, z, block) elif roof[dx, dz] > 0: interfaceUtils.placeBlockBatched(x, y, z, "dark_prismarine_slab") cv2.destroyWindow("layers") interfaceUtils.sendBlocks()
for x in range(area[2]): for z in range(area[3]): yTerrain = int(heightmap[(x, z)]) buildType = int(image[(x, z)]) for j in range(len(startHeights) - 1): buildingBlock = "air" if floorWallMappings[buildType][ j] == 0 else "gray_concrete" if buildType == 0 or buildType == 3 else "blackstone" y1 = startHeights[j] y2 = startHeights[j + 1] if buildType == 4: y2 = min(y2, yTerrain) for y in range(y1, y2): if not worldSlice.getBlockAt( (area[0] + x, y, area[1] + z)) in protectedBlocks: interfaceUtils.placeBlockBatched( area[0] + x, y, area[1] + z, buildingBlock, 1000) # railings ry = startHeights[1] if hrailings[(x, z)]: interfaceUtils.placeBlockBatched(area[0] + x, ry, area[1] + z, "end_rod[facing=north]", 1000) elif vrailings[(x, z)]: interfaceUtils.placeBlockBatched(area[0] + x, ry, area[1] + z, "end_rod[facing=east]", 1000) elif crailings[(x, z)]: for i in range(2): interfaceUtils.placeBlockBatched(area[0] + x, ry - 1 + i, area[1] + z, "gray_concrete", 1000) # walkway decoration
import interfaceUtils # x position, z position, x size, z size area = (0, 0, 128, 128) # default build area # 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 64 ~-64 ~64 192 ~64") buildArea = interfaceUtils.requestBuildArea() if buildArea != -1: x1 = buildArea["xFrom"] >> 4 << 4 y1 = buildArea["yFrom"] >> 4 << 4 z1 = buildArea["zFrom"] >> 4 << 4 x2 = (buildArea["xTo"] >> 4 << 4) + 1 y2 = (buildArea["yTo"] >> 4 << 4) + 1 z2 = (buildArea["zTo"] >> 4 << 4) + 1 # print(buildArea) area = (x1, z1, x2 - x1, z2 - z1) for y in range(y1, y2): for x in range(x1, x2): for z in range(z1, z2): mx = x % 16 == 0 my = y % 16 == 0 mz = z % 16 == 0 if (mx & my) | (my & mz) | (mz & mx): interfaceUtils.placeBlockBatched(x, y, z, "white_wool", 200) interfaceUtils.sendBlocks()
desiredHeight = adjDist2 + 63 newHeightmap = np.clip(desiredHeight, baseHeight - adjDist, baseHeight + adjDist) difference = (newHeightmap.astype(np.int) - heightmap) cutTrees = np.where(hmTrees > heightmap) # cv2.imshow("nhm", newHeightmap) # cv2.waitKey(0) # cut trees for p in zip(cutTrees[0], cutTrees[1]): for y in range(hmTrees[p] - 1, heightmap[p] - 1, -1): interfaceUtils.placeBlockBatched(p[0] + area[0], y, p[1] + area[1], "air") fill = np.where((difference > 0)) cut = np.where(difference < 0) for p in zip(fill[0], fill[1]): block1 = ws.getBlockAt((area[0] + p[0], heightmap[p] - 2, area[1] + p[1])) block2 = ws.getBlockAt((area[0] + p[0], heightmap[p] - 1, area[1] + p[1])) for y in range(heightmap[p] - 1, newHeightmap[p] - 1): interfaceUtils.placeBlockBatched(area[0] + p[0], y, area[1] + p[1], block1) interfaceUtils.placeBlockBatched(area[0] + p[0], newHeightmap[p] - 1, area[1] + p[1], block2) for p in zip(cut[0], cut[1]): for y in range(heightmap[p] - 1, newHeightmap[p] - 1, -1):
def setBlockAt(self, x, y_incr, z, block): y = y_incr + self.getHeightAt(x,z) if self._batching: interfaceUtils.placeBlockBatched(x, y, z, block, 100) else: interfaceUtils.setBlock(x, y, z, block)
def placeBlock(x, y, z, block): interfaceUtils.placeBlockBatched(x, y, z, block, limit=200)
def buildPaths(self, build_map): mid_point = int((self._size - 1) / 2) l_switch = True l_side = (-1, 1) # bottom to top for j in range(-1, 2): x = self._builder._x z = self._builder._z + self._z + mid_point + j top = self._builder._x + self._builder._size while (x < top): if self._x <= x < (self._x+self._size): x += 1 else: y = self._builder.getHeightAt(x, z) block = self._builder.getBlockAt(x, -1, z) if block == "minecraft:water": self._builder.setBlockAt(x, -1, z, "oak_planks") build_map.setBuildAt(x,z, 2) else: self._builder.setBlockAt(x, -1, z, "grass_path") build_map.setBuildAt(x,z, 2) # clear above path for y_i in range(10): if interfaceUtils.getBlock(x, y + y_i, z) == "minecraft:oak_fence": pass else: interfaceUtils.placeBlockBatched(x, y + y_i, z, "air") # build path lamps if j == 0: if (x % 7 == 0): l_z = self._builder._z + self._z + mid_point + l_side[l_switch] for ii in range(6): interfaceUtils.placeBlockBatched(x, y+ii, l_z, "oak_fence") interfaceUtils.placeBlockBatched(x, y+ii, z, "sea_lantern") l_switch = not(l_switch) x += 1 # left to right for i in range(-1, 2): z = self._builder._z x = self._builder._x + self._x + mid_point + i bound = self._builder._z + self._builder._size while (z < bound): if self._z <= z < (self._z+self._size): z += 1 else: y = self._builder.getHeightAt(x, z) block = self._builder.getBlockAt(x, -1, z) if block == "minecraft:water": self._builder.setBlockAt(x, -1, z, "oak_planks") build_map.setBuildAt(x,z, 2) else: self._builder.setBlockAt(x, -1, z, "grass_path") build_map.setBuildAt(x,z, 2) # clear above path for y_i in range(10): if interfaceUtils.getBlock(x, y + y_i, z) == "minecraft:oak_fence": pass else: interfaceUtils.placeBlockBatched(x, y + y_i, z, "air") # build path lamps if i == 0: if (z % 7 == 0): l_x = self._builder._x + self._x + mid_point + l_side[l_switch] for jj in range(6): interfaceUtils.placeBlockBatched(l_x, y+jj, z, "oak_fence") interfaceUtils.placeBlockBatched(x, y+jj, z, "sea_lantern") l_switch = not(l_switch) z += 1