Java Code Examples for com.sk89q.worldedit.regions.Region#getChunks()
The following examples show how to use
com.sk89q.worldedit.regions.Region#getChunks() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Spigot_v1_16_R1.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 6 votes |
private List<CompletableFuture<IChunkAccess>> submitChunkLoadTasks(Region region, WorldServer serverWorld) { ChunkProviderServer chunkManager = serverWorld.getChunkProvider(); List<CompletableFuture<IChunkAccess>> chunkLoadings = new ArrayList<>(); // Pre-gen all the chunks for (BlockVector2 chunk : region.getChunks()) { try { //noinspection unchecked chunkLoadings.add( ((CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>>) getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) .thenApply(either -> either.left().orElse(null)) ); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Couldn't load chunk for regen.", e); } } return chunkLoadings; }
Example 2
Source File: Extent.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
default public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException { PseudoRandom random = new PseudoRandom(); for (Vector2D chunkPos : region.getChunks()) { for (int i = 0; i < frequency; i++) { if (random.nextInt(100) > rarity) { continue; } int x = (chunkPos.getBlockX() << 4) + random.nextInt(16); int z = (chunkPos.getBlockZ() << 4) + random.nextInt(16); gen.spawn(random, x, z); } } }
Example 3
Source File: WorldEditHandler.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public static void loadRegion(Location location) { ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(location); World world = location.getWorld(); Region cube = getRegion(world, region); for (BlockVector2 chunk : cube.getChunks()) { world.unloadChunk(chunk.getBlockX(), chunk.getBlockZ(), true); world.loadChunk(chunk.getBlockX(), chunk.getBlockZ(), false); } }
Example 4
Source File: WorldEditHandler.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public static void unloadRegion(Location location) { ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(location); World world = location.getWorld(); Region cube = getRegion(world, region); for (BlockVector2 chunk : cube.getChunks()) { world.unloadChunk(chunk.getBlockX(), chunk.getBlockZ(), true); } }
Example 5
Source File: WorldEditHandler.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public static void refreshRegion(Location location) { ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(location); World world = location.getWorld(); Region cube = getRegion(world, region); for (BlockVector2 chunk : cube.getChunks()) { world.refreshChunk(chunk.getBlockX(), chunk.getBlockZ()); } }
Example 6
Source File: Extent.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public default void generate(Region region, GenBase gen) throws WorldEditException { for (Vector2D chunkPos : region.getChunks()) { gen.generate(chunkPos, this); } }