本文整理汇总了Java中org.bukkit.generator.ChunkGenerator类的典型用法代码示例。如果您正苦于以下问题:Java ChunkGenerator类的具体用法?Java ChunkGenerator怎么用?Java ChunkGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChunkGenerator类属于org.bukkit.generator包,在下文中一共展示了ChunkGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateChunkData
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid biomeGrid) {
if (world.getEnvironment().equals(World.Environment.NETHER)) {
return generateNetherChunks(world, random, chunkX, chunkZ, biomeGrid);
}
ChunkData result = createChunkData(world);
if (Settings.seaHeight != 0) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < Settings.seaHeight; y++) {
result.setBlock(x, y, z, Material.STATIONARY_WATER);
}
}
}
}
return result;
}
示例2: generate
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
public void generate(byte[][] chunk, World world, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid grid) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
int realX = x + chunkX * 16;
int realZ = z + chunkZ * 16;
grid.setBiome(x, z, null);
// Generate basic terrain
double height = baseHeight + generateSea(realX, realZ, grid) + generateHugeMountain(realX, realZ) + terrainAmplitude1 * terrainGenerator1.noise(realX * terrainFreq1, realZ * terrainFreq1) + terrainAmplitude2 * terrainGenerator2.noise(realX * terrainFreq2, realZ * terrainFreq2);
double humidity = 50D + 50D * humidityGenerator.noise(realX * humidityFreq, realZ * humidityFreq);
double temperature = 8D + 24D * temperatureGenerator.noise(realX * temperatureFreq, realZ * temperatureFreq);
if (height > baseHeight)
grid.setBiome(x, z, null);
for (int y = 1; y < 256; y++) {
if (grid.getBiome(x, z) != null) {
if (y < height) setBlock(x, y, z, chunk, Material.STONE);
else if (y < baseHeight) setBlock(x, y, z, chunk, Material.WATER);
else setBlock(x, y, z, chunk, Material.AIR);
} else if (y <= height) setBlock(x, y, z, chunk, Material.STONE);
}
}
}
}
示例3: generateSea
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
private double generateSea(int x, int z, ChunkGenerator.BiomeGrid grid) {
double height = seaAmplitude * seaGenerator.noise(x * seaFreq, z * seaFreq);
if (height < -0.05) {
grid.setBiome((x % 16 + 16) % 16, (z % 16 + 16) % 16, Biome.OCEAN);
if (height < -0.2) grid.setBiome((x % 16 + 16) % 16, (z % 16 + 16) % 16, Biome.DEEP_OCEAN);
}
return height > 0 ? 0 : height;
}
示例4: WorldCreatorData
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
public WorldCreatorData(
Optional<String> name,
@Nullable Dimension dimension,
Optional<Long> seed,
@Nullable WorldType type,
Optional<ChunkGenerator> generator,
@Nullable String generatorSettings,
@Nullable Boolean structures
) {
if (name == null) {
throw new IllegalArgumentException("The name of a creator cannot be null!");
}
this.name = name;
this.dimension = Optional.ofNullable(dimension).orElse(Dimension.NORMAL);
this.type = Optional.ofNullable(type).orElse(WorldType.NORMAL);
this.seed = seed;
this.generator = generator;
this.generatorSettings = Optional.ofNullable(generatorSettings).orElse("");
this.structures = Optional.ofNullable(structures).orElse(true);
}
示例5: getDefaultWorldGenerator
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
@Override
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
WorldEvents.lastWorld = world;
if (!PlotSquared.setupPlotWorld(world, id)) {
return null;
}
HybridGen result = new HybridGen(world);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
if (WorldEvents.lastWorld != null && WorldEvents.lastWorld.equals(world)) {
WorldEvents.lastWorld = null;
}
}
}, 20);
return result;
}
示例6: updateGenerators
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
@Override
public void updateGenerators() {
if (SetupUtils.generators.size() > 0) {
return;
}
final String testWorld = "CheckingPlotSquaredGenerator";
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (plugin.isEnabled()) {
final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
if (generator != null) {
PlotSquared.removePlotWorld(testWorld);
final String name = plugin.getDescription().getName();
// final PlotGenerator pgen = (PlotGenerator) generator;
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
SetupUtils.generators.put(name, generator);
// }
// }
}
}
}
}
示例7: getWorld
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
public World getWorld() {
if (uSkyBlock.skyBlockWorld == null) {
skyBlockWorld = Bukkit.getWorld(Settings.general_worldName);
ChunkGenerator skyGenerator = getGenerator();
ChunkGenerator worldGenerator = skyBlockWorld != null ? skyBlockWorld.getGenerator() : null;
if (skyBlockWorld == null || skyBlockWorld.canGenerateStructures() ||
worldGenerator == null || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName()))
{
uSkyBlock.skyBlockWorld = WorldCreator
.name(Settings.general_worldName)
.type(WorldType.NORMAL)
.generateStructures(false)
.environment(World.Environment.NORMAL)
.generator(skyGenerator)
.createWorld();
uSkyBlock.skyBlockWorld.save();
}
MultiverseCoreHandler.importWorld(skyBlockWorld);
setupWorld(skyBlockWorld, island_height);
}
return uSkyBlock.skyBlockWorld;
}
示例8: getSkyBlockNetherWorld
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
public World getSkyBlockNetherWorld() {
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())) {
uSkyBlock.skyBlockNetherWorld = WorldCreator
.name(Settings.general_worldName + "_nether")
.type(WorldType.NORMAL)
.generateStructures(false)
.environment(World.Environment.NETHER)
.generator(skyGenerator)
.createWorld();
uSkyBlock.skyBlockNetherWorld.save();
}
MultiverseCoreHandler.importNetherWorld(skyBlockNetherWorld);
setupWorld(skyBlockNetherWorld, island_height / 2);
MultiverseInventoriesHandler.linkWorlds(getWorld(), skyBlockNetherWorld);
}
return skyBlockNetherWorld;
}
示例9: getGenerator
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
@Override
public String getGenerator(PlotArea plotArea) {
if (SetupUtils.generators.isEmpty()) {
updateGenerators();
}
World world = Bukkit.getWorld(plotArea.worldname);
if (world == null) {
return null;
}
ChunkGenerator generator = world.getGenerator();
if (!(generator instanceof BukkitPlotGenerator)) {
return null;
}
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
GeneratorWrapper<?> current = entry.getValue();
if (current.equals(generator)) {
return entry.getKey();
}
}
return null;
}
示例10: onWorldInit
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
World world = event.getWorld();
String name = world.getName();
PlotAreaManager manager = PS.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) {
SinglePlotAreaManager single = (SinglePlotAreaManager) manager;
if (single.isWorld(name)) {
world.setKeepSpawnInMemory(false);
return;
}
}
ChunkGenerator gen = world.getGenerator();
if (gen instanceof GeneratorWrapper) {
PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
} else {
PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
}
}
示例11: getGenerator
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
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;
}
示例12: getGeneratorForName
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
/**
* 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;
}
示例13: CraftWorld
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
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);
}
}
示例14: CraftWorld
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
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);
}
}
示例15: displayGenerators
import org.bukkit.generator.ChunkGenerator; //导入依赖的package包/类
public void displayGenerators(PlotPlayer plr) {
StringBuffer message = new StringBuffer();
message.append("&6你想要生成什么类型地皮?");
for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) {
if (entry.getKey().equals("PlotSquared")) {
message.append("\n&8 - &2" + entry.getKey() + " (默认生成参数)");
}
else if (entry.getValue() instanceof HybridGen) {
message.append("\n&8 - &7" + entry.getKey() + " (混合生成参数)");
}
else if (entry.getValue() instanceof PlotGenerator) {
message.append("\n&8 - &7" + entry.getKey() + " (高级地皮生成参数)");
}
else {
message.append("\n&8 - &7" + entry.getKey() + " (其他生成参数)");
}
}
MainUtil.sendMessage(plr, message.toString());
}