mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +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,41 @@
|
||||
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;
|
||||
|
||||
/** Third-party decoration: tops terrain columns using the terrain module's typed output. */
|
||||
public final class GrassModule implements IrisModule {
|
||||
public static final ChunkStage<Void> TOP = Stage.chunk("example:grass/top");
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("example:grass", "1.0.0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(TOP)
|
||||
.when(GrassSettings.class)
|
||||
.requires(TerrainModule.SURFACE)
|
||||
.run(GrassModule::cover);
|
||||
}
|
||||
|
||||
private static void cover(ChunkStageContext context, GrassSettings grass) {
|
||||
var top = new BlockState(grass.block());
|
||||
var heights = context.output(TerrainModule.SURFACE);
|
||||
var blocks = context.hunk(BlockState.class);
|
||||
for (int x = 0; x < blocks.getWidth(); x++) {
|
||||
for (int z = 0; z < blocks.getDepth(); z++) {
|
||||
int height = heights.at(x, z);
|
||||
if (height > 0) {
|
||||
blocks.set(x, height - 1, z, top);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user