public abstract class FiniteChunkSource extends ChunkSource
| Modifier and Type | Class and Description |
|---|---|
static class |
FiniteChunkSource.LevelDataContainer |
| Modifier and Type | Field and Description |
|---|---|
protected int |
levelHeight |
protected int[] |
levelHeightmap |
protected int |
levelLength |
protected int |
levelWidth |
protected static int |
MAX_FLOODS |
protected static net.minecraft.block.Block |
PLACEHOLDER_BLOCK |
blockSources, DEEP_OCEAN_MIN_DEPTH, defaultBlock, defaultFluid, OCEAN_MIN_DEPTH, random, seaLevel, seed, settings, worldHeight| Constructor and Description |
|---|
FiniteChunkSource(long seed,
ModernBetaGeneratorSettings settings)
Constructs an abstract FiniteChunkSource with necessary level information.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
atLevelBounds(int x,
int y,
int z)
Indicates whether the given level coordinates are at the level bounds.
|
BiomeInjectionRules |
buildBiomeInjectorRules(ModernBetaBiomeProvider biomeProvider)
Builds the ruleset used for biome injection.
|
void |
buildHouse(net.minecraft.world.WorldServer world,
net.minecraft.util.math.BlockPos spawnPos,
boolean isBonusChestEnabled)
Generates the Indev starting house at the given coordinates.
|
protected void |
fillOblateSpheroid(float centerX,
float centerY,
float centerZ,
float radius,
net.minecraft.block.Block fillBlock)
Fills a space in level data in a spheroid shape.
|
protected int |
flood(int x,
int y,
int z,
net.minecraft.block.Block fillBlock,
net.minecraft.block.Block replaceBlock)
Floods the level downward and outward from a given starting position and fill/replace blocks.
|
protected int |
flood(int startX,
int startY,
int startZ,
net.minecraft.block.Block fillBlock,
net.minecraft.block.Block replaceBlock,
net.minecraft.util.math.Vec3d[] floodedPositions)
Floods the level downward and outward from a given starting position and fill/replace blocks.
|
protected abstract void |
generateBorder(net.minecraft.world.World world,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
Generates the world chunks outside of the level bounds.
|
protected abstract int |
getBorderHeight(int x,
int z,
HeightmapChunk.Type type)
Sample height at given x/z coordinate for coordinates outside of the level bounds.
|
int |
getHeight(net.minecraft.world.World world,
int x,
int z,
HeightmapChunk.Type type)
Inherited from
getHeight. |
net.minecraft.block.Block |
getLevelBlock(int x,
int y,
int z)
Gets a block given coordinates from level data.
|
int |
getLevelHeight()
Gets the finite level height.
|
int |
getLevelHeight(int x,
int z,
HeightmapChunk.Type type)
Gets the height from level data given x/z coordinates and the heightmap type.
|
int |
getLevelLength()
Gets the finite level length.
|
int |
getLevelWidth()
Gets the finite level width.
|
SpawnLocator |
getSpawnLocator()
Inherited from
getSpawnLocator. |
boolean |
hasPregenerated()
Indicates whether the level data has been generated.
|
protected boolean |
inLevelBounds(int x,
int y,
int z)
Indicates whether the given level coordinates are within the level area.
|
boolean |
inWorldBounds(int x,
int z)
Indicates whether the given x/z world coordinates are within the level area.
|
protected void |
pregenerateLevelOrWait(net.minecraft.world.World world)
Checks if the level data has generated yet, if not, then generates the level data.
|
protected abstract void |
pregenerateTerrain()
Generates the level data.
|
void |
provideInitialChunk(net.minecraft.world.World world,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
Create initial chunk given chunk coordinates.
|
void |
provideProcessedChunk(net.minecraft.world.World world,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ,
java.util.List<net.minecraft.world.gen.structure.StructureComponent> structureComponents)
Create processed chunk given chunk coordinates.
|
void |
provideSurface(net.minecraft.world.World world,
net.minecraft.world.biome.Biome[] biomes,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
Build surface for given chunk primer and chunk coordinates.
|
void |
pruneChunk(net.minecraft.world.World world,
int chunkX,
int chunkZ)
Prunes the chuck at the given coordinates.
|
void |
setLevelBlock(int x,
int y,
int z,
net.minecraft.block.Block block)
Sets a block into level data at the given coordinates.
|
protected void |
setPhase(java.lang.String phase)
Sets the current generation phase for the level.
|
protected void |
setPhaseProgress(float phaseProgress)
Sets the current generation phase progress for the level.
|
boolean |
skipChunk(int chunkX,
int chunkZ)
Indicate whether the chunk at the given coordinates should be skipped.
|
atBeachDepth, atOceanDepth, getBeachOctaveNoise, getDefaultBlock, getDefaultFluid, getForestOctaveNoise, getGeneratorSettings, getSeaLevel, getSeed, getSurfaceOctaveNoise, isBeachBlock, isFluidBlock, setBeachOctaveNoise, setCloudHeight, setForestOctaveNoise, setSurfaceOctaveNoiseprotected static final net.minecraft.block.Block PLACEHOLDER_BLOCK
protected static final int MAX_FLOODS
protected final int levelWidth
protected final int levelLength
protected final int levelHeight
protected final int[] levelHeightmap
public FiniteChunkSource(long seed,
ModernBetaGeneratorSettings settings)
seed - The world seed.settings - The generator settings.public SpawnLocator getSpawnLocator()
getSpawnLocator.
Uses IndevSpawnLocator by default.getSpawnLocator in class ChunkSourceSpawnLocator.DEFAULT by default.public void provideInitialChunk(net.minecraft.world.World world,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
ChunkSourceBiomeProvider.getBiome() from World.
At this stage, the biomes have not actually been set for ModernBetaBiome to sample from.
Instead, get the biome provider, cast to ModernBetaBiomeProvider and use ModernBetaBiomeProvider.getBiomeSource() to sample biomes, or do final generation in processedChunk to get processed biome map.provideInitialChunk in class ChunkSourceworld - The world objectchunkPrimer - Chunk primerchunkX - x-coordinate in chunk coordinateschunkZ - z-coordinate in chunk coordinatespublic void provideProcessedChunk(net.minecraft.world.World world,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ,
java.util.List<net.minecraft.world.gen.structure.StructureComponent> structureComponents)
ChunkSourceprovideInitialChunk so villages can be placed correctly.
This does not need to be implemented and can be left empty, if you don't wish to do additional processing.provideProcessedChunk in class ChunkSourceworld - The world objectchunkPrimer - Chunk primerchunkX - x-coordinate in chunk coordinateschunkZ - z-coordinate in chunk coordinatesstructureComponents - The list of structure components that at least partially occupy this chunk.public void provideSurface(net.minecraft.world.World world,
net.minecraft.world.biome.Biome[] biomes,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
ChunkSourceprovideSurface in class ChunkSourceworld - The world objectbiomes - Biome array for chunkchunkPrimer - Chunk primerchunkX - x-coordinate in chunk coordinateschunkZ - z-coordinate in chunk coordinatespublic int getHeight(net.minecraft.world.World world,
int x,
int z,
HeightmapChunk.Type type)
getHeight.
Samples height from the generated level data.getHeight in class ChunkSourceworld - The world object.x - x-coordinate in block coordinates.z - z-coordinate in block coordinates.type - HeightmapChunk heightmap type.public net.minecraft.block.Block getLevelBlock(int x,
int y,
int z)
x - x-coordinate in block coordinates.y - y-coordinate in block coordinates.z - z-coordinate in block coordinates.public void setLevelBlock(int x,
int y,
int z,
net.minecraft.block.Block block)
x - x-coordinate in block coordinates.y - y-coordinate in block coordinates.z - z-coordinate in block coordinates.block - The block to set in level data.public int getLevelHeight(int x,
int z,
HeightmapChunk.Type type)
x - x-coordinate in block coordinates.z - z-coordinate in block coordinates.type - HeightmapChunk.Type.public int getLevelWidth()
public int getLevelLength()
public int getLevelHeight()
public void buildHouse(net.minecraft.world.WorldServer world,
net.minecraft.util.math.BlockPos spawnPos,
boolean isBonusChestEnabled)
world - The world object.spawnPos - The player spawn block position.isBonusChestEnabled - Whether the bonus chest should be generated in the house.public boolean inWorldBounds(int x,
int z)
x - x-coordinate in block coordinates in world space.z - z-coordinate in block coordinates in world space.public boolean hasPregenerated()
public boolean skipChunk(int chunkX,
int chunkZ)
skipChunk in class ChunkSourcechunkX - x-coordinate in chunk coordinateschunkZ - z-coordinate in chunk coordinatespublic void pruneChunk(net.minecraft.world.World world,
int chunkX,
int chunkZ)
pruneChunk in class ChunkSourcechunkX - x-coordinate in chunk coordinateschunkZ - z-coordinate in chunk coordinatesworld - The world objectpublic BiomeInjectionRules buildBiomeInjectorRules(ModernBetaBiomeProvider biomeProvider)
buildBiomeInjectorRules in class ChunkSourcebiomeProvider - The biome provider.protected abstract void pregenerateTerrain()
protected abstract void generateBorder(net.minecraft.world.World world,
net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
world - The world object.chunkPrimer - The chunk primer.chunkX - x-coordinate in chunk coordinateschunkZ - z-coordinate in chunk coordinatesprotected abstract int getBorderHeight(int x,
int z,
HeightmapChunk.Type type)
x - x-coordinate in block coordinates.z - z-coordinate in block coordinates.type - HeightmapChunk.Type.protected boolean inLevelBounds(int x,
int y,
int z)
x - x-coordinate in block coordinates in level space.y - y-coordinate in block coordinates in level space.z - z-coordinate in block coordinates in level space.protected boolean atLevelBounds(int x,
int y,
int z)
x - x-coordinate in block coordinates in level space.y - y-coordinate in block coordinates in level space.z - z-coordinate in block coordinates in level space.protected void pregenerateLevelOrWait(net.minecraft.world.World world)
world - The world object, passed into FiniteDataHandler.protected void fillOblateSpheroid(float centerX,
float centerY,
float centerZ,
float radius,
net.minecraft.block.Block fillBlock)
centerX - x-coordinate in block coordinates in level space.centerY - y-coordinate in block coordinates in level space.centerZ - z-coordinate in block coordinates in level space.radius - Radius of spheroid shape.fillBlock - Block to fill into space.protected int flood(int x,
int y,
int z,
net.minecraft.block.Block fillBlock,
net.minecraft.block.Block replaceBlock)
x - x-coordinate in block coordinates in level space.y - y-coordinate in block coordinates in level space.z - z-coordinate in block coordinates in level space.fillBlock - The block to fill the space with.replaceBlock - The block to replace.MAX_FLOODS or if floodedPositions is null. -1 otherwise.protected int flood(int startX,
int startY,
int startZ,
net.minecraft.block.Block fillBlock,
net.minecraft.block.Block replaceBlock,
net.minecraft.util.math.Vec3d[] floodedPositions)
MAX_FLOODS positions and then return.
The intent is to use a test block as the `fillBlock` (see PLACEHOLDER_BLOCK), then fill with the actual fill block if the number of floods is below MAX_FLOODS.
Otherwise you should refill with the original block using the array positions.
More comments below:
Not the original algorithm, but did extensive testing/reverse engineering against a modded instance of Indev,
so this is accurate except in one case -- doing edge floods for Inland worlds; this shouldn't seem possible given
that the edges should never be exposed, but for some reason some underground pockets along the level edge still
flood.
The algorithm should basically just be flooding downwards and outwards given a starting position, however,
what I'm fairly certain the original algorithm does when flooding along map edges:
Flooding can touch edges of the map (x = 0 / z = 0 / x = levelWidth - 1 / z = levelLength - 1 / y = 0 / y = levelHeight - 1)
if doing edge floods (does a check for filler block id 255 which is only done for random position floods),
otherwise cancel the flood.
However, there seems to be a bug where the check if x = levelWidth - 1 does not actually use x,
so the original level generator allows water to generate where x = levelWidth - 1 above ground.
This bug is fixed here, because I'm not sure how to consistently reproduce it.startX - x-coordinate in block coordinates in level space.startY - y-coordinate in block coordinates in level space.startZ - z-coordinate in block coordinates in level space.fillBlock - The block to fill the space with.replaceBlock - The block to replace.floodedPositions - The array of Vec3d positions that have been filled. This is used to track positions to quickly fill with another block type.MAX_FLOODS or if floodedPositions is null. -1 otherwise.protected void setPhase(java.lang.String phase)
phase - Generation phase.protected void setPhaseProgress(float phaseProgress)
phaseProgress - The decimal phase progress. (i.e. 50% equals 0.5)