类 ChunkGenerator

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

public abstract class ChunkGenerator extends Object
用于初始化一个整体的区块的区块生成器。比如说,地狱的区块生成器用于生成地狱岩和灵魂沙。 区块的生成分为多个步骤,这些步骤始终按照相同的顺序执行。 然而,在这些步骤之间可能会经过无限长的时间。这意味着,一个区块可能在表面步骤生成后, 经过一次或多次服务器重启,甚至经过多个 Minecraft 版本后才继续执行基岩步骤。 生成顺序如下:
  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)
上述列出的每个方法以及 getBaseHeight(WorldInfo, Random, int, int, HeightMap) 必须完全线程安全,并且能够处理多个并发调用者。 世界生成的某些方面可以委托给原版生成器。 可以重写以下方法来启用此功能:
  • 构造器详细资料

    • 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      chunkData - 要修改的区块数据
    • 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      chunkData - 要修改的区块数据
    • 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      chunkData - 要修改的区块数据
    • 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      chunkData - 要修改的区块数据
    • getDefaultBiomeProvider

      @Nullable public @Nullable BiomeProvider getDefaultBiomeProvider(@NotNull @NotNull WorldInfo worldInfo)
      当在 WorldCreator 或服务器配置文件中未设置 BiomeProvider 时调用此方法. 因此,一个插件可以提供生物群系,另一个插件可以提供生成.

      原文: 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 - 生物群系提供器将用于的世界的世界信息
      返回:
      用于填充区块生物群系的BiomeProvider
    • getBaseHeight

      public int getBaseHeight(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int x, int z, @NotNull @NotNull HeightMap heightMap)
      此方法类似于 World.getHighestBlockAt(int, int, HeightMap). 区别在于,最高的y坐标应该是应用任何表面、基岩、洞穴或装饰之前的方块. 换句话说,就是区块中只有噪声存在时的最高方块.

      原文: 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      x - 世界原点的X坐标
      z - 世界原点的Z坐标
      heightMap - 从哪个高度图获取最高方块
      返回:
      给定位置最高方块的y坐标
    • generateChunkData

      已过时。
      生成现在已拆分,应使用新方法,参见 ChunkGenerator
      为给定坐标塑造区块. 此方法必须返回一个ChunkData.

      原文: 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 - 此区块将用于的世界
      random - 要使用的随机数生成器
      x - 区块的X坐标
      z - 区块的Z坐标
      biome - 区块的建议生物群系值 - 可以被生成器更新
      返回:
      包含此生成器创建的每个方块类型的ChunkData
    • createChunkData

      @NotNull @Deprecated(since="1.17.1") protected final @NotNull ChunkGenerator.ChunkData createChunkData(@NotNull @NotNull World world)
      已过时。
      ChunkGenerator.ChunkData 现在直接提供
      为世界创建一个ChunkData.

      原文: Create a ChunkData for a world.

      参数:
      world - ChunkData所用于的世界
      返回:
      为世界创建的新ChunkData
    • 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 BlockPopulators 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(since="1.17.1") public boolean isParallelCapable()
      已过时。
      区块生成代码应该是线程安全的
      获取此ChunkGenerator是否支持并行.

      原文: Gets if this ChunkGenerator is parallel capable. See ChunkGenerator for more information.

      返回:
      并行支持状态
    • shouldGenerateNoise

      @Deprecated(since="26.3") 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
      另请参阅:
    • shouldGenerateNoise

      @Deprecated(since="26.3") 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      返回:
      如果服务器应该生成原版噪声则返回true
      另请参阅:
    • 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
      另请参阅:
    • 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      返回:
      如果服务器应该生成原版表面则返回true
      另请参阅:
    • shouldGenerateBedrock

      @Deprecated(since="1.19.2") public boolean shouldGenerateBedrock()
      已过时。
      无效果,基岩生成是表面步骤的一部分,参见 shouldGenerateSurface()
      获取服务器是否应该生成原版基岩.

      原文: Gets if the server should generate Vanilla bedrock.

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

      返回:
      如果服务器应该生成原版基岩则返回true
    • shouldGenerateCaves

      @Deprecated(since="26.3") 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
      另请参阅:
    • shouldGenerateCaves

      @Deprecated(since="26.3") 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      返回:
      如果服务器应该生成原版洞穴则返回true
      另请参阅:
    • shouldGenerateDecorations

      public boolean shouldGenerateDecorations()
      获取服务器是否应该在此ChunkGenerator之后生成原版装饰.

      原文: 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
      另请参阅:
    • shouldGenerateDecorations

      public boolean shouldGenerateDecorations(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
      获取服务器是否应该在此ChunkGenerator之后生成原版装饰.

      原文: 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 - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      返回:
      如果服务器应该生成原版装饰则返回true
      另请参阅:
    • shouldGenerateMobs

      public boolean shouldGenerateMobs()
      获取服务器是否应该在此ChunkGenerator之后生成原版生物.

      原文: 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
      另请参阅:
    • shouldGenerateMobs

      public boolean shouldGenerateMobs(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
      获取服务器是否应该在此ChunkGenerator之后生成原版生物.

      原文: Gets if the server should generate Vanilla mobs after this ChunkGenerator.

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

      参数:
      worldInfo - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      返回:
      如果服务器应该生成原版生物则返回true
      另请参阅:
    • shouldGenerateStructures

      public boolean shouldGenerateStructures()
      获取服务器是否应该在此ChunkGenerator之后生成原版结构.

      原文: 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
      另请参阅:
    • shouldGenerateStructures

      public boolean shouldGenerateStructures(@NotNull @NotNull WorldInfo worldInfo, @NotNull @NotNull Random random, int chunkX, int chunkZ)
      获取服务器是否应该在此ChunkGenerator之后生成原版结构.

      原文: Gets if the server should generate Vanilla structures after this ChunkGenerator.

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

      参数:
      worldInfo - 此区块将用于的世界的世界信息
      random - 要使用的随机数生成器
      chunkX - 区块的X坐标
      chunkZ - 区块的Z坐标
      返回:
      如果服务器应该生成原版结构则返回true
      另请参阅: