程序包 org.bukkit.generator

# 类 ChunkGenerator

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

public abstract class ChunkGenerator extends Object
用于初始化一个整体的区块的区块生成器。比如说，地狱的区块生成器用于生成地狱岩和灵魂沙. A chunk is generated in multiple steps, those steps are always in the same order. Between those steps however an unlimited time may pass. This means, a chunk may generated until the surface step and continue with the bedrock step after one or multiple server restarts or even after multiple Minecraft versions. The order of generation is as follows

1. `generateNoise(WorldInfo, Random, int, int, ChunkData)`
2. `generateSurface(WorldInfo, Random, int, int, ChunkData)`
3. `generateBedrock(WorldInfo, Random, int, int, ChunkData)`
4. `generateCaves(WorldInfo, Random, int, int, ChunkData)`

Every method listed above as well as `getBaseHeight(WorldInfo, Random, int, int, HeightMap)` must be completely thread safe and able to handle multiple concurrent callers. Some aspects of world generation can be delegated to the Vanilla generator. The following methods can be overridden to enable this:

- `shouldGenerateNoise()` or `shouldGenerateNoise(WorldInfo, Random, int, int)`
- `shouldGenerateSurface()` or `shouldGenerateSurface(WorldInfo, Random, int, int)`
- `shouldGenerateCaves()` or `shouldGenerateCaves(WorldInfo, Random, int, int)`
- `shouldGenerateDecorations()` or `shouldGenerateDecorations(WorldInfo, Random, int, int)`
- `shouldGenerateMobs()` or `shouldGenerateMobs(WorldInfo, Random, int, int)`
- `shouldGenerateStructures()` or `shouldGenerateStructures(WorldInfo, Random, int, int)`

- ## 嵌套类概要

  嵌套类
  修饰符和类型
  类
  说明
  `static interface`
  `ChunkGenerator.BiomeGrid`
  已过时。
  现在使用 `BiomeProvider` 设置生物群系
  `static interface`
  `ChunkGenerator.ChunkData`
  Data for a Chunk.

- ## 构造器概要

  构造器
  构造器
  说明
  `ChunkGenerator()`

- ## 方法概要

  修饰符和类型
  方法
  说明
  `boolean`
  `canSpawn(@NotNull World world, int x, int z)`
  测试指定方位是否对自然生成的方位有效。
  `protected final @NotNull ChunkGenerator.ChunkData`
  `createChunkData(@NotNull World world)`
  已过时。
  `ChunkGenerator.ChunkData` are now directly provided
  `void`
  `generateBedrock(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ, @NotNull ChunkGenerator.ChunkData chunkData)`
  Shapes the Chunk bedrock layer for the given coordinates.
  `void`
  `generateCaves(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ, @NotNull ChunkGenerator.ChunkData chunkData)`
  Shapes the Chunk caves for the given coordinates.
  `@NotNull ChunkGenerator.ChunkData`
  `generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.BiomeGrid biome)`
  已过时。
  The generation is now split up and the new methods should be used, see `ChunkGenerator`
  `void`
  `generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ, @NotNull ChunkGenerator.ChunkData chunkData)`
  Shapes the Chunk noise for the given coordinates.
  `void`
  `generateSurface(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ, @NotNull ChunkGenerator.ChunkData chunkData)`
  Shapes the Chunk surface for the given coordinates.
  `int`
  `getBaseHeight(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull HeightMap heightMap)`
  This method is similar to `World.getHighestBlockAt(int, int, HeightMap)`.
  `@Nullable BiomeProvider`
  `getDefaultBiomeProvider(@NotNull WorldInfo worldInfo)`
  Gets called when no `BiomeProvider` is set in `WorldCreator` or via the server configuration files.
  `@NotNull List<BlockPopulator>`
  `getDefaultPopulators(@NotNull World world)`
  得到一个用于提供指定世界的默认的`BlockPopulator`列表。
  `@Nullable Location`
  `getFixedSpawnLocation(@NotNull World world, @NotNull Random random)`
  获取一个固定出生方位用于一个指定的世界。
  `boolean`
  `isParallelCapable()`
  已过时。
  the chunk generation code should be thread safe
  `boolean`
  `shouldGenerateBedrock()`
  已过时。
  has no effect, bedrock generation is part of the surface step, see `shouldGenerateSurface()`
  `boolean`
  `shouldGenerateCaves()`
  Gets if the server should generate Vanilla caves.
  `boolean`
  `shouldGenerateCaves(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ)`
  Gets if the server should generate Vanilla caves.
  `boolean`
  `shouldGenerateDecorations()`
  Gets if the server should generate Vanilla decorations after this ChunkGenerator.
  `boolean`
  `shouldGenerateDecorations(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ)`
  Gets if the server should generate Vanilla decorations after this ChunkGenerator.
  `boolean`
  `shouldGenerateMobs()`
  Gets if the server should generate Vanilla mobs after this ChunkGenerator.
  `boolean`
  `shouldGenerateMobs(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ)`
  Gets if the server should generate Vanilla mobs after this ChunkGenerator.
  `boolean`
  `shouldGenerateNoise()`
  Gets if the server should generate Vanilla noise.
  `boolean`
  `shouldGenerateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ)`
  Gets if the server should generate Vanilla noise.
  `boolean`
  `shouldGenerateStructures()`
  Gets if the server should generate Vanilla structures after this ChunkGenerator.
  `boolean`
  `shouldGenerateStructures(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ)`
  Gets if the server should generate Vanilla structures after this ChunkGenerator.
  `boolean`
  `shouldGenerateSurface()`
  Gets if the server should generate Vanilla surface.
  `boolean`
  `shouldGenerateSurface(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ)`
  Gets if the server should generate Vanilla surface.

  ### 从类继承的方法 java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 构造器详细资料

  - ### ChunkGenerator

    public ChunkGenerator()

- ## 方法详细资料

  - ### generateNoise

    public void generateNoise(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ, @NotNull @NotNull ChunkGenerator.ChunkData chunkData)
    Shapes the Chunk noise for the given coordinates.

    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 the `ChunkGenerator.ChunkData` at a later point of time.

    The Y-coordinate range should never be hardcoded, to get the Y-coordinate range use the methods `ChunkGenerator.ChunkData.getMinHeight()` and `ChunkGenerator.ChunkData.getMaxHeight()`.

    If `shouldGenerateNoise()` is set to true, the given `ChunkGenerator.ChunkData` contains already the Vanilla noise generation.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
      `chunkData` - To modify

  - ### generateSurface

    public void generateSurface(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ, @NotNull @NotNull ChunkGenerator.ChunkData chunkData)
    Shapes the Chunk surface for the given coordinates.

    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 the `ChunkGenerator.ChunkData` at a later point of time.

    The Y-coordinate range should never be hardcoded, to get the Y-coordinate range use the methods `ChunkGenerator.ChunkData.getMinHeight()` and `ChunkGenerator.ChunkData.getMaxHeight()`.

    If `shouldGenerateSurface()` is set to true, the given `ChunkGenerator.ChunkData` contains already the Vanilla surface generation.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
      `chunkData` - To modify

  - ### generateBedrock

    public void generateBedrock(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ, @NotNull @NotNull ChunkGenerator.ChunkData chunkData)
    Shapes the Chunk bedrock layer for the given coordinates.

    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 the `ChunkGenerator.ChunkData` at a later point of time.

    The Y-coordinate range should never be hardcoded, to get the Y-coordinate range use the methods `ChunkGenerator.ChunkData.getMinHeight()` and `ChunkGenerator.ChunkData.getMaxHeight()`.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
      `chunkData` - To modify

  - ### generateCaves

    public void generateCaves(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ, @NotNull @NotNull ChunkGenerator.ChunkData chunkData)
    Shapes the Chunk caves for the given coordinates.

    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 the `ChunkGenerator.ChunkData` at a later point of time.

    The Y-coordinate range should never be hardcoded, to get the Y-coordinate range use the methods `ChunkGenerator.ChunkData.getMinHeight()` and `ChunkGenerator.ChunkData.getMaxHeight()`.

    If `shouldGenerateCaves()` is set to true, the given `ChunkGenerator.ChunkData` contains already the Vanilla cave generation.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
      `chunkData` - To modify

  - ### getDefaultBiomeProvider

    @Nullable public @Nullable BiomeProvider getDefaultBiomeProvider(@NotNull @NotNull WorldInfo worldInfo)
    Gets called when no `BiomeProvider` is set in `WorldCreator` or via the server configuration files. It is therefore possible that one plugin can provide the Biomes and another one the generation.

    Notes:

    If `null` is returned, than Vanilla biomes are used.

    This method only gets called once when the world is loaded. Returning another `BiomeProvider` later one is not respected.

    参数:
      `worldInfo` - The world info of the world the biome provider will be used for
    返回:
      BiomeProvider to use to fill the biomes of a chunk

  - ### getBaseHeight

    public int getBaseHeight(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int x, int z, @NotNull @NotNull HeightMap heightMap)
    This method is similar to `World.getHighestBlockAt(int, int, HeightMap)`. With the difference being, that the highest y coordinate should be the block before any surface, bedrock, caves or decoration is applied. Or in other words the highest block when only the noise is present at the chunk.

    Notes:

    When this method is not overridden, the Vanilla base height is used.

    This method should never attempt to get the Chunk at the passed coordinates, or use the method `World.getHighestBlockAt(int, int, HeightMap)`, as doing so may cause an infinite loop.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `x` - The X-coordinate from world origin
      `z` - The Z-coordinate from world origin
      `heightMap` - From the highest block should be get
    返回:
      The y coordinate of the highest block at the given location

  - ### generateChunkData

    @NotNull @Deprecated public @NotNull ChunkGenerator.ChunkData generateChunkData(@NotNull @NotNull World world, @NotNull @NotNull Random random, int x, int z, @NotNull @NotNull ChunkGenerator.BiomeGrid biome)
    已过时。
    The generation is now split up and the new methods should be used, see `ChunkGenerator`
    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)`

    参数:
      `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
    返回:
      ChunkData containing the types for each block created by this generator

  - ### createChunkData

    @NotNull @Deprecated protected final @NotNull ChunkGenerator.ChunkData createChunkData(@NotNull @NotNull World world)
    已过时。
    `ChunkGenerator.ChunkData` are now directly provided
    Create a ChunkData for a world.
    参数:
      `world` - the world the ChunkData is for
    返回:
      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

    参数:
      `world` - 用于测试的世界
      `x` - 用于测试的方块的X坐标
      `z` - 用于测试的方块的Z坐标
    返回:
      如果方位有效则返回true，否则返回false

  - ### getDefaultPopulators

    @NotNull public @NotNull List<BlockPopulator> getDefaultPopulators(@NotNull @NotNull World world)
    得到一个用于提供指定世界的默认的`BlockPopulator`列表。

    原文： Gets a list of default `BlockPopulator`s to apply to a given world

    参数:
      `world` - 用于提供的世界
    返回:
      包含所有方块填充器的列表

  - ### 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.

    参数:
      `world` - 用于定位出生点的世界
      `random` - 这个计算器中使用的随机生成器
    返回:
      包含一个新的出生点的方位，若不存在则返回null

  - ### isParallelCapable

    @Deprecated public boolean isParallelCapable()
    已过时。
    the chunk generation code should be thread safe
    Gets if this ChunkGenerator is parallel capable. See `ChunkGenerator` for more information.
    返回:
      parallel capable status

  - ### shouldGenerateNoise

    public boolean shouldGenerateNoise()
    Gets if the server should generate Vanilla noise.

    The Vanilla noise is generated before `generateNoise(WorldInfo, Random, int, int, ChunkData)` is called.

    This is method is not called (and has therefore no effect), if `shouldGenerateNoise(WorldInfo, Random, int, int)` is overridden.

    返回:
      true if the server should generate Vanilla noise
    另请参阅:
      - `shouldGenerateNoise(WorldInfo, Random, int, int)`

  - ### shouldGenerateNoise

    public boolean shouldGenerateNoise(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
    Gets if the server should generate Vanilla noise.

    The Vanilla noise is generated before `generateNoise(WorldInfo, Random, int, int, ChunkData)` is called.

    Only this method is called if both this and `shouldGenerateNoise()` are overridden.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
    返回:
      true if the server should generate Vanilla noise
    另请参阅:
      - `shouldGenerateNoise()`

  - ### shouldGenerateSurface

    public boolean shouldGenerateSurface()
    Gets if the server should generate Vanilla surface.

    The Vanilla surface is generated before `generateSurface(WorldInfo, Random, int, int, ChunkData)` is called.

    This is method is not called (and has therefore no effect), if `shouldGenerateSurface(WorldInfo, Random, int, int)` is overridden.

    返回:
      true if the server should generate Vanilla surface
    另请参阅:
      - `shouldGenerateSurface(WorldInfo, Random, int, int)`

  - ### shouldGenerateSurface

    public boolean shouldGenerateSurface(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
    Gets if the server should generate Vanilla surface.

    The Vanilla surface is generated before `generateSurface(WorldInfo, Random, int, int, ChunkData)` is called.

    Only this method is called if both this and `shouldGenerateSurface()` are overridden.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
    返回:
      true if the server should generate Vanilla surface
    另请参阅:
      - `shouldGenerateSurface()`

  - ### shouldGenerateBedrock

    @Deprecated public boolean shouldGenerateBedrock()
    已过时。
    has no effect, bedrock generation is part of the surface step, see `shouldGenerateSurface()`
    Gets if the server should generate Vanilla bedrock.

    The Vanilla bedrock is generated before `generateBedrock(WorldInfo, Random, int, int, ChunkData)` is called.

    返回:
      true if the server should generate Vanilla bedrock

  - ### shouldGenerateCaves

    public boolean shouldGenerateCaves()
    Gets if the server should generate Vanilla caves.

    The Vanilla caves are generated before `generateCaves(WorldInfo, Random, int, int, ChunkData)` is called.

    This is method is not called (and has therefore no effect), if `shouldGenerateCaves(WorldInfo, Random, int, int)` is overridden.

    返回:
      true if the server should generate Vanilla caves
    另请参阅:
      - `shouldGenerateCaves(WorldInfo, Random, int, int)`

  - ### shouldGenerateCaves

    public boolean shouldGenerateCaves(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
    Gets if the server should generate Vanilla caves.

    The Vanilla caves are generated before `generateCaves(WorldInfo, Random, int, int, ChunkData)` is called.

    Only this method is called if both this and `shouldGenerateCaves()` are overridden.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
    返回:
      true if the server should generate Vanilla caves
    另请参阅:
      - `shouldGenerateCaves()`

  - ### shouldGenerateDecorations

    public boolean shouldGenerateDecorations()
    Gets if the server should generate Vanilla decorations after this ChunkGenerator.

    The Vanilla decoration are generated before any `BlockPopulator` are called.

    This is method is not called (and has therefore no effect), if `shouldGenerateDecorations(WorldInfo, Random, int, int)` is overridden.

    返回:
      true if the server should generate Vanilla decorations
    另请参阅:
      - `shouldGenerateDecorations(WorldInfo, Random, int, int)`

  - ### shouldGenerateDecorations

    public boolean shouldGenerateDecorations(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
    Gets if the server should generate Vanilla decorations after this ChunkGenerator.

    The Vanilla decoration are generated before any `BlockPopulator` are called.

    Only this method is called if both this and `shouldGenerateDecorations()` are overridden.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
    返回:
      true if the server should generate Vanilla decorations
    另请参阅:
      - `shouldGenerateDecorations()`

  - ### shouldGenerateMobs

    public boolean shouldGenerateMobs()
    Gets if the server should generate Vanilla mobs after this ChunkGenerator.

    This is method is not called (and has therefore no effect), if `shouldGenerateMobs(WorldInfo, Random, int, int)` is overridden.

    返回:
      true if the server should generate Vanilla mobs
    另请参阅:
      - `shouldGenerateMobs(WorldInfo, Random, int, int)`

  - ### shouldGenerateMobs

    public boolean shouldGenerateMobs(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
    Gets if the server should generate Vanilla mobs after this ChunkGenerator.

    Only this method is called if both this and `shouldGenerateMobs()` are overridden.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
    返回:
      true if the server should generate Vanilla mobs
    另请参阅:
      - `shouldGenerateMobs()`

  - ### shouldGenerateStructures

    public boolean shouldGenerateStructures()
    Gets if the server should generate Vanilla structures after this ChunkGenerator.

    This is method is not called (and has therefore no effect), if `shouldGenerateStructures(WorldInfo, Random, int, int)` is overridden.

    返回:
      true if the server should generate Vanilla structures
    另请参阅:
      - `shouldGenerateStructures(WorldInfo, Random, int, int)`

  - ### shouldGenerateStructures

    public boolean shouldGenerateStructures(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
    Gets if the server should generate Vanilla structures after this ChunkGenerator.

    Only this method is called if both this and `shouldGenerateStructures()` are overridden.

    参数:
      `worldInfo` - The world info of the world this chunk will be used for
      `random` - The random generator to use
      `chunkX` - The X-coordinate of the chunk
      `chunkZ` - The Z-coordinate of the chunk
    返回:
      true if the server should generate Vanilla structures
    另请参阅:
      - `shouldGenerateStructures()`