mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
- IrisModule.setup(ModuleSetup) replaces install(StageGraph) and register(FeatureRegistry); ModuleSetups.run is the host entry point. - The conditional definition variants are gone: a stage body reads the settings it is conditioned on through ctx.configured(Type.class). - Placement, block, chunk and mantle stages each get their own definition interface; chunk definitions offer neither reach nor writesMantle. MantleStage is no longer generic. - softAfter/softBefore take stage constants as well as StageRefs. - A producer that rejected the attempt may return null. - PlacementRunner, ChunkRunner and MantleRunner all take StageTimings. - ConfiguredSettings groups entries by the type that declares @Feature. - README, DESIGN and CONTRACTS updated, with the edge choice table.
47 lines
1.7 KiB
Java
47 lines
1.7 KiB
Java
package com.volmit.example.chunk;
|
|
|
|
import com.volmit.IrisModule;
|
|
import com.volmit.ModuleInfo;
|
|
import com.volmit.ModuleSetup;
|
|
import com.volmit.block.BlockState;
|
|
import com.volmit.stage.ChunkStage;
|
|
import com.volmit.stage.ChunkStageContext;
|
|
import com.volmit.stage.Stage;
|
|
|
|
/** Core terrain shaping as an ordinary module: fills stone and reports surface heights. */
|
|
public final class TerrainModule implements IrisModule {
|
|
public static final ChunkStage<SurfaceHeights> SURFACE = Stage.chunk("iris:terrain/surface", SurfaceHeights.class);
|
|
public static final BlockState STONE = new BlockState("minecraft:stone");
|
|
private static final int BASE_HEIGHT = 3;
|
|
private static final int RIPPLE = 3;
|
|
|
|
@Override
|
|
public ModuleInfo info() {
|
|
return ModuleInfo.of("iris:terrain", "Terrain", "test");
|
|
}
|
|
|
|
@Override
|
|
public void setup(ModuleSetup setup) {
|
|
setup.stages().define(SURFACE).produce(TerrainModule::shape);
|
|
}
|
|
|
|
public static int surfaceHeight(int worldX, int worldZ) {
|
|
return BASE_HEIGHT + Math.floorMod(worldX + worldZ, RIPPLE);
|
|
}
|
|
|
|
private static SurfaceHeights shape(ChunkStageContext context) {
|
|
var blocks = context.hunk(BlockState.class);
|
|
var heights = new SurfaceHeights(blocks.getWidth(), blocks.getDepth());
|
|
for (int x = 0; x < blocks.getWidth(); x++) {
|
|
for (int z = 0; z < blocks.getDepth(); z++) {
|
|
int height = Math.min(surfaceHeight(context.originX() + x, context.originZ() + z), blocks.getHeight());
|
|
for (int y = 0; y < height; y++) {
|
|
blocks.set(x, y, z, STONE);
|
|
}
|
|
heights.set(x, z, height);
|
|
}
|
|
}
|
|
return heights;
|
|
}
|
|
}
|