diff --git a/src/main/java/com/volmit/config/Reference.java b/src/main/java/com/volmit/config/Reference.java index 942ced307..2f26937c5 100644 --- a/src/main/java/com/volmit/config/Reference.java +++ b/src/main/java/com/volmit/config/Reference.java @@ -16,6 +16,11 @@ public enum Reference { BIOME, /** A platform structure, such as {@code minecraft:village_plains}. */ STRUCTURE, + /** A platform structure or a prefix naming a family of them: {@code minecraft:village_plains}, + * {@code minecraft:village} (every village) or {@code nova_structures:} (a whole namespace). */ + STRUCTURE_PREFIX, + /** A platform structure set, such as {@code minecraft:villages}. */ + STRUCTURE_SET, /** A potion effect type, such as {@code minecraft:speed}. */ POTION_EFFECT, /** An enchantment, such as {@code minecraft:sharpness}. */ diff --git a/src/main/java/com/volmit/vanilla/JigsawOverrides.java b/src/main/java/com/volmit/vanilla/JigsawOverrides.java new file mode 100644 index 000000000..fb87cf1f2 --- /dev/null +++ b/src/main/java/com/volmit/vanilla/JigsawOverrides.java @@ -0,0 +1,238 @@ +package com.volmit.vanilla; + +import com.volmit.config.Desc; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalInt; + +/** Changes to a platform jigsaw structure's definition before the platform assembles one start of it, as packs write + * them: {@code {"startPool": "minecraft:village/plains/town_centers", "maxDepth": 4}}. Every option left out keeps + * what the registered definition says. A value the host creates with the no-argument constructor and reads the JSON + * into. + */ +@Desc("Optional overrides applied to a live vanilla, datapack, or modded jigsaw definition before Minecraft assembles it. Omitted values preserve the registered source definition.") +public final class JigsawOverrides { + /** Removes the definition's start connector constraint when given as {@link #startJigsawName()}. */ + public static final String NO_START_JIGSAW = "NONE"; + + /** Whether the start piece follows one of the platform's heightmaps. */ + @Desc("Controls whether a configured native jigsaw projects its start onto a Minecraft heightmap.") + public enum Heightmap { + @Desc("Keeps the registered structure's own heightmap projection.") + SOURCE, + @Desc("Removes heightmap projection: the start piece lands at the structure's literal start height.") + NONE, + @Desc("The terrain top counting water as solid.") + WORLD_SURFACE_WG, + @Desc("The terrain top including water.") + WORLD_SURFACE, + @Desc("Solid terrain beneath any water.") + OCEAN_FLOOR_WG, + @Desc("Solid ground beneath any water.") + OCEAN_FLOOR, + @Desc("The terrain top including water.") + MOTION_BLOCKING, + @Desc("The terrain top including water; there is no leaf layer to skip.") + MOTION_BLOCKING_NO_LEAVES + } + + /** Whether placed pieces take on the water they are placed into. */ + @Desc("Controls waterlogging behavior for a configured native jigsaw.") + public enum Liquids { + @Desc("Keeps the registered structure's own liquid setting.") + SOURCE, + @Desc("Places pieces dry.") + IGNORE_WATERLOGGING, + @Desc("Waterlogs placed pieces from the water they replace.") + APPLY_WATERLOGGING + } + + @Desc("Optional registered template-pool key used instead of the source jigsaw's start pool. Empty preserves the source pool.") + private String startPool = ""; + + @Desc("Optional start connector name. Empty preserves the source value; the literal NONE removes the source constraint.") + private String startJigsawName = ""; + + @MinNumber(0) + @MaxNumber(20) + @Desc("Maximum jigsaw recursion depth. Null preserves the source value.") + private Integer maxDepth = null; + + @MinNumber(1) + @MaxNumber(128) + @Desc("Exact horizontal block distance allowed from the start. Null preserves the source value.") + private Integer maxDistanceHorizontal = null; + + @MinNumber(1) + @MaxNumber(4064) + @Desc("Exact vertical block distance allowed from the start. Null preserves the source value.") + private Integer maxDistanceVertical = null; + + @Desc("Expansion-hack override. Null preserves the source value.") + private Boolean useExpansionHack = null; + + @Desc("Heightmap projection override. SOURCE preserves the registered value and NONE removes projection.") + private Heightmap projectStartToHeightmap = Heightmap.SOURCE; + + @MinNumber(0) + @MaxNumber(Integer.MAX_VALUE) + @Desc("Minimum distance retained above the dimension floor. Null preserves the source value.") + private Integer dimensionPaddingBottom = null; + + @MinNumber(0) + @MaxNumber(Integer.MAX_VALUE) + @Desc("Minimum distance retained below the dimension ceiling. Null preserves the source value.") + private Integer dimensionPaddingTop = null; + + @Desc("Waterlogging override. SOURCE preserves the registered value.") + private Liquids liquidSettings = Liquids.SOURCE; + + private JigsawOverrides() { + } + + private JigsawOverrides(JigsawOverrides source) { + startPool = source.startPool; + startJigsawName = source.startJigsawName; + maxDepth = source.maxDepth; + maxDistanceHorizontal = source.maxDistanceHorizontal; + maxDistanceVertical = source.maxDistanceVertical; + useExpansionHack = source.useExpansionHack; + projectStartToHeightmap = source.projectStartToHeightmap(); + dimensionPaddingBottom = source.dimensionPaddingBottom; + dimensionPaddingTop = source.dimensionPaddingTop; + liquidSettings = source.liquidSettings(); + } + + /** Overrides that change nothing: the registered definition as it is. */ + public static JigsawOverrides none() { + return new JigsawOverrides(); + } + + /** These overrides, starting from the template pool {@code pool}, such as {@code minecraft:village/plains/town_centers}. */ + public JigsawOverrides withStartPool(String pool) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.startPool = Objects.requireNonNull(pool, "pool"); + return overrides; + } + + /** These overrides, starting from the connector {@code name}; {@link #NO_START_JIGSAW} removes the constraint. */ + public JigsawOverrides withStartJigsawName(String name) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.startJigsawName = Objects.requireNonNull(name, "name"); + return overrides; + } + + public JigsawOverrides withMaxDepth(int depth) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.maxDepth = depth; + return overrides; + } + + /** These overrides, keeping pieces within {@code horizontal} and {@code vertical} blocks of the start. */ + public JigsawOverrides withMaxDistance(int horizontal, int vertical) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.maxDistanceHorizontal = horizontal; + overrides.maxDistanceVertical = vertical; + return overrides; + } + + public JigsawOverrides withExpansionHack(boolean use) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.useExpansionHack = use; + return overrides; + } + + public JigsawOverrides withHeightmap(Heightmap heightmap) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.projectStartToHeightmap = Objects.requireNonNull(heightmap, "heightmap"); + return overrides; + } + + /** These overrides, keeping the pieces {@code bottom} blocks above the dimension's floor and {@code top} below its ceiling. */ + public JigsawOverrides withDimensionPadding(int bottom, int top) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.dimensionPaddingBottom = bottom; + overrides.dimensionPaddingTop = top; + return overrides; + } + + public JigsawOverrides withLiquids(Liquids liquids) { + JigsawOverrides overrides = new JigsawOverrides(this); + overrides.liquidSettings = Objects.requireNonNull(liquids, "liquids"); + return overrides; + } + + /** The template pool to start from; empty keeps the definition's. */ + public String startPool() { + return startPool == null ? "" : startPool; + } + + /** The start connector; empty keeps the definition's, {@link #NO_START_JIGSAW} removes it. */ + public String startJigsawName() { + return startJigsawName == null ? "" : startJigsawName; + } + + public OptionalInt maxDepth() { + return optional(maxDepth); + } + + public OptionalInt maxDistanceHorizontal() { + return optional(maxDistanceHorizontal); + } + + public OptionalInt maxDistanceVertical() { + return optional(maxDistanceVertical); + } + + public Optional useExpansionHack() { + return Optional.ofNullable(useExpansionHack); + } + + /** The heightmap projection; {@link Heightmap#SOURCE} where the pack wrote none or one the host does not know. */ + public Heightmap projectStartToHeightmap() { + return projectStartToHeightmap == null ? Heightmap.SOURCE : projectStartToHeightmap; + } + + public OptionalInt dimensionPaddingBottom() { + return optional(dimensionPaddingBottom); + } + + public OptionalInt dimensionPaddingTop() { + return optional(dimensionPaddingTop); + } + + /** The waterlogging; {@link Liquids#SOURCE} where the pack wrote none or one the host does not know. */ + public Liquids liquidSettings() { + return liquidSettings == null ? Liquids.SOURCE : liquidSettings; + } + + private static OptionalInt optional(Integer value) { + return value == null ? OptionalInt.empty() : OptionalInt.of(value); + } + + @Override + public boolean equals(Object other) { + return other instanceof JigsawOverrides that && startPool().equals(that.startPool()) + && startJigsawName().equals(that.startJigsawName()) && Objects.equals(maxDepth, that.maxDepth) + && Objects.equals(maxDistanceHorizontal, that.maxDistanceHorizontal) + && Objects.equals(maxDistanceVertical, that.maxDistanceVertical) + && Objects.equals(useExpansionHack, that.useExpansionHack) + && projectStartToHeightmap() == that.projectStartToHeightmap() + && Objects.equals(dimensionPaddingBottom, that.dimensionPaddingBottom) + && Objects.equals(dimensionPaddingTop, that.dimensionPaddingTop) + && liquidSettings() == that.liquidSettings(); + } + + @Override + public int hashCode() { + return Objects.hash(startPool(), startJigsawName(), maxDepth, maxDistanceHorizontal, maxDistanceVertical, + useExpansionHack, projectStartToHeightmap(), dimensionPaddingBottom, dimensionPaddingTop, liquidSettings()); + } + + @Override + public String toString() { + return "JigsawOverrides[pool '" + startPool() + "', depth " + maxDepth + ", " + projectStartToHeightmap() + "]"; + } +} diff --git a/src/main/java/com/volmit/vanilla/StructureStilts.java b/src/main/java/com/volmit/vanilla/StructureStilts.java new file mode 100644 index 000000000..e3f8e7de5 --- /dev/null +++ b/src/main/java/com/volmit/vanilla/StructureStilts.java @@ -0,0 +1,96 @@ +package com.volmit.vanilla; + +import com.volmit.block.BlockSpec; +import com.volmit.block.PaletteSpec; +import com.volmit.config.Desc; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; +import java.util.List; +import java.util.Objects; + +/** Foundation columns the host builds beneath a structure's pieces after placing them, as packs write it: + * {@code {"maxDepth": 32, "palette": {"palette": [{"block": "stone_bricks"}]}, "spacing": 2}}. A value the host + * creates with the no-argument constructor and reads the JSON into. + */ +@Desc("Defines foundation columns placed beneath a structure.") +public final class StructureStilts { + private static final int DEFAULT_MAX_DEPTH = 64; + private static final String DEFAULT_BLOCK = "minecraft:cobblestone"; + + @MinNumber(1) + @MaxNumber(4064) + @Desc("Maximum number of blocks each foundation column may descend while searching for solid ground.") + private int maxDepth = DEFAULT_MAX_DEPTH; + + @Desc("Block palette used for foundation columns.") + private PaletteSpec palette = PaletteSpec.of(List.of(BlockSpec.of(DEFAULT_BLOCK))); + + @MinNumber(1) + @MaxNumber(64) + @Desc("Horizontal spacing between support columns. One fills every eligible foundation column.") + private int spacing = 1; + + @Desc("Whether solid partial blocks such as slabs, stairs, and walls may seed foundation columns.") + private boolean supportNonOccluding = false; + + private StructureStilts() { + } + + private StructureStilts(int maxDepth, PaletteSpec palette, int spacing, boolean supportNonOccluding) { + this.maxDepth = maxDepth; + this.palette = Objects.requireNonNull(palette, "palette"); + this.spacing = spacing; + this.supportNonOccluding = supportNonOccluding; + } + + /** Columns of {@code palette} under every eligible block, at most 64 deep. */ + public static StructureStilts of(PaletteSpec palette) { + return new StructureStilts(DEFAULT_MAX_DEPTH, palette, 1, false); + } + + public StructureStilts withMaxDepth(int maxDepth) { + return new StructureStilts(maxDepth, palette(), spacing, supportNonOccluding); + } + + public StructureStilts withSpacing(int spacing) { + return new StructureStilts(maxDepth, palette(), spacing, supportNonOccluding); + } + + /** These stilts, also seeded from partial blocks such as slabs, stairs and walls. */ + public StructureStilts supportingNonOccluding() { + return new StructureStilts(maxDepth, palette(), spacing, true); + } + + public int maxDepth() { + return maxDepth; + } + + /** The blocks of the columns; cobblestone where the pack wrote none. */ + public PaletteSpec palette() { + return palette == null ? PaletteSpec.of(List.of(BlockSpec.of(DEFAULT_BLOCK))) : palette; + } + + public int spacing() { + return spacing; + } + + public boolean supportNonOccluding() { + return supportNonOccluding; + } + + @Override + public boolean equals(Object other) { + return other instanceof StructureStilts that && maxDepth == that.maxDepth && palette().equals(that.palette()) + && spacing == that.spacing && supportNonOccluding == that.supportNonOccluding; + } + + @Override + public int hashCode() { + return Objects.hash(maxDepth, palette(), spacing, supportNonOccluding); + } + + @Override + public String toString() { + return "StructureStilts[" + palette() + ", depth " + maxDepth + ", spacing " + spacing + "]"; + } +} diff --git a/src/main/java/com/volmit/vanilla/StructureTerrain.java b/src/main/java/com/volmit/vanilla/StructureTerrain.java new file mode 100644 index 000000000..76bfd84fd --- /dev/null +++ b/src/main/java/com/volmit/vanilla/StructureTerrain.java @@ -0,0 +1,222 @@ +package com.volmit.vanilla; + +import com.volmit.block.PaletteSpec; +import com.volmit.config.Desc; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; +import java.util.Objects; +import java.util.Optional; + +/** How the host fits the terrain around a structure before its pieces are placed, as packs write it: + * {@code {"mode": "FORCE_CARVE", "horizontalPadding": 4, "shape": "ERODED"}}. The host carries the work out; a module + * only describes it. A value the host creates with the no-argument constructor and reads the JSON into. + */ +@Desc("Terrain integration applied after a structure graph is assembled and before its pieces are placed.") +public final class StructureTerrain { + private static final double DEFAULT_EROSION_STRENGTH = 0.8D; + private static final double DEFAULT_EROSION_FREQUENCY = 0.07D; + private static final double DEFAULT_LOBE_STRENGTH = 0.85D; + + /** What the host does to the terrain around the structure. */ + @Desc("Controls how terrain is integrated with a structure.") + public enum Mode { + @Desc("Replays the registered structure's own authored terrain adaptation.") + SOURCE, + @Desc("Disables all terrain integration.") + PRESERVE, + @Desc("Clears one straight box around the assembled pieces, expanded by the paddings.") + BORE, + @Desc("Clears the padded envelope in the configured carve shape.") + FORCE_CARVE, + @Desc("Raises surface terrain under rigid foundations with a 12-block falloff without lowering existing ground.") + VACUUM, + @Desc("Fills the padded piece volume with solid blocks before any piece is placed.") + ENCASE + } + + /** The shape {@link Mode#FORCE_CARVE} clears. */ + @Desc("Controls the shape of the expanded terrain carve around a structure.") + public enum Shape { + @Desc("The full expanded box with straight walls, ceiling and floor.") + BOX, + @Desc("A smooth rounded volume without erosion noise.") + ROUNDED, + @Desc("A rounded volume whose outer boundary is eroded by noise.") + ERODED + } + + @Desc("Terrain operation.") + private Mode mode = Mode.SOURCE; + + @MinNumber(0) + @MaxNumber(128) + @Desc("Horizontal clearance around the assembled pieces for BORE, FORCE_CARVE, and ENCASE.") + private int horizontalPadding = 0; + + @MinNumber(0) + @MaxNumber(128) + @Desc("Air clearance above the assembled pieces.") + private int ceilingPadding = 0; + + @MinNumber(0) + @MaxNumber(64) + @Desc("Terrain cleared below the assembled pieces. Zero preserves their supporting floor.") + private int floorPadding = 0; + + @Desc("Shape used by FORCE_CARVE.") + private Shape shape = Shape.BOX; + + @Desc("Block palette used by ENCASE. When unset, the host picks the dimension's own stone.") + private PaletteSpec encasePalette = null; + + @MinNumber(0) + @MaxNumber(1) + @Desc("Boundary erosion strength for ERODED force carving.") + private double erosionStrength = DEFAULT_EROSION_STRENGTH; + + @MinNumber(0.001) + @MaxNumber(1) + @Desc("Boundary noise frequency for ERODED force carving.") + private double erosionFrequency = DEFAULT_EROSION_FREQUENCY; + + @MinNumber(0) + @MaxNumber(1) + @Desc("Low frequency lobe wavelength for ERODED force carving. Zero derives it from the erosion frequency.") + private double lobeFrequency = 0D; + + @MinNumber(0) + @MaxNumber(1) + @Desc("Fraction of the horizontal padding the lobes may remove for ERODED force carving.") + private double lobeStrength = DEFAULT_LOBE_STRENGTH; + + private StructureTerrain() { + } + + private StructureTerrain(StructureTerrain source) { + mode = source.mode(); + horizontalPadding = source.horizontalPadding; + ceilingPadding = source.ceilingPadding; + floorPadding = source.floorPadding; + shape = source.shape(); + encasePalette = source.encasePalette; + erosionStrength = source.erosionStrength; + erosionFrequency = source.erosionFrequency; + lobeFrequency = source.lobeFrequency; + lobeStrength = source.lobeStrength; + } + + /** Terrain fitting in {@code mode} with every other option at its default. */ + public static StructureTerrain of(Mode mode) { + StructureTerrain terrain = new StructureTerrain(); + terrain.mode = Objects.requireNonNull(mode, "mode"); + return terrain; + } + + /** This fitting with clearance around the pieces: sideways, above and below, in blocks. */ + public StructureTerrain withPadding(int horizontal, int ceiling, int floor) { + StructureTerrain terrain = new StructureTerrain(this); + terrain.horizontalPadding = horizontal; + terrain.ceilingPadding = ceiling; + terrain.floorPadding = floor; + return terrain; + } + + public StructureTerrain withShape(Shape shape) { + StructureTerrain terrain = new StructureTerrain(this); + terrain.shape = Objects.requireNonNull(shape, "shape"); + return terrain; + } + + public StructureTerrain withEncasePalette(PaletteSpec palette) { + StructureTerrain terrain = new StructureTerrain(this); + terrain.encasePalette = Objects.requireNonNull(palette, "palette"); + return terrain; + } + + /** This fitting with the erosion of an {@link Shape#ERODED} boundary: its strength and noise frequency. */ + public StructureTerrain withErosion(double strength, double frequency) { + StructureTerrain terrain = new StructureTerrain(this); + terrain.erosionStrength = strength; + terrain.erosionFrequency = frequency; + return terrain; + } + + /** This fitting with the low frequency lobes of an {@link Shape#ERODED} boundary. */ + public StructureTerrain withLobes(double frequency, double strength) { + StructureTerrain terrain = new StructureTerrain(this); + terrain.lobeFrequency = frequency; + terrain.lobeStrength = strength; + return terrain; + } + + /** The terrain operation; {@link Mode#SOURCE} where the pack wrote none or one the host does not know. */ + public Mode mode() { + return mode == null ? Mode.SOURCE : mode; + } + + public int horizontalPadding() { + return horizontalPadding; + } + + public int ceilingPadding() { + return ceilingPadding; + } + + public int floorPadding() { + return floorPadding; + } + + /** The carve shape; {@link Shape#BOX} where the pack wrote none or one the host does not know. */ + public Shape shape() { + return shape == null ? Shape.BOX : shape; + } + + /** The blocks {@link Mode#ENCASE} fills with; empty for the dimension's own stone. */ + public Optional encasePalette() { + return Optional.ofNullable(encasePalette); + } + + /** As the pack wrote it; the host clamps it to 0..1. */ + public double erosionStrength() { + return erosionStrength; + } + + /** As the pack wrote it; the host clamps it to 0.001..1. */ + public double erosionFrequency() { + return erosionFrequency; + } + + /** As the pack wrote it; zero or less lets the host derive it from the erosion frequency. */ + public double lobeFrequency() { + return lobeFrequency; + } + + /** As the pack wrote it; the host clamps it to 0..1. */ + public double lobeStrength() { + return lobeStrength; + } + + @Override + public boolean equals(Object other) { + return other instanceof StructureTerrain that && mode() == that.mode() + && horizontalPadding == that.horizontalPadding && ceilingPadding == that.ceilingPadding + && floorPadding == that.floorPadding && shape() == that.shape() + && Objects.equals(encasePalette, that.encasePalette) + && Double.compare(erosionStrength, that.erosionStrength) == 0 + && Double.compare(erosionFrequency, that.erosionFrequency) == 0 + && Double.compare(lobeFrequency, that.lobeFrequency) == 0 + && Double.compare(lobeStrength, that.lobeStrength) == 0; + } + + @Override + public int hashCode() { + return Objects.hash(mode(), horizontalPadding, ceilingPadding, floorPadding, shape(), encasePalette, + erosionStrength, erosionFrequency, lobeFrequency, lobeStrength); + } + + @Override + public String toString() { + return "StructureTerrain[" + mode() + ", padding " + horizontalPadding + "/" + ceilingPadding + "/" + floorPadding + + ", " + shape() + "]"; + } +} diff --git a/src/main/java/com/volmit/vanilla/VanillaStructureAdjustment.java b/src/main/java/com/volmit/vanilla/VanillaStructureAdjustment.java new file mode 100644 index 000000000..215b88ba1 --- /dev/null +++ b/src/main/java/com/volmit/vanilla/VanillaStructureAdjustment.java @@ -0,0 +1,90 @@ +package com.volmit.vanilla; + +import java.util.Objects; +import java.util.Optional; + +/** What a module changes about the platform's own starts of one structure, the ones the platform places where it + * would on its own: how far they move up or down, a band of world heights to move them into, whether they keep the + * height the platform chose, and how they {@link VanillaStructureFit fit} the terrain. + * + *

Precedence, as the host applies it: keeping the platform's height wins over a band, a band wins over the + * host's own repositioning of buried structures, and the shift applies on top of whichever height results. + * Structures with a fixed platform alignment (an ocean monument's sea level) keep it. + */ +public final class VanillaStructureAdjustment { + /** The platform's starts as the platform makes them. */ + public static final VanillaStructureAdjustment NONE = new VanillaStructureAdjustment(0, null, false, VanillaStructureFit.SOURCE); + + private final int yShift; + private final YBand yBand; + private final boolean keepsSourceY; + private final VanillaStructureFit fit; + + private VanillaStructureAdjustment(int yShift, YBand yBand, boolean keepsSourceY, VanillaStructureFit fit) { + this.yShift = yShift; + this.yBand = yBand; + this.keepsSourceY = keepsSourceY; + this.fit = fit; + } + + /** This adjustment, moving the starts {@code blocks} further up (negative: down). */ + public VanillaStructureAdjustment shifted(int blocks) { + return new VanillaStructureAdjustment(Math.addExact(yShift, blocks), yBand, keepsSourceY, fit); + } + + public VanillaStructureAdjustment withYBand(YBand band) { + return new VanillaStructureAdjustment(yShift, Objects.requireNonNull(band, "band"), keepsSourceY, fit); + } + + /** This adjustment, keeping the height the platform chose instead of the host's repositioning of buried structures. */ + public VanillaStructureAdjustment keepingSourceY() { + return new VanillaStructureAdjustment(yShift, yBand, true, fit); + } + + public VanillaStructureAdjustment withFit(VanillaStructureFit fit) { + return new VanillaStructureAdjustment(yShift, yBand, keepsSourceY, Objects.requireNonNull(fit, "fit")); + } + + /** Blocks the starts move up; negative moves them down. */ + public int yShift() { + return yShift; + } + + public Optional yBand() { + return Optional.ofNullable(yBand); + } + + public boolean keepsSourceY() { + return keepsSourceY; + } + + public VanillaStructureFit fit() { + return fit; + } + + /** Both adjustments applied, {@code later} after this one: shifts add up, keeping the platform's height sticks, and + * a band or a fit part {@code later} states replaces this one's. The host combines the adjustments of several + * modules this way, in module id order. + */ + public VanillaStructureAdjustment then(VanillaStructureAdjustment later) { + return new VanillaStructureAdjustment(Math.addExact(yShift, later.yShift), later.yBand().orElse(yBand), + keepsSourceY || later.keepsSourceY, fit.then(later.fit)); + } + + @Override + public boolean equals(Object other) { + return other instanceof VanillaStructureAdjustment that && yShift == that.yShift + && Objects.equals(yBand, that.yBand) && keepsSourceY == that.keepsSourceY && fit.equals(that.fit); + } + + @Override + public int hashCode() { + return Objects.hash(yShift, yBand, keepsSourceY, fit); + } + + @Override + public String toString() { + return "VanillaStructureAdjustment[shift " + yShift + ", " + yBand().map(Object::toString).orElse("no band") + + (keepsSourceY ? ", source Y" : "") + ", " + fit + "]"; + } +} diff --git a/src/main/java/com/volmit/vanilla/VanillaStructureFit.java b/src/main/java/com/volmit/vanilla/VanillaStructureFit.java new file mode 100644 index 000000000..e711e7cdd --- /dev/null +++ b/src/main/java/com/volmit/vanilla/VanillaStructureFit.java @@ -0,0 +1,59 @@ +package com.volmit.vanilla; + +import java.util.Objects; +import java.util.Optional; + +/** How a platform structure sits in the terrain: the fitting the host does around it before its pieces are placed, + * and the foundation columns it builds under them afterwards. Without a terrain fitting the host replays the + * structure's own ({@link StructureTerrain.Mode#SOURCE}); without stilts it builds none. + */ +public final class VanillaStructureFit { + /** The structure's own terrain adaptation and no stilts. */ + public static final VanillaStructureFit SOURCE = new VanillaStructureFit(null, null); + + private final StructureTerrain terrain; + private final StructureStilts stilts; + + private VanillaStructureFit(StructureTerrain terrain, StructureStilts stilts) { + this.terrain = terrain; + this.stilts = stilts; + } + + public VanillaStructureFit withTerrain(StructureTerrain terrain) { + return new VanillaStructureFit(Objects.requireNonNull(terrain, "terrain"), stilts); + } + + public VanillaStructureFit withStilts(StructureStilts stilts) { + return new VanillaStructureFit(terrain, Objects.requireNonNull(stilts, "stilts")); + } + + public Optional terrain() { + return Optional.ofNullable(terrain); + } + + public Optional stilts() { + return Optional.ofNullable(stilts); + } + + /** This fit with each part {@code later} states replaced by {@code later}'s. */ + public VanillaStructureFit then(VanillaStructureFit later) { + return new VanillaStructureFit(later.terrain().orElse(terrain), later.stilts().orElse(stilts)); + } + + @Override + public boolean equals(Object other) { + return other instanceof VanillaStructureFit that && Objects.equals(terrain, that.terrain) + && Objects.equals(stilts, that.stilts); + } + + @Override + public int hashCode() { + return Objects.hash(terrain, stilts); + } + + @Override + public String toString() { + return "VanillaStructureFit[" + terrain().map(Object::toString).orElse("source terrain") + ", " + + stilts().map(Object::toString).orElse("no stilts") + "]"; + } +} diff --git a/src/main/java/com/volmit/vanilla/VanillaStructureHook.java b/src/main/java/com/volmit/vanilla/VanillaStructureHook.java index beef5d4b1..952f03a4a 100644 --- a/src/main/java/com/volmit/vanilla/VanillaStructureHook.java +++ b/src/main/java/com/volmit/vanilla/VanillaStructureHook.java @@ -1,14 +1,25 @@ package com.volmit.vanilla; import com.volmit.resource.ResourceId; +import java.util.List; /** A module's say over the platform's own structures. Modules register it with - * {@link com.volmit.FeatureRegistry#registerVanillaStructureHook}; the host asks every hook of the pack before the - * platform starts one of its structures in a world, and when it locates one. + * {@link com.volmit.FeatureRegistry#registerVanillaStructureHook}; the host asks every hook of the pack, in module id + * order: * - *

The host asks once per world, structure and pack snapshot and keeps the answer, so a hook decides from the - * pack (its settings and resources) and never from where a start would be. Rules of several modules combine with - * {@link VanillaStructureRule#and}: any module may block the platform's starts. + *

+ * + *

The host asks {@link #rule} and {@link #adjustment} once per world, structure and pack snapshot and keeps the + * answer, so they decide from the pack (its settings and resources) and never from where a start would be. Rules of + * several modules combine with {@link VanillaStructureRule#and}: any module may block the platform's starts. + * Adjustments combine with {@link VanillaStructureAdjustment#then}, setups with {@link VanillaStructureSetup#and}. + * Every method may be called from any thread, concurrently. */ @FunctionalInterface public interface VanillaStructureHook { @@ -16,4 +27,31 @@ public interface VanillaStructureHook { * in the world {@code context} describes. {@link VanillaStructureRule#GENERATE} when the module has no part in it. */ VanillaStructureRule rule(ResourceId structure, VanillaStructureContext context); + + /** What this module changes about the platform's own starts of {@code structure}; {@code underground} says whether + * the platform generates it in one of its underground steps (strongholds, mineshafts, trial chambers, ancient + * cities). {@link VanillaStructureAdjustment#NONE} when the module has no part in it. + */ + default VanillaStructureAdjustment adjustment(ResourceId structure, boolean underground, VanillaStructureContext context) { + return VanillaStructureAdjustment.NONE; + } + + /** The platform structures this module starts in chunk {@code chunkX, chunkZ}: starts the platform generates from + * that chunk, wherever its own placement rules would put them. At most one start per structure and chunk counts; + * the host keeps the first, in module id order. Decided from the world and the chunk only, so the same chunk always + * gets the same starts: the host asks again when it locates structures and when it checks a start it finds in + * the world. + */ + default List starts(int chunkX, int chunkZ, VanillaStructureStartContext context) { + return List.of(); + } + + /** What this module changes about how the platform sets up its structures for the dimension {@code context} + * describes. Protecting the platform's definitions in one dimension protects them in every data pack the host + * installs, since those are shared by every world. {@link VanillaStructureSetup#UNCHANGED} when the module has no + * part in it. + */ + default VanillaStructureSetup setup(VanillaStructureContext context) { + return VanillaStructureSetup.UNCHANGED; + } } diff --git a/src/main/java/com/volmit/vanilla/VanillaStructureSetup.java b/src/main/java/com/volmit/vanilla/VanillaStructureSetup.java new file mode 100644 index 000000000..ba7b467ae --- /dev/null +++ b/src/main/java/com/volmit/vanilla/VanillaStructureSetup.java @@ -0,0 +1,82 @@ +package com.volmit.vanilla; + +import com.volmit.resource.ResourceId; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** What a module changes about how the platform sets up its structures for a dimension, before any world generates: + * how often the structures of a structure set start ({@link #frequency}), and whether data packs the host installs may + * replace the platform's own structure definitions. + */ +public final class VanillaStructureSetup { + /** The platform's structures as their definitions set them up. */ + public static final VanillaStructureSetup UNCHANGED = new VanillaStructureSetup(Map.of(), false); + + private static final double UNCHANGED_FREQUENCY = 1D; + + private final Map frequencies; + private final boolean protectsVanillaDefinitions; + + private VanillaStructureSetup(Map frequencies, boolean protectsVanillaDefinitions) { + this.frequencies = frequencies; + this.protectsVanillaDefinitions = protectsVanillaDefinitions; + } + + /** This setup, starting the structures of {@code structureSet}, such as {@code minecraft:villages}, {@code multiplier} + * times as often (0.01 to 16). A set given twice keeps the later multiplier. + */ + public VanillaStructureSetup withFrequency(ResourceId structureSet, double multiplier) { + Map changed = new HashMap<>(frequencies); + changed.put(Objects.requireNonNull(structureSet, "structureSet"), multiplier); + return new VanillaStructureSetup(Collections.unmodifiableMap(changed), protectsVanillaDefinitions); + } + + /** This setup, keeping the platform's own ({@code minecraft}) structure definitions out of the data packs the host + * installs, so their structures, sets, pools and templates stay as the platform defines them. + */ + public VanillaStructureSetup protectingVanillaDefinitions() { + return new VanillaStructureSetup(frequencies, true); + } + + /** How many times as often the structures of {@code structureSet} start; 1 for a set the setup leaves alone. */ + public double frequency(ResourceId structureSet) { + return frequencies.getOrDefault(structureSet, UNCHANGED_FREQUENCY); + } + + /** Every structure set whose frequency the setup changes, with its multiplier. */ + public Map frequencies() { + return frequencies; + } + + public boolean protectsVanillaDefinitions() { + return protectsVanillaDefinitions; + } + + /** What two modules' setups mean together: frequencies multiply, and the definitions are protected when either + * protects them. The order does not matter. + */ + public VanillaStructureSetup and(VanillaStructureSetup other) { + Map combined = new HashMap<>(frequencies); + other.frequencies.forEach((set, multiplier) -> combined.merge(set, multiplier, (first, second) -> first * second)); + return new VanillaStructureSetup(Collections.unmodifiableMap(combined), + protectsVanillaDefinitions || other.protectsVanillaDefinitions); + } + + @Override + public boolean equals(Object other) { + return other instanceof VanillaStructureSetup that && frequencies.equals(that.frequencies) + && protectsVanillaDefinitions == that.protectsVanillaDefinitions; + } + + @Override + public int hashCode() { + return Objects.hash(frequencies, protectsVanillaDefinitions); + } + + @Override + public String toString() { + return "VanillaStructureSetup[" + frequencies + (protectsVanillaDefinitions ? ", vanilla definitions protected" : "") + "]"; + } +} diff --git a/src/main/java/com/volmit/vanilla/VanillaStructureStart.java b/src/main/java/com/volmit/vanilla/VanillaStructureStart.java new file mode 100644 index 000000000..eea65fcb7 --- /dev/null +++ b/src/main/java/com/volmit/vanilla/VanillaStructureStart.java @@ -0,0 +1,133 @@ +package com.volmit.vanilla; + +import com.volmit.resource.ResourceId; +import java.util.Objects; +import java.util.Optional; + +/** One start of a platform structure a module places: the platform generates the structure, such as + * {@code minecraft:ancient_city}, from the chunk the module chose instead of one it would pick itself. + * + *

A surface start sits on the terrain the platform finds at the chunk; {@link #y()} records the height the module + * planned with. An {@link #underground() underground} start puts the structure's lowest block at {@link #y()}. + * Heights are above the dimension's bottom (0 = bottom). Platform starts of the same structure that already exist in + * the chunk win unless the start {@link #replacesPlatformStart() replaces} them or the structure is + * {@link VanillaStructureRule#REPLACE replaced} by a module. + * + *

{@link #identity()} names what placed the start, stable for one pack: the host records it with every start it + * publishes, so a start found in the world later can be traced back to its placement. + */ +public final class VanillaStructureStart { + private final ResourceId structure; + private final int chunkX; + private final int chunkZ; + private final int y; + private final boolean underground; + private final boolean replacesPlatformStart; + private final long identity; + private final JigsawOverrides jigsaw; + private final VanillaStructureFit fit; + + private VanillaStructureStart(ResourceId structure, int chunkX, int chunkZ, int y, boolean underground, + boolean replacesPlatformStart, long identity, JigsawOverrides jigsaw, + VanillaStructureFit fit) { + this.structure = Objects.requireNonNull(structure, "structure"); + this.chunkX = chunkX; + this.chunkZ = chunkZ; + this.y = y; + this.underground = underground; + this.replacesPlatformStart = replacesPlatformStart; + this.identity = identity; + this.jigsaw = jigsaw; + this.fit = Objects.requireNonNull(fit, "fit"); + } + + /** A surface start of {@code structure} in chunk {@code chunkX, chunkZ}, planned at height {@code y}, with the + * structure's own terrain fitting, its registered definition and identity 0. + */ + public static VanillaStructureStart at(ResourceId structure, int chunkX, int chunkZ, int y) { + return new VanillaStructureStart(structure, chunkX, chunkZ, y, false, false, 0L, null, VanillaStructureFit.SOURCE); + } + + /** This start with the structure's lowest block at {@link #y()} instead of on the surface. */ + public VanillaStructureStart underground() { + return new VanillaStructureStart(structure, chunkX, chunkZ, y, true, replacesPlatformStart, identity, jigsaw, fit); + } + + /** This start, taking the chunk even where the platform already started the structure there. */ + public VanillaStructureStart replacingPlatformStart() { + return new VanillaStructureStart(structure, chunkX, chunkZ, y, underground, true, identity, jigsaw, fit); + } + + public VanillaStructureStart withIdentity(long identity) { + return new VanillaStructureStart(structure, chunkX, chunkZ, y, underground, replacesPlatformStart, identity, jigsaw, fit); + } + + /** This start, assembled with {@code overrides} applied to a jigsaw structure's definition. Only jigsaw structures + * take overrides: the host fails the start of any other structure that has some. + */ + public VanillaStructureStart withJigsaw(JigsawOverrides overrides) { + return new VanillaStructureStart(structure, chunkX, chunkZ, y, underground, replacesPlatformStart, identity, + Objects.requireNonNull(overrides, "overrides"), fit); + } + + public VanillaStructureStart withFit(VanillaStructureFit fit) { + return new VanillaStructureStart(structure, chunkX, chunkZ, y, underground, replacesPlatformStart, identity, jigsaw, fit); + } + + public ResourceId structure() { + return structure; + } + + public int chunkX() { + return chunkX; + } + + public int chunkZ() { + return chunkZ; + } + + /** Height above the dimension's bottom: the structure's lowest block underground, the planned surface otherwise. */ + public int y() { + return y; + } + + public boolean isUnderground() { + return underground; + } + + public boolean replacesPlatformStart() { + return replacesPlatformStart; + } + + public long identity() { + return identity; + } + + /** Changes to the jigsaw definition; empty assembles the registered definition as it is. */ + public Optional jigsaw() { + return Optional.ofNullable(jigsaw); + } + + public VanillaStructureFit fit() { + return fit; + } + + @Override + public boolean equals(Object other) { + return other instanceof VanillaStructureStart that && structure.equals(that.structure) && chunkX == that.chunkX + && chunkZ == that.chunkZ && y == that.y && underground == that.underground + && replacesPlatformStart == that.replacesPlatformStart && identity == that.identity + && Objects.equals(jigsaw, that.jigsaw) && fit.equals(that.fit); + } + + @Override + public int hashCode() { + return Objects.hash(structure, chunkX, chunkZ, y, underground, replacesPlatformStart, identity, jigsaw, fit); + } + + @Override + public String toString() { + return "VanillaStructureStart[" + structure + " at chunk " + chunkX + "," + chunkZ + ", y " + y + + (underground ? ", underground" : "") + (replacesPlatformStart ? ", replacing" : "") + "]"; + } +} diff --git a/src/main/java/com/volmit/vanilla/VanillaStructureStartContext.java b/src/main/java/com/volmit/vanilla/VanillaStructureStartContext.java new file mode 100644 index 000000000..b55aae13c --- /dev/null +++ b/src/main/java/com/volmit/vanilla/VanillaStructureStartContext.java @@ -0,0 +1,13 @@ +package com.volmit.vanilla; + +import com.volmit.world.PackWorld; +import com.volmit.world.TerrainSampler; + +/** The world and chunk a {@link VanillaStructureHook} places starts for. Valid only while the hook runs. */ +public interface VanillaStructureStartContext { + /** The world: its seed, pack resources and settings, and the state modules keep for it. */ + PackWorld world(); + + /** The host's terrain over the chunk and the 8 blocks around it. */ + TerrainSampler terrain(); +} diff --git a/src/main/java/com/volmit/vanilla/YBand.java b/src/main/java/com/volmit/vanilla/YBand.java new file mode 100644 index 000000000..d4cd5ceaa --- /dev/null +++ b/src/main/java/com/volmit/vanilla/YBand.java @@ -0,0 +1,59 @@ +package com.volmit.vanilla; + +import com.volmit.config.Desc; +import com.volmit.config.MaxNumber; +import com.volmit.config.MinNumber; +import java.util.Objects; + +/** A band of absolute world heights a platform structure is moved into, as packs write it: + * {@code {"min": -120, "max": -20}}. Unlike other API heights these are world Y, as the platform's own structure + * definitions use them. Reversed bounds mean the same band. A value the host creates with the no-argument constructor + * and reads the JSON into. + */ +@Desc("An absolute world Y band a native structure is relocated into. Reversed bounds are normalized.") +public final class YBand { + @MinNumber(-4064) + @MaxNumber(4064) + @Desc("Lowest absolute world Y of the band.") + private int min = 0; + + @MinNumber(-4064) + @MaxNumber(4064) + @Desc("Highest absolute world Y of the band.") + private int max = 0; + + private YBand() { + } + + private YBand(int min, int max) { + this.min = min; + this.max = max; + } + + public static YBand of(int min, int max) { + return new YBand(min, max); + } + + public int lowest() { + return Math.min(min, max); + } + + public int highest() { + return Math.max(min, max); + } + + @Override + public boolean equals(Object other) { + return other instanceof YBand that && lowest() == that.lowest() && highest() == that.highest(); + } + + @Override + public int hashCode() { + return Objects.hash(lowest(), highest()); + } + + @Override + public String toString() { + return "YBand[" + lowest() + ".." + highest() + "]"; + } +} diff --git a/src/test/java/com/volmit/VanillaStructureValuesTest.java b/src/test/java/com/volmit/VanillaStructureValuesTest.java new file mode 100644 index 000000000..811cfffdb --- /dev/null +++ b/src/test/java/com/volmit/VanillaStructureValuesTest.java @@ -0,0 +1,133 @@ +package com.volmit; + +import com.volmit.block.BlockSpec; +import com.volmit.block.PaletteSpec; +import com.volmit.config.OptionsMetadata; +import com.volmit.resource.ResourceId; +import com.volmit.vanilla.JigsawOverrides; +import com.volmit.vanilla.StructureStilts; +import com.volmit.vanilla.StructureTerrain; +import com.volmit.vanilla.VanillaStructureAdjustment; +import com.volmit.vanilla.VanillaStructureFit; +import com.volmit.vanilla.VanillaStructureHook; +import com.volmit.vanilla.VanillaStructureRule; +import com.volmit.vanilla.VanillaStructureSetup; +import com.volmit.vanilla.VanillaStructureStart; +import com.volmit.vanilla.YBand; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.OptionalInt; +import static org.junit.jupiter.api.Assertions.*; + +/** The values a vanilla structure hook answers with and how the host combines several modules' answers. */ +class VanillaStructureValuesTest { + private static final ResourceId VILLAGES = ResourceId.parse("minecraft:villages"); + private static final ResourceId CITY = ResourceId.parse("minecraft:ancient_city"); + + @Test + void fitValuesKeepThePacksJsonNamesAndDefaults() { + assertEquals(List.of("mode", "horizontalPadding", "ceilingPadding", "floorPadding", "shape", "encasePalette", + "erosionStrength", "erosionFrequency", "lobeFrequency", "lobeStrength"), names(StructureTerrain.class)); + assertEquals(List.of("maxDepth", "palette", "spacing", "supportNonOccluding"), names(StructureStilts.class)); + assertEquals(List.of("min", "max"), names(YBand.class)); + assertEquals(List.of("startPool", "startJigsawName", "maxDepth", "maxDistanceHorizontal", "maxDistanceVertical", + "useExpansionHack", "projectStartToHeightmap", "dimensionPaddingBottom", "dimensionPaddingTop", + "liquidSettings"), names(JigsawOverrides.class)); + + var terrain = StructureTerrain.of(StructureTerrain.Mode.FORCE_CARVE); + assertEquals(StructureTerrain.Shape.BOX, terrain.shape()); + assertEquals(0.8, terrain.erosionStrength()); + assertEquals(0.07, terrain.erosionFrequency()); + assertEquals(Optional.empty(), terrain.encasePalette()); + var stilts = StructureStilts.of(PaletteSpec.of(List.of(BlockSpec.of("minecraft:cobblestone")))); + assertEquals(64, stilts.maxDepth()); + assertEquals(1, stilts.spacing()); + assertEquals(OptionalInt.empty(), JigsawOverrides.none().maxDepth()); + assertEquals(JigsawOverrides.Heightmap.SOURCE, JigsawOverrides.none().projectStartToHeightmap()); + } + + @Test + void fitValuesAreValuesChangedOnlyThroughWithers() { + var carve = StructureTerrain.of(StructureTerrain.Mode.FORCE_CARVE).withPadding(4, 2, 1) + .withShape(StructureTerrain.Shape.ERODED).withErosion(0.5, 0.1).withLobes(0.2, 0.4); + + assertEquals(carve, StructureTerrain.of(StructureTerrain.Mode.FORCE_CARVE).withShape(StructureTerrain.Shape.ERODED) + .withLobes(0.2, 0.4).withErosion(0.5, 0.1).withPadding(4, 2, 1)); + assertEquals(4, carve.horizontalPadding()); + assertEquals(0.4, carve.lobeStrength()); + assertNotEquals(carve, carve.withPadding(4, 2, 0)); + assertEquals(YBand.of(-20, -120), YBand.of(-120, -20), "reversed bounds are the same band"); + assertEquals(-120, YBand.of(-20, -120).lowest()); + var overrides = JigsawOverrides.none().withStartPool("minecraft:village/plains/town_centers").withMaxDepth(4) + .withMaxDistance(80, 120).withHeightmap(JigsawOverrides.Heightmap.NONE); + assertEquals(OptionalInt.of(4), overrides.maxDepth()); + assertEquals(OptionalInt.of(120), overrides.maxDistanceVertical()); + assertEquals(Optional.empty(), overrides.useExpansionHack()); + assertNotEquals(JigsawOverrides.none(), overrides); + } + + @Test + void adjustmentsAddShiftsAndLetTheLaterBandAndFitPartsWin() { + var stilts = StructureStilts.of(PaletteSpec.of(List.of(BlockSpec.of("stone")))); + var carve = StructureTerrain.of(StructureTerrain.Mode.BORE); + var first = VanillaStructureAdjustment.NONE.shifted(-32).withYBand(YBand.of(-60, -20)) + .withFit(VanillaStructureFit.SOURCE.withStilts(stilts)); + var second = VanillaStructureAdjustment.NONE.shifted(8).keepingSourceY() + .withFit(VanillaStructureFit.SOURCE.withTerrain(carve)); + + var combined = first.then(second); + + assertEquals(-24, combined.yShift()); + assertEquals(Optional.of(YBand.of(-60, -20)), combined.yBand(), "the later adjustment has no band"); + assertTrue(combined.keepsSourceY()); + assertEquals(VanillaStructureFit.SOURCE.withStilts(stilts).withTerrain(carve), combined.fit()); + assertEquals(Optional.of(YBand.of(0, 10)), combined.then(VanillaStructureAdjustment.NONE.withYBand(YBand.of(0, 10))).yBand()); + assertEquals(first, first.then(VanillaStructureAdjustment.NONE), "NONE changes nothing"); + } + + @Test + void setupsMultiplyFrequenciesAndProtectTheDefinitionsWhenEitherDoes() { + var doubled = VanillaStructureSetup.UNCHANGED.withFrequency(VILLAGES, 2); + var protecting = VanillaStructureSetup.UNCHANGED.withFrequency(VILLAGES, 1.5).protectingVanillaDefinitions(); + + assertEquals(3, doubled.and(protecting).frequency(VILLAGES)); + assertEquals(doubled.and(protecting), protecting.and(doubled)); + assertTrue(doubled.and(protecting).protectsVanillaDefinitions()); + assertEquals(1, doubled.frequency(CITY), "a set the setup leaves alone"); + assertEquals(4, doubled.withFrequency(VILLAGES, 4).frequency(VILLAGES), "the later multiplier of one setup wins"); + assertEquals(Map.of(VILLAGES, 2.0), doubled.frequencies()); + } + + @Test + void startsSitOnTheSurfaceWithTheStructuresOwnFitUnlessTheModuleSaysOtherwise() { + var start = VanillaStructureStart.at(CITY, 12, -7, 40); + + assertFalse(start.isUnderground()); + assertFalse(start.replacesPlatformStart()); + assertEquals(VanillaStructureFit.SOURCE, start.fit()); + assertEquals(Optional.empty(), start.jigsaw()); + var underground = start.underground().replacingPlatformStart().withIdentity(-5L) + .withJigsaw(JigsawOverrides.none().withMaxDepth(3)); + assertTrue(underground.isUnderground()); + assertTrue(underground.replacesPlatformStart()); + assertEquals(-5L, underground.identity()); + assertEquals(Optional.of(JigsawOverrides.none().withMaxDepth(3)), underground.jigsaw()); + assertEquals(underground, start.withIdentity(-5L).replacingPlatformStart().underground() + .withJigsaw(JigsawOverrides.none().withMaxDepth(3))); + } + + @Test + void aHookThatOnlyRulesChangesNothingElse() { + VanillaStructureHook hook = (structure, context) -> VanillaStructureRule.BLOCK; + + assertEquals(VanillaStructureAdjustment.NONE, hook.adjustment(CITY, true, null)); + assertEquals(List.of(), hook.starts(0, 0, null)); + assertEquals(VanillaStructureSetup.UNCHANGED, hook.setup(null)); + } + + private static List names(Class type) { + return OptionsMetadata.inspect(type).options().stream().map(OptionsMetadata.Option::name).toList(); + } +}