|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.generator.ChunkGenerator
public abstract class ChunkGenerator
A chunk generator is responsible for the initial shaping of an entire chunk. For example, the nether chunk generator should shape netherrack and soulsand
Nested Class Summary | |
---|---|
static interface |
ChunkGenerator.BiomeGrid
Interface to biome data for chunk to be generated: initialized with default values for world type and seed. |
Constructor Summary | |
---|---|
ChunkGenerator()
|
Method Summary | |
---|---|
boolean |
canSpawn(World world,
int x,
int z)
Tests if the specified location is valid for a natural spawn position |
byte[] |
generate(World world,
Random random,
int x,
int z)
Deprecated. |
byte[][] |
generateBlockSections(World world,
Random random,
int x,
int z,
ChunkGenerator.BiomeGrid biomes)
Shapes the chunk for the given coordinates. |
short[][] |
generateExtBlockSections(World world,
Random random,
int x,
int z,
ChunkGenerator.BiomeGrid biomes)
Shapes the chunk for the given coordinates, with extended block IDs supported (0-4095). |
List<BlockPopulator> |
getDefaultPopulators(World world)
Gets a list of default BlockPopulator s to apply to a given world |
Location |
getFixedSpawnLocation(World world,
Random random)
Gets a fixed spawn location to use for a given world. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChunkGenerator()
Method Detail |
---|
@Deprecated public byte[] generate(World world, Random random, int x, int z)
public short[][] generateExtBlockSections(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes)
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) { if (result[y >> 4] == null) { result[y >> 4] = new short[4096]; } result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; }while reading a block ID can be done with the following mapping function:
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]; }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) { if (result[y >> 4) == null) { result[y >> 4] = new short[4096]; } result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; }while reading a block ID can be done with the following mapping function:
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
- The world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate of the chunkz
- The Z-coordinate of the chunkbiomes
- Proposed biome values for chunk - can be updated by generator
public byte[][] generateBlockSections(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes)
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) { if (result[y >> 4) == null) { result[y >> 4] = new byte[4096]; } result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; }while reading a block ID can be done with the following mapping function:
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]; }Note that this method should never attempt to get the Chunk at the passed coordinates, as doing so may cause an infinite loop
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 chunkbiomes
- Proposed biome values for chunk - can be updated by generator
public boolean canSpawn(World world, int x, int z)
world
- The world we're testing onx
- X-coordinate of the block to testz
- Z-coordinate of the block to test
public List<BlockPopulator> getDefaultPopulators(World world)
BlockPopulator
s to apply to a given world
world
- World to apply to
public Location getFixedSpawnLocation(World world, Random random)
world
- The world to locate a spawn point forrandom
- Random generator to use in the calculation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |