org.bukkit.generator.ChunkGenerator Java Examples
The following examples show how to use
org.bukkit.generator.ChunkGenerator.
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: WorldManager.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
/** * Gets the skyblock nether island {@link World}. Creates and/or imports the world if necessary. Returns null if * the nether is not enabled in the plugin configuration. * @return Skyblock nether island world, or null if nether is disabled. */ @Nullable public synchronized World getNetherWorld() { if (skyBlockNetherWorld == null && Settings.nether_enabled) { skyBlockNetherWorld = Bukkit.getWorld(Settings.general_worldName + "_nether"); ChunkGenerator skyGenerator = getNetherGenerator(); ChunkGenerator worldGenerator = skyBlockNetherWorld != null ? skyBlockNetherWorld.getGenerator() : null; if (skyBlockNetherWorld == null || skyBlockNetherWorld.canGenerateStructures() || worldGenerator == null || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) { skyBlockNetherWorld = WorldCreator .name(Settings.general_worldName + "_nether") .type(WorldType.NORMAL) .generateStructures(false) .environment(World.Environment.NETHER) .generator(skyGenerator) .createWorld(); skyBlockNetherWorld.save(); } MultiverseCoreHandler.importNetherWorld(skyBlockNetherWorld); setupWorld(skyBlockNetherWorld, island_height / 2); MultiverseInventoriesHandler.linkWorlds(getWorld(), skyBlockNetherWorld); } return skyBlockNetherWorld; }
Example #2
Source File: WorldManager.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
/** * Gets the skyblock island {@link World}. Creates and/or imports the world if necessary. * @return Skyblock island world. */ @NotNull public synchronized World getWorld() { if (skyBlockWorld == null) { skyBlockWorld = Bukkit.getWorld(Settings.general_worldName); ChunkGenerator skyGenerator = getOverworldGenerator(); ChunkGenerator worldGenerator = skyBlockWorld != null ? skyBlockWorld.getGenerator() : null; if (skyBlockWorld == null || skyBlockWorld.canGenerateStructures() || worldGenerator == null || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) { skyBlockWorld = WorldCreator .name(Settings.general_worldName) .type(WorldType.NORMAL) .generateStructures(false) .environment(World.Environment.NORMAL) .generator(skyGenerator) .createWorld(); skyBlockWorld.save(); } MultiverseCoreHandler.importWorld(skyBlockWorld); setupWorld(skyBlockWorld, island_height); } return skyBlockWorld; }
Example #3
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 5 votes |
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) { this.world = world; this.generator = gen; environment = env; if (server.chunkGCPeriod > 0) { chunkGCTickCount = rand.nextInt(server.chunkGCPeriod); } }
Example #4
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ChunkGenerator getChunkGenerator() { return new ChunkGenerator() { @Override public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) { final ChunkGenerator.ChunkData chunkData = this.createChunkData(world); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { chunkGererator.setBiome(i, j, Biome.VOID); } } return chunkData; } }; }
Example #5
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ChunkGenerator getChunkGenerator() { return new ChunkGenerator() { @Override public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) { final ChunkGenerator.ChunkData chunkData = this.createChunkData(world); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { chunkGererator.setBiome(i, j, Biome.VOID); } } return chunkData; } }; }
Example #6
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ChunkGenerator getChunkGenerator() { return new ChunkGenerator() { @Override public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) { final ChunkGenerator.ChunkData chunkData = this.createChunkData(world); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { chunkGererator.setBiome(i, j, Biome.THE_VOID); } } return chunkData; } }; }
Example #7
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ChunkGenerator getChunkGenerator() { return new ChunkGenerator() { @Override public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) { final ChunkGenerator.ChunkData chunkData = this.createChunkData(world); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { chunkGererator.setBiome(i, j, Biome.VOID); } } return chunkData; } }; }
Example #8
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 5 votes |
public ChunkGenerator getGenerator(String world) { ConfigurationSection section = configuration.getConfigurationSection("worlds"); ChunkGenerator result = null; if (section != null) { section = section.getConfigurationSection(world); if (section != null) { String name = section.getString("generator"); if ((name != null) && (!name.equals(""))) { String[] split = name.split(":", 2); String id = (split.length > 1) ? split[1] : null; Plugin plugin = pluginManager.getPlugin(split[0]); if (plugin == null) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + split[0] + "' does not exist"); } else if (!plugin.isEnabled()) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled yet (is it load:STARTUP?)"); } else { try { result = plugin.getDefaultWorldGenerator(world, id); if (result == null) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' lacks a default world generator"); } } catch (Throwable t) { plugin.getLogger().log(Level.SEVERE, "Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName(), t); } } } } } return result; }
Example #9
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ChunkGenerator getChunkGenerator() { return new ChunkGenerator() { @Override public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) { final ChunkGenerator.ChunkData chunkData = this.createChunkData(world); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { chunkGererator.setBiome(i, j, Biome.VOID); } } return chunkData; } }; }
Example #10
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ChunkGenerator getChunkGenerator() { return new ChunkGenerator() { @Override public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) { final ChunkGenerator.ChunkData chunkData = this.createChunkData(world); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { chunkGererator.setBiome(i, j, Biome.VOID); } } return chunkData; } }; }
Example #11
Source File: WorldManager.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
/** * Gets the {@link ChunkGenerator} responsible for generating chunks in the overworld skyworld. * @return ChunkGenerator for overworld skyworld. */ @NotNull private ChunkGenerator getOverworldGenerator() { try { String clazz = plugin.getConfig().getString("options.advanced.chunk-generator", "us.talabrek.ultimateskyblock.world.SkyBlockChunkGenerator"); Object generator = Class.forName(clazz).newInstance(); if (generator instanceof ChunkGenerator) { return (ChunkGenerator) generator; } } catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) { logger.log(Level.WARNING, "Invalid overworld chunk-generator configured: " + ex); } return new SkyBlockChunkGenerator(); }
Example #12
Source File: WorldManager.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
/** * Gets the {@link ChunkGenerator} responsible for generating chunks in the nether skyworld. * @return ChunkGenerator for nether skyworld. */ @NotNull private ChunkGenerator getNetherGenerator() { try { String clazz = plugin.getConfig().getString("nether.chunk-generator", "us.talabrek.ultimateskyblock.world.SkyBlockNetherChunkGenerator"); Object generator = Class.forName(clazz).newInstance(); if (generator instanceof ChunkGenerator) { return (ChunkGenerator) generator; } } catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) { logger.log(Level.WARNING, "Invalid nether chunk-generator configured: " + ex); } return new SkyBlockNetherChunkGenerator(); }
Example #13
Source File: WorldManager.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
/** * Gets a {@link ChunkGenerator} for use in a default world, as specified in the server configuration * @param worldName Name of the world that this will be applied to * @param id Unique ID, if any, that was specified to indicate which generator was requested * @return ChunkGenerator for use in the default world generation */ @Nullable public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) { Validate.notNull(worldName, "WorldName cannot be null"); return ((id != null && id.endsWith("nether")) || (worldName.endsWith("nether"))) && Settings.nether_enabled ? getNetherGenerator() : getOverworldGenerator(); }
Example #14
Source File: WorldCreator.java From Kettle with GNU General Public License v3.0 | 5 votes |
/** * Attempts to get the {@link ChunkGenerator} with the given name. * <p> * If the generator is not found, null will be returned and a message will * be printed to the specified {@link CommandSender} explaining why. * <p> * The name must be in the "plugin:id" notation, or optionally just * "plugin", where "plugin" is the safe-name of a plugin and "id" is an * optional unique identifier for the generator you wish to request from * the plugin. * * @param world Name of the world this will be used for * @param name Name of the generator to retrieve * @param output Where to output if errors are present * @return Resulting generator, or null */ public static ChunkGenerator getGeneratorForName(String world, String name, CommandSender output) { ChunkGenerator result = null; if (world == null) { throw new IllegalArgumentException("World name must be specified"); } if (output == null) { output = Bukkit.getConsoleSender(); } if (name != null) { String[] split = name.split(":", 2); String id = (split.length > 1) ? split[1] : null; Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]); if (plugin == null) { output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + split[0] + "' does not exist"); } else if (!plugin.isEnabled()) { output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled"); } else { result = plugin.getDefaultWorldGenerator(world, id); } } return result; }
Example #15
Source File: CraftWorld.java From Thermos with GNU General Public License v3.0 | 5 votes |
public CraftWorld(net.minecraft.world.WorldServer world, ChunkGenerator gen, Environment env) { this.world = world; this.generator = gen; environment = env; if (server.chunkGCPeriod > 0) { chunkGCTickCount = rand.nextInt(server.chunkGCPeriod); } }
Example #16
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 5 votes |
public ChunkGenerator getGenerator(String world) { ConfigurationSection section = configuration.getConfigurationSection("worlds"); ChunkGenerator result = null; if (section != null) { section = section.getConfigurationSection(world); if (section != null) { String name = section.getString("generator"); if ((name != null) && (!name.equals(""))) { String[] split = name.split(":", 2); String id = (split.length > 1) ? split[1] : null; Plugin plugin = pluginManager.getPlugin(split[0]); if (plugin == null) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + split[0] + "' does not exist"); } else if (!plugin.isEnabled()) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled yet (is it load:STARTUP?)"); } else { try { result = plugin.getDefaultWorldGenerator(world, id); if (result == null) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' lacks a default world generator"); } } catch (Throwable t) { plugin.getLogger().log(Level.SEVERE, "Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName(), t); } } } } } return result; }
Example #17
Source File: AsyncWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public ChunkGenerator getGenerator() { return parent.getGenerator(); }
Example #18
Source File: BukkitQueue_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { if (biome != null) { try { if (seed == null) { seed = world.getSeed(); } nmsWorld.worldData.getSeed(); boolean result; ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, ""); Biome bukkitBiome = getAdapter().getBiome(biome.getId()); BiomeBase base = BiomeBase.getBiome(biome.getId()); fieldBiomes.set(generator, new BiomeBase[]{base}); boolean cold = base.getTemperature() <= 1; net.minecraft.server.v1_12_R1.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator; long existingSeed = world.getSeed(); { if (genLayer == null) genLayer = new MutableGenLayer(seed); genLayer.set(biome.getId()); Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager()); Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager()); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer); fieldSeed.set(nmsWorld.worldData, seed); ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager())); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator); keepLoaded.remove(MathMan.pairInt(x, z)); result = getWorld().regenerateChunk(x, z); net.minecraft.server.v1_12_R1.Chunk nmsChunk = getCachedChunk(world, x, z); if (nmsChunk != null) { nmsChunk.f(true); // Set Modified nmsChunk.mustSave = true; } ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator); fieldSeed.set(nmsWorld.worldData, existingSeed); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2); } return result; } catch (Throwable e) { e.printStackTrace(); } } return super.regenerateChunk(world, x, z, biome, seed); }
Example #19
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 4 votes |
@Override public World createWorld(WorldCreator creator) { Validate.notNull(creator, "Creator may not be null"); String name = creator.name(); ChunkGenerator generator = creator.generator(); File folder = new File(getWorldContainer(), name); World world = getWorld(name); net.minecraft.world.WorldType type = net.minecraft.world.WorldType.parseWorldType(creator.type().getName()); boolean generateStructures = creator.generateStructures(); if ((folder.exists()) && (!folder.isDirectory())) { throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder"); } if (world != null) { return world; } boolean hardcore = false; WorldSettings worldSettings = new WorldSettings(creator.seed(), net.minecraft.world.WorldSettings.GameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type); net.minecraft.world.WorldServer worldserver = DimensionManager.initDimension(creator, worldSettings); pluginManager.callEvent(new WorldInitEvent(worldserver.getWorld())); net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = true; System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Dimension: " + worldserver.provider.dimensionId + ", Seed: " + worldserver.getSeed() + ")"); // Cauldron - log dimension if (worldserver.getWorld().getKeepSpawnInMemory()) { short short1 = 196; long i = System.currentTimeMillis(); for (int j = -short1; j <= short1; j += 16) { for (int k = -short1; k <= short1; k += 16) { long l = System.currentTimeMillis(); if (l < i) { i = l; } if (l > i + 1000L) { int i1 = (short1 * 2 + 1) * (short1 * 2 + 1); int j1 = (j + short1) * (short1 * 2 + 1) + k + 1; System.out.println("Preparing spawn area for " + worldserver.getWorld().getName() + ", " + (j1 * 100 / i1) + "%"); i = l; } net.minecraft.util.ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint(); worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4); } } } pluginManager.callEvent(new WorldLoadEvent(worldserver.getWorld())); net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = false; return worldserver.getWorld(); }
Example #20
Source File: BukkitQueue_1_10.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { if (biome != null) { try { if (seed == null) { seed = world.getSeed(); } nmsWorld.worldData.getSeed(); boolean result; ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, ""); Biome bukkitBiome = getAdapter().getBiome(biome.getId()); BiomeBase base = BiomeBase.getBiome(biome.getId()); fieldBiomes.set(generator, new BiomeBase[]{base}); boolean cold = base.getTemperature() <= 1; net.minecraft.server.v1_10_R1.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator; long existingSeed = world.getSeed(); { if (genLayer == null) genLayer = new MutableGenLayer(seed); genLayer.set(biome.getId()); Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager()); Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager()); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer); fieldSeed.set(nmsWorld.worldData, seed); ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager())); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator); keepLoaded.remove(MathMan.pairInt(x, z)); result = getWorld().regenerateChunk(x, z); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator); fieldSeed.set(nmsWorld.worldData, existingSeed); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2); } return result; } catch (Throwable e) { e.printStackTrace(); } } return super.regenerateChunk(world, x, z, biome, seed); }
Example #21
Source File: CraftWorld.java From Thermos with GNU General Public License v3.0 | 4 votes |
public void setGenerator(ChunkGenerator generator) { if (this.generator == null) { this.generator = generator; } }
Example #22
Source File: BukkitQueue_1_9_R1.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { if (biome != null) { try { if (seed == null) { seed = world.getSeed(); } nmsWorld.worldData.getSeed(); boolean result; net.minecraft.server.v1_9_R2.ChunkProviderGenerate generator = new net.minecraft.server.v1_9_R2.ChunkProviderGenerate(nmsWorld, seed, false, ""); Biome bukkitBiome = getAdapter().getBiome(biome.getId()); net.minecraft.server.v1_9_R2.BiomeBase base = net.minecraft.server.v1_9_R2.BiomeBase.getBiome(biome.getId()); fieldBiomes.set(generator, new net.minecraft.server.v1_9_R2.BiomeBase[]{base}); net.minecraft.server.v1_9_R2.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator; long existingSeed = world.getSeed(); { if (genLayer == null) genLayer = new MutableGenLayer(seed); genLayer.set(biome.getId()); Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager()); Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager()); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer); fieldSeed.set(nmsWorld.worldData, seed); ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new net.minecraft.server.v1_9_R2.BiomeCache(this.nmsWorld.getWorldChunkManager())); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator); keepLoaded.remove(MathMan.pairInt(x, z)); result = getWorld().regenerateChunk(x, z); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator); fieldSeed.set(nmsWorld.worldData, existingSeed); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2); } return result; } catch (Throwable e) { e.printStackTrace(); } } return super.regenerateChunk(world, x, z, biome, seed); }
Example #23
Source File: BukkitQueue_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { if (biome != null) { try { if (seed == null) { seed = world.getSeed(); } nmsWorld.worldData.getSeed(); boolean result; ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, ""); Biome bukkitBiome = getAdapter().getBiome(biome.getId()); BiomeBase base = BiomeBase.getBiome(biome.getId()); fieldBiomes.set(generator, new BiomeBase[]{base}); boolean cold = base.getTemperature() <= 1; net.minecraft.server.v1_11_R1.ChunkGenerator existingGenerator = nmsWorld.getChunkProviderServer().chunkGenerator; long existingSeed = world.getSeed(); { if (genLayer == null) genLayer = new MutableGenLayer(seed); genLayer.set(biome.getId()); Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager()); Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager()); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer); fieldSeed.set(nmsWorld.worldData, seed); ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager())); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), generator); keepLoaded.remove(MathMan.pairInt(x, z)); result = getWorld().regenerateChunk(x, z); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProviderServer(), existingGenerator); fieldSeed.set(nmsWorld.worldData, existingSeed); fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1); fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2); } return result; } catch (Throwable e) { e.printStackTrace(); } } return super.regenerateChunk(world, x, z, biome, seed); }
Example #24
Source File: uSkyBlock.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
@Override public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) { return getWorldManager().getDefaultWorldGenerator(worldName, id); }
Example #25
Source File: Spigot_v1_13_R2_2.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean regenerate(org.bukkit.World bukkitWorld, Region region, EditSession editSession) { WorldServer originalWorld = ((CraftWorld) bukkitWorld).getHandle(); File saveFolder = Files.createTempDir(); // register this just in case something goes wrong // normally it should be deleted at the end of this method saveFolder.deleteOnExit(); saveFolder.deleteOnExit(); try { Environment env = bukkitWorld.getEnvironment(); ChunkGenerator gen = bukkitWorld.getGenerator(); MinecraftServer server = originalWorld.getServer().getServer(); WorldData newWorldData = new WorldData(originalWorld.worldData.a((NBTTagCompound) null), server.dataConverterManager, getDataVersion(), null); newWorldData.checkName("worldeditregentempworld"); WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalWorld.getDataManager().getDirectory().getName(), server, server.dataConverterManager); try (WorldServer freshWorld = new WorldServer(server, saveHandler, new PersistentCollection(saveHandler), newWorldData, originalWorld.worldProvider.getDimensionManager(), originalWorld.methodProfiler, env, gen)) { freshWorld.savingDisabled = true; // Pre-gen all the chunks // We need to also pull one more chunk in every direction CuboidRegion expandedPreGen = new CuboidRegion(region.getMinimumPoint().subtract(16, 0, 16), region.getMaximumPoint().add(16, 0, 16)); for (BlockVector2 chunk : expandedPreGen.getChunks()) { freshWorld.getChunkAt(chunk.getBlockX(), chunk.getBlockZ()); } CraftWorld craftWorld = freshWorld.getWorld(); BukkitWorld from = new BukkitWorld(craftWorld); for (BlockVector3 vec : region) { editSession.setBlock(vec, from.getFullBlock(vec)); } } } catch (MaxChangedBlocksException e) { throw new RuntimeException(e); } finally { saveFolder.delete(); try { Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) serverWorldsField.get(Bukkit.getServer()); map.remove("worldeditregentempworld"); } catch (IllegalAccessException ignored) { } } return true; }
Example #26
Source File: ASkyBlock.java From askyblock with GNU General Public License v2.0 | 4 votes |
@Override public ChunkGenerator getDefaultWorldGenerator(final String worldName, final String id) { return new ChunkGeneratorWorld(); }
Example #27
Source File: LukkitPlugin.java From Lukkit with MIT License | 4 votes |
@Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { return Main.instance.getDefaultWorldGenerator(worldName, id); }
Example #28
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public ChunkGenerator.ChunkData createChunkData(World world) { return new CraftChunkData(world); }
Example #29
Source File: JavaPlugin.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { return null; }
Example #30
Source File: CustomChunkGenerator.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CustomChunkGenerator(World world, long seed, ChunkGenerator generator) { this.world = (WorldServer) world; this.generator = generator; this.random = new Random(seed); }