Class ChunkGenerator

java.lang.Object
org.bukkit.generator.ChunkGenerator

public abstract class ChunkGenerator extends Object
A chunk generator is responsible for the initial shaping of an entire chunk. For example, the nether chunk generator should shape netherrack and soulsand. By default only one thread will call generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid) at a time, although this may not necessarily be the main server thread. If your generator is capable of fully asynchronous generation, then isParallelCapable() should be overridden accordingly to allow multiple concurrent callers. Some aspects of world generation can be delegated to the Vanilla generator. The methods shouldGenerateCaves(), shouldGenerateDecorations(), shouldGenerateMobs() and shouldGenerateStructures() can be overridden to enable this.
  • Constructor Details

    • ChunkGenerator

      public ChunkGenerator()
  • Method Details

    • generateChunkData

      @NotNull public @NotNull ChunkGenerator.ChunkData generateChunkData(@NotNull @NotNull World world, @NotNull @NotNull Random random, int x, int z, @NotNull @NotNull ChunkGenerator.BiomeGrid biome)
      Shapes the chunk for the given coordinates. This method must return a ChunkData.

      Notes:

      This method should never attempt to get the Chunk at the passed coordinates, as doing so may cause an infinite loop

      This method should never modify a ChunkData after it has been returned.

      This method must return a ChunkData returned by createChunkData(org.bukkit.World)

      Parameters:
      world - The world this chunk will be used for
      random - The random generator to use
      x - The X-coordinate of the chunk
      z - The Z-coordinate of the chunk
      biome - Proposed biome values for chunk - can be updated by generator
      Returns:
      ChunkData containing the types for each block created by this generator
    • createChunkData

      @NotNull protected final @NotNull ChunkGenerator.ChunkData createChunkData(@NotNull @NotNull World world)
      Create a ChunkData for a world.
      Parameters:
      world - the world the ChunkData is for
      Returns:
      a new ChunkData for world
    • canSpawn

      public boolean canSpawn(@NotNull @NotNull World world, int x, int z)
      Tests if the specified location is valid for a natural spawn position
      Parameters:
      world - The world we're testing on
      x - X-coordinate of the block to test
      z - Z-coordinate of the block to test
      Returns:
      true if the location is valid, otherwise false
    • getDefaultPopulators

      @NotNull public @NotNull List<BlockPopulator> getDefaultPopulators(@NotNull @NotNull World world)
      Gets a list of default BlockPopulators to apply to a given world
      Parameters:
      world - World to apply to
      Returns:
      List containing any amount of BlockPopulators
    • generateDecorations

      public void generateDecorations(@NotNull ProtoWorld world)
      Generate decorations in a chunk, with quick access to its neighbors.
      Parameters:
      world - ProtoWorld to generate decorations with.
    • getFixedSpawnLocation

      @Nullable public @Nullable Location getFixedSpawnLocation(@NotNull @NotNull World world, @NotNull @NotNull Random random)
      Gets a fixed spawn location to use for a given world.

      A null value is returned if a world should not use a fixed spawn point, and will instead attempt to find one randomly.

      Parameters:
      world - The world to locate a spawn point for
      random - Random generator to use in the calculation
      Returns:
      Location containing a new spawn point, otherwise null
    • isParallelCapable

      public boolean isParallelCapable()
      Gets if this ChunkGenerator is parallel capable. See ChunkGenerator for more information.
      Returns:
      parallel capable status
    • shouldGenerateCaves

      public boolean shouldGenerateCaves()
      Gets if the server should generate Vanilla caves after this ChunkGenerator.
      Returns:
      true if the server should generate Vanilla caves
    • shouldGenerateDecorations

      public boolean shouldGenerateDecorations()
      Gets if the server should generate Vanilla decorations after this ChunkGenerator.
      Returns:
      true if the server should generate Vanilla decorations
    • shouldGenerateMobs

      public boolean shouldGenerateMobs()
      Gets if the server should generate Vanilla mobs after this ChunkGenerator.
      Returns:
      true if the server should generate Vanilla mobs
    • shouldGenerateStructures

      public boolean shouldGenerateStructures()
      Gets if the server should generate Vanilla structures after this ChunkGenerator.
      Returns:
      true if the server should generate Vanilla structures
    • createVanillaChunkData

      @NotNull public @NotNull ChunkGenerator.ChunkData createVanillaChunkData(@NotNull @NotNull World world, int x, int z)
      Create a ChunkData for use in a generator, that is populated by the vanilla generator for that world
      Parameters:
      world - the world to create the ChunkData for
      x - the x coordinate of the chunk
      z - the z coordinate of the chunk
      Returns:
      a new ChunkData for the world