类 ChunkGenerator
-
嵌套类概要
嵌套类修饰符和类型类说明static interface
被生成区块的生物群系数据的接口:根据世界类型和种子的默认值初始化。static interface
Data for a Chunk. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明boolean
测试指定方位是否对自然生成的方位有效。protected final ChunkGenerator.ChunkData
createChunkData
(World world) Create a ChunkData for a world.byte[]
已过时。不安全的参数byte[][]
generateBlockSections
(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes) 已过时。不安全的参数generateChunkData
(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biome) Shapes the chunk for the given coordinates.short[][]
generateExtBlockSections
(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes) 已过时。不安全的参数getDefaultPopulators
(World world) 得到一个用于提供指定世界的默认的BlockPopulator
列表。getFixedSpawnLocation
(World world, Random random) 获取一个固定出生方位用于一个指定的世界。
-
构造器详细资料
-
ChunkGenerator
public ChunkGenerator()
-
-
方法详细资料
-
generate
已过时。不安全的参数生成指定坐标的区块。这个方法会按照下面的格式返回一个byte[32768]类型的数据。
for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 128; y++) { // result[(x * 16 + z) * 128 + y] = ??; } } }
注意这个方法永远不要试图去获取已经通过的坐标,不然就可能陷入死循环。
注意这个过时的方法只有在 generateExtBlockSections() 和 generateBlockSections() 都失效并且返回null时才能被调用。
原文: Shapes the chunk for the given coordinates.
This method should return a byte[32768] in the following format:
for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 128; y++) { // result[(x * 16 + z) * 128 + y] = ??; } } }
Note that this method should never attempt to get the Chunk at the passed coordinates, as doing so may cause an infinite loop
Note this deprecated method will only be called when both generateExtBlockSections() and generateBlockSections() are unimplemented and return null.
- 参数:
world
- 被指定区块的世界random
- 使用的随机生成器x
- 区块的X坐标z
- 区块的Z坐标- 返回:
- 包含每个被这个生成器创造的方块的byte[]类型的数据
-
generateExtBlockSections
@Deprecated public short[][] generateExtBlockSections(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes) 已过时。不安全的参数使用拓展方块的ID(0-4095)生成指定坐标的区块。截至1.2,区块被表示为一个三维数组,每个区块都由16*16*16个方块组成。如果一部分是空的(都是ID为0的方块,即空气),那么这个部分就不再需要被维持以减少内存占用。
这个方法会按照下面的格式返回一个short[][]类型的数据。
short[][] result = new short[world-height / 16][];
每个拥有方块的部分(sectionID = (Y>>4))
需要为这部分中的4096个方块分配空间:result[sectionID] = new short[4096];
没有内容的部分可以被保留为空。使用下面的映射函数可以在X,Y,Z坐标放置一个在区块内的方块:
void setBlock(short[][] result, int x, int y, int z, short blkid) {
使用下面的映射函数可以读取一个方块的ID:if (result[y >> 4] == null) {} {@code result[y >> 4] = new short[4096];}
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
}short getBlock(short[][] result, int x, int y, int z) {
if (result[y >> 4] == null) {} return (short)0;
return result[y >> 4][((y & 0xF) << 8) | (z << 4) | x];
}注意这个方法永远不要试图去获取已经通过的坐标,不然就可能陷入死循环。
注意不能返回255以上方块ID的生成器不应该执行此方法,否则会返回空(generateBlockSections()方法被调用时的结果)。
原文: Shapes the chunk for the given coordinates, with extended block IDs supported (0-4095).
As of 1.2, chunks are represented by a vertical array of chunk sections, each of which is 16 x 16 x 16 blocks. If a section is empty (all zero), the section does not need to be supplied, reducing memory usage.
This method must return a short[][] array in the following format:
short[][] result = new short[world-height / 16][];
Each section(sectionID = (Y>>4))
that has blocks needs to be allocated space for the 4096 blocks in that section:result[sectionID] = new short[4096];
while sections that are not populated can be left null.Setting a block at X, Y, Z within the chunk can be done with the following mapping function:
void setBlock(short[][] result, int x, int y, int z, short blkid) {
while reading a block ID can be done with the following mapping function:if (result[y >> 4] == null) {} {@code result[y >> 4] = new short[4096];}
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
}short getBlock(short[][] result, int x, int y, int z) {
if (result[y >> 4] == null) {} return (short)0;
return result[y >> 4][((y & 0xF) << 8) | (z << 4) | x];
}Note that this method should never attempt to get the Chunk at the passed coordinates, as doing so may cause an infinite loop
Note generators that do not return block IDs above 255 should not implement this method, or should have it return null (which will result in the generateBlockSections() method being called).
- 参数:
world
- 被指定区块的世界random
- 使用的随机生成器x
- 区块的X坐标z
- 区块的Z坐标biomes
- 区块预期的生物群系数值,可以被生成器更新- 返回:
- 包含每个被这个生成器创造的方块的short[][]类型的数据
-
generateBlockSections
@Deprecated public byte[][] generateBlockSections(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes) 已过时。不安全的参数在指定的坐标生成区块。截至1.2,区块被表示为一个三维数组,每个区块都由16*16*16个方块组成。如果一部分是空的(都是ID为0的方块,即空气),那么这个部分就不再需要被维持以减少内存占用。
这个方法会按照下面的格式返回一个byte[][]类型的数据。
byte[][] result = new byte[world-height / 16][];
每个拥有方块的部分(sectionID = (Y>>4))
需要为这部分中的4096个方块分配空间:result[sectionID] = new byte[4096];
没有内容的部分可以被保留为空。 使用下面的映射函数可以在X,Y,Z坐标放置一个在区块内的方块:void setBlock(byte[][] result, int x, int y, int z, byte blkid) {
使用下面的映射函数可以读取一个方块的ID:if (result[y >> 4) == null) {} {@code result[y >> 4] = new byte[4096];}
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
}byte getBlock(byte[][] result, int x, int y, int z) {
注意这个方法永远不要试图去获取已经通过的坐标,不然就可能陷入死循环。if (result[y >> 4) == null) {} return (byte)0;
return result[y >> 4][((y & 0xF) << 8) | (z << 4) | x];
}原文: Shapes the chunk for the given coordinates.
As of 1.2, chunks are represented by a vertical array of chunk sections, each of which is 16 x 16 x 16 blocks. If a section is empty (all zero), the section does not need to be supplied, reducing memory usage.
This method must return a byte[][] array in the following format:
byte[][] result = new byte[world-height / 16][];
Each section(sectionID = (Y>>4))
that has blocks needs to be allocated space for the 4096 blocks in that section:result[sectionID] = new byte[4096];
while sections that are not populated can be left null.Setting a block at X, Y, Z within the chunk can be done with the following mapping function:
void setBlock(byte[][] result, int x, int y, int z, byte blkid) {
while reading a block ID can be done with the following mapping function:if (result[y >> 4) == null) {} {@code result[y >> 4] = new byte[4096];}
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
}byte getBlock(byte[][] result, int x, int y, int z) {
Note that this method should never attempt to get the Chunk at the passed coordinates, as doing so may cause an infinite loopif (result[y >> 4) == null) {} return (byte)0;
return result[y >> 4][((y & 0xF) << 8) | (z << 4) | x];
}- 参数:
world
- 被指定区块的世界random
- 使用的随机生成器x
- 区块的X坐标z
- 区块的Z坐标biomes
- 区块预期的生物群系数值,可以被生成器更新- 返回:
- 包含每个被这个生成器创造的方块的short[][]类型的数据
-
generateChunkData
public ChunkGenerator.ChunkData generateChunkData(World world, Random random, int x, int z, 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)
- 参数:
world
- The world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate of the chunkz
- The Z-coordinate of the chunkbiome
- Proposed biome values for chunk - can be updated by generator- 返回:
- ChunkData containing the types for each block created by this generator
-
createChunkData
Create a ChunkData for a world.- 参数:
world
- the world the ChunkData is for- 返回:
- a new ChunkData for world
-
canSpawn
测试指定方位是否对自然生成的方位有效。原文: Tests if the specified location is valid for a natural spawn position
- 参数:
world
- 用于测试的世界x
- 用于测试的方块的X坐标z
- 用于测试的方块的Z坐标- 返回:
- 如果方位有效则返回true,否则返回false
-
getDefaultPopulators
得到一个用于提供指定世界的默认的BlockPopulator
列表。原文: Gets a list of default
BlockPopulator
s to apply to a given world- 参数:
world
- 用于提供的世界- 返回:
- 包含所有方块填充器的列表
-
getFixedSpawnLocation
获取一个固定出生方位用于一个指定的世界。如果一个世界没有使用一个固定出生点就会返回空值,并且会试图随机寻找一个以代替。
原文: 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
-