public abstract class ChunkGenerator
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static interface |
ChunkGenerator.BiomeGrid
被生成区块的生物群系数据的接口:根据世界类型和种子的默认值初始化。
|
static interface |
ChunkGenerator.ChunkData
Data for a Chunk.
|
构造器和说明 |
---|
ChunkGenerator() |
限定符和类型 | 方法和说明 |
---|---|
boolean |
canSpawn(World world,
int x,
int z)
测试指定方位是否对自然生成的方位有效。
|
protected ChunkGenerator.ChunkData |
createChunkData(World world)
Create a ChunkData for a world.
|
byte[] |
generate(World world,
java.util.Random random,
int x,
int z)
已过时。
不安全的参数
|
byte[][] |
generateBlockSections(World world,
java.util.Random random,
int x,
int z,
ChunkGenerator.BiomeGrid biomes)
已过时。
不安全的参数
|
ChunkGenerator.ChunkData |
generateChunkData(World world,
java.util.Random random,
int x,
int z,
ChunkGenerator.BiomeGrid biome)
Shapes the chunk for the given coordinates.
|
short[][] |
generateExtBlockSections(World world,
java.util.Random random,
int x,
int z,
ChunkGenerator.BiomeGrid biomes)
已过时。
不安全的参数
|
java.util.List<BlockPopulator> |
getDefaultPopulators(World world)
得到一个用于提供指定世界的默认的
BlockPopulator 列表。 |
Location |
getFixedSpawnLocation(World world,
java.util.Random random)
获取一个固定出生方位用于一个指定的世界。
|
@Deprecated public byte[] generate(World world, java.util.Random random, int x, int z)
这个方法会按照下面的格式返回一个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坐标@Deprecated public short[][] generateExtBlockSections(World world, java.util.Random random, int x, int z, ChunkGenerator.BiomeGrid biomes)
截至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
- 区块预期的生物群系数值,可以被生成器更新@Deprecated public byte[][] generateBlockSections(World world, java.util.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
- 区块预期的生物群系数值,可以被生成器更新public ChunkGenerator.ChunkData generateChunkData(World world, java.util.Random random, int x, int z, ChunkGenerator.BiomeGrid biome)
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
generatorprotected final ChunkGenerator.ChunkData createChunkData(World world)
world
- the world the ChunkData is forpublic boolean canSpawn(World world, int x, int z)
原文: Tests if the specified location is valid for a natural spawn position
world
- 用于测试的世界x
- 用于测试的方块的X坐标z
- 用于测试的方块的Z坐标public java.util.List<BlockPopulator> getDefaultPopulators(World world)
BlockPopulator
列表。
原文:
Gets a list of default BlockPopulator
s to apply to a given
world
world
- 用于提供的世界public Location getFixedSpawnLocation(World world, java.util.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
- 这个计算器中使用的随机生成器