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,50 @@
|
||||
package com.volmit.example.placement;
|
||||
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.stage.PlacementStage;
|
||||
import com.volmit.stage.PlacementStageContext;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.stage.StageRef;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Third-party module: turns the ground under the anchor into moss. It requires the core
|
||||
* anchor height (typed output) and block completion, and runs after snow only if snow exists.
|
||||
*/
|
||||
public final class MossModule implements IrisModule {
|
||||
public static final PlacementStage<Void> SPREAD = Stage.placement("example:moss/spread");
|
||||
public static final BlockState MOSS = new BlockState("minecraft:moss_block");
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("example:moss", "1.0.0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(SPREAD)
|
||||
.when(MossSettings.class)
|
||||
.requires(AnchorModule.HEIGHT, BlocksModule.COMPLETE)
|
||||
.softAfter(StageRef.of("iris:snow/finish"))
|
||||
.run(MossModule::spread);
|
||||
}
|
||||
|
||||
private static void spread(PlacementStageContext context, MossSettings moss) {
|
||||
var anchor = context.output(AnchorModule.HEIGHT).anchor();
|
||||
var access = context.access();
|
||||
int groundY = anchor.y() - 1;
|
||||
for (int dx = -moss.radius(); dx <= moss.radius(); dx++) {
|
||||
for (int dz = -moss.radius(); dz <= moss.radius(); dz++) {
|
||||
int x = anchor.x() + dx;
|
||||
int z = anchor.z() + dz;
|
||||
if (!ExampleBlocks.isAir(access.get(x, groundY, z))) {
|
||||
access.set(new PlacedBlock(new BlockPosition(x, groundY, z), MOSS, Optional.empty()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user