mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Settings no longer resolve to one value per type. FeatureSettings.at(type, x, z) returns one entry per level that declares the type at that column (dimension, region, surface biome, placement), each with its level, source and value; levels stack and a module decides what several mean. Conditional stage bodies receive every configured entry. Chunk and mantle runners collect a chunk's settings themselves, so a stage runs when any column of the chunk configures it. Work that writes the mantle or reaches beyond its chunk moves to a new MANTLE pipeline (Stage.mantle, MantleRunner) that the host runs around a chunk before it generates. Chunk stages may no longer declare a reach or mantle writes and see the mantle read-only. Built-in settings may hold host types the host describes itself (ModuleHost.describingHostTypesIn, ValueKind.HostKind); pack modules cannot. FeatureSchema.shorthand() names the only option of settings packs may write as a bare value.
57 lines
2.4 KiB
Java
57 lines
2.4 KiB
Java
package com.volmit.example.placement;
|
|
|
|
import com.volmit.IrisModule;
|
|
import com.volmit.ModuleInfo;
|
|
import com.volmit.block.BlockState;
|
|
import com.volmit.config.FeatureSettings.Entry;
|
|
import com.volmit.placement.PlacedBlock;
|
|
import com.volmit.stage.BlockStage;
|
|
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.List;
|
|
import java.util.Optional;
|
|
|
|
/** Port of PlacementModuleSnow: collect written tops, then cover them after the finishing work
|
|
* of whichever stilt or vacuum module is installed (soft, so neither is required).
|
|
*/
|
|
public final class SnowModule implements IrisModule {
|
|
public static final BlockStage<SnowHeights> COLLECT = Stage.placementBlock("iris:snow/collect", SnowHeights.class);
|
|
public static final PlacementStage<Void> FINISH = Stage.placement("iris:snow/finish");
|
|
public static final BlockState SNOW = new BlockState("minecraft:snow");
|
|
|
|
@Override
|
|
public ModuleInfo info() {
|
|
return ModuleInfo.of("iris:snow", "Snow", "test");
|
|
}
|
|
|
|
@Override
|
|
public void install(StageGraph graph) {
|
|
graph.define(COLLECT)
|
|
.when(SnowSettings.class)
|
|
.requires(BlocksModule.WRITE)
|
|
.accumulate(SnowHeights::new, (context, snow, heights) -> heights.include(
|
|
context.output(AnchorModule.HEIGHT).worldPosition(context.request(), context.block().position())));
|
|
graph.define(FINISH)
|
|
.when(SnowSettings.class)
|
|
.requires(COLLECT, BlocksModule.COMPLETE)
|
|
.softAfter(StageRef.of("iris:stilt/fill"), StageRef.of("iris:vacuum/finish"))
|
|
.run(SnowModule::cover);
|
|
}
|
|
|
|
private static void cover(PlacementStageContext context, List<Entry<SnowSettings>> settings) {
|
|
var snow = settings.getFirst().value(); // a placement declares its settings once
|
|
var layer = SNOW.withProperty("layers", Integer.toString(snow.layers()));
|
|
var access = context.access();
|
|
for (var top : context.output(COLLECT).tops()) {
|
|
var above = new BlockPosition(top.x(), top.y() + 1, top.z());
|
|
if (ExampleBlocks.isAir(access.get(above.x(), above.y(), above.z()))) {
|
|
access.set(new PlacedBlock(above, layer, Optional.empty()));
|
|
}
|
|
}
|
|
}
|
|
}
|