public abstract class FiniteChunkSource extends ChunkSource
| Modifier and Type | Class and Description |
|---|---|
static class |
FiniteChunkSource.LevelDataContainer |
| Modifier and Type | Field and Description |
|---|---|
protected BiomeSource |
biomeSource |
protected float |
levelCaveWidth |
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.
|
void |
buildHouse(net.minecraft.world.WorldServer world,
net.minecraft.util.math.BlockPos spawnPos,
boolean isBonusChestEnabled)
Generates the Indev starting house at the given coordinates.
|
BiomeInjectionRules.Builder |
createBiomeInjectionRules(BiomeSource biomeSource)
Creates the rule set builder used for biome injection.
|
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.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(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.
|
java.lang.String |
getPhase()
Get the finite level generation phase.
|
WorldSpawner |
getWorldSpawner()
Gets the world spawner used to initially place the player spawn.
|
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.
|
void |
loadOrCreateLevelDataContainer(net.minecraft.world.World world)
Loads from file or creates new level data container.
|
protected void |
pregenerateLevelOrWait(FiniteChunkSource.LevelDataContainer levelDataContainer)
Checks if the level data has generated yet, if not, then generates the level data.
|
protected abstract void |
pregenerateTerrain()
Generates the level data.
|
void |
pregenerateTerrainOrWait()
Pregenerates the level terrain.
|
void |
provideInitialChunk(net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
Create initial chunk given chunk coordinates.
|
void |
provideProcessedChunk(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 |
saveLevelDataContainer(net.minecraft.world.World world)
Saves the level data container to file.
|
void |
setLevelBlock(int x,
int y,
int z,
net.minecraft.block.Block block)
Sets a block into level data at the given coordinates.
|
void |
setLevelNotifier(java.util.function.Consumer<java.lang.String> levelNotifier)
Sets the level notifier consumer.
|
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.
|
buildBiomeInjectorRules, createRandom, getBeachOctaveNoise, getDefaultBlock, getDefaultFluid, getForestOctaveNoise, getGeneratorSettings, getSeaLevel, getSeed, getSurfaceOctaveNoise, 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 float levelCaveWidth
protected final int[] levelHeightmap
protected final BiomeSource biomeSource
public FiniteChunkSource(long seed,
ModernBetaGeneratorSettings settings)
seed - The world seed.settings - The generator settings.public final WorldSpawner getWorldSpawner()
ChunkSourcegetWorldSpawner in class ChunkSourceWorldSpawner.DEFAULT by default.public void provideInitialChunk(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 ChunkSourcechunkPrimer - Chunk primerchunkX - x-coordinate in chunk coordinateschunkZ - z-coordinate in chunk coordinatespublic void provideProcessedChunk(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 ChunkSourcechunkPrimer - 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 final 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(int x,
int z,
HeightmapChunk.Type type)
getHeight.
Samples height from the generated level data.getHeight in class ChunkSourcex - 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 java.lang.String getPhase()
public void setLevelNotifier(java.util.function.Consumer<java.lang.String> levelNotifier)
levelNotifier - The level notifier consuming a String.public void loadOrCreateLevelDataContainer(net.minecraft.world.World world)
world - The world objectpublic void saveLevelDataContainer(net.minecraft.world.World world)
world - The world objectpublic void pregenerateTerrainOrWait()
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.Builder createBiomeInjectionRules(BiomeSource biomeSource)
ChunkSourcecreateBiomeInjectionRules in class ChunkSourcebiomeSource - The biome source.protected abstract void pregenerateTerrain()
protected abstract void generateBorder(net.minecraft.world.chunk.ChunkPrimer chunkPrimer,
int chunkX,
int chunkZ)
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 void pregenerateLevelOrWait(FiniteChunkSource.LevelDataContainer levelDataContainer)
levelDataContainer - The level data container.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 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)