mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Port a slice of the Iris placement lifecycle as example modules
Prepare/transforms, anchor height, block writes, stilt and snow are rebuilt as independent iris:* modules, plus a third-party moss module that integrates via requires, softAfter and a typed output. A two-module chunk example proves the generic machinery outside placement.
This commit is contained in:
1 parent
eeb5486098
commit
d78a66772a
21 files changed
+849
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package com.volmit.example.chunk;
|
||||
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.stage.ChunkStage;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/** 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", "test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user