mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Iris implements the placement facade; the placement stages load from the built-ins jar
IrisPlacement implements ObjectPlacement over the placement's object, IrisObjectPlacement, placer and states (IrisObjectShape, IrisPlacementSettings, IrisPlacementTerrain). The placement modules leave IrisModuleHost and join JAR_MODULE_IDS and BuiltInPack.jarModules(); the new host module iris:placement-settings describes the classes IrisObjectPlacement holds, which a jar module may not. Tests ported; IrisPlacementTest and ObjectSpinKernelTest added.
This commit is contained in:
1 parent
48e328baef
commit
f51ba05ec5
14 files changed
+1078
-54
No files matched your search
@@ -102,7 +102,11 @@ final class IrisBlockRegistry implements BlockRegistry {
|
||||
|
||||
@Override
|
||||
public boolean hasTrait(BlockState state, BlockTrait trait) {
|
||||
PlatformBlockState platform = platformState(state);
|
||||
return hasTrait(platformState(state), trait);
|
||||
}
|
||||
|
||||
/** Whether the platform's {@code state} has {@code trait}. */
|
||||
static boolean hasTrait(PlatformBlockState platform, BlockTrait trait) {
|
||||
return switch (trait) {
|
||||
case AIR -> platform.isAir();
|
||||
case SOLID -> platform.isSolid();
|
||||
|
||||
@@ -28,7 +28,6 @@ import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.modifier.CarveModule;
|
||||
import art.arcane.iris.engine.modifier.DepositModule;
|
||||
import art.arcane.iris.engine.modifier.FloatingModule;
|
||||
import art.arcane.iris.engine.object.placement.PlacementModules;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleLog;
|
||||
@@ -63,7 +62,8 @@ public final class IrisModuleHost {
|
||||
* {@code IrisModule/builtin-modules.txt}) instead of being compiled into Iris. A pack loads them from its {@code modules}
|
||||
* folder, and {@link MissingBuiltInModules} warns when it loads none; a test keeps this equal to the jar's list.
|
||||
*/
|
||||
public static final List<String> JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter");
|
||||
public static final List<String> JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter", "iris:prepare",
|
||||
"iris:anchor", "iris:validate", "iris:bore", "iris:blocks", "iris:stilt", "iris:vacuum", "iris:snow");
|
||||
/** Iris's pack object model: built-in settings may hold these classes, which Iris reads and describes itself. */
|
||||
public static final String HOST_TYPE_PACKAGE = "art.arcane.iris.engine.object";
|
||||
private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"};
|
||||
@@ -76,14 +76,14 @@ public final class IrisModuleHost {
|
||||
return Holder.HOST;
|
||||
}
|
||||
|
||||
/** The modules every pack loads before its own: Iris's own, placement and the chunk generation every world runs. */
|
||||
/** The modules every pack loads before its own: Iris's own and the chunk generation every world runs. */
|
||||
public static List<IrisModule> builtInModules() {
|
||||
return Stream.of(hostModules(), PlacementModules.all(), generationModules()).flatMap(List::stream).toList();
|
||||
return Stream.of(hostModules(), generationModules()).flatMap(List::stream).toList();
|
||||
}
|
||||
|
||||
/** Modules that are Iris itself, not features: they write the layout's platform biomes and record the platform's custom blocks. A pack never replaces them and the built-ins jar does not hold them. */
|
||||
/** Modules that are Iris itself, not features: they write the layout's platform biomes, record the platform's custom blocks and describe the classes Iris's placement settings hold. A pack never replaces them and the built-ins jar does not hold them. */
|
||||
private static List<IrisModule> hostModules() {
|
||||
return List.of(new BiomeModule(), new CustomModule());
|
||||
return List.of(new BiomeModule(), new CustomModule(), new PlacementSettingsModule());
|
||||
}
|
||||
|
||||
private static List<IrisModule> generationModules() {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.placement.ObjectShape;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** An Iris object as the placement stages see it. */
|
||||
final class IrisObjectShape implements ObjectShape {
|
||||
private final IrisObject object;
|
||||
|
||||
IrisObjectShape(IrisObject object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int width() {
|
||||
return object.getW();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int height() {
|
||||
return object.getH();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int depth() {
|
||||
return object.getD();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int centerX() {
|
||||
return object.getCenter().getBlockX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int centerY() {
|
||||
return object.getCenter().getBlockY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int centerZ() {
|
||||
return object.getCenter().getBlockZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String key() {
|
||||
return object.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IrisBlockVector> surfaceSupportOffsets() {
|
||||
return object.getSurfaceSupportOffsets();
|
||||
}
|
||||
}
|
||||
@@ -18,22 +18,40 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.placement.CaveSpace;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.ObjectShape;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.placement.PlaneNoise;
|
||||
import art.arcane.iris.builtin.placement.SurfaceWarp;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.placer.HeightmapObjectPlacer;
|
||||
import art.arcane.iris.engine.object.material.BlockDataMergeSupport;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarveResult;
|
||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.iris.util.project.noise.SimplexNoise;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.world.BlockPosition;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Iris's own inputs of the object placement being run: the placement settings, object, placer and cave
|
||||
* that IrisApi does not describe. Iris's built-in placement stages read them through {@link #current()},
|
||||
* bound on the placing thread while the placement graph runs; pack modules cannot see this class.
|
||||
* Iris's own inputs of the object placement being run: the placement settings, object, placer and cave that IrisApi
|
||||
* does not describe, answered to Iris's built-in placement stages as an {@link ObjectPlacement}, bound on the placing
|
||||
* thread while the placement graph runs. Pack modules cannot see this class.
|
||||
*/
|
||||
public final class IrisPlacement {
|
||||
private static final ScopedValue<IrisPlacement> CURRENT = ScopedValue.newInstance();
|
||||
public final class IrisPlacement implements ObjectPlacement {
|
||||
private static final int NOT_ANCHORED = Integer.MIN_VALUE;
|
||||
|
||||
private final IrisObject object;
|
||||
@@ -46,6 +64,11 @@ public final class IrisPlacement {
|
||||
private final IrisData data;
|
||||
private final PlatformBlockStates states;
|
||||
private final ObjectPlacerEdit edit;
|
||||
private final IrisObjectShape shape;
|
||||
private final IrisPlacementSettings settings;
|
||||
private final IrisPlacementTerrain terrain;
|
||||
private ObjectRotation derivedRotation;
|
||||
private IrisObjectRotation derivedIrisRotation;
|
||||
private int anchorY = NOT_ANCHORED;
|
||||
|
||||
IrisPlacement(IrisObject object, IrisObjectPlacement config, IObjectPlacer placer, CarveResult cave,
|
||||
@@ -60,66 +83,135 @@ public final class IrisPlacement {
|
||||
this.data = data;
|
||||
this.states = states;
|
||||
this.edit = edit;
|
||||
}
|
||||
|
||||
/** The placement running on this thread. */
|
||||
public static IrisPlacement current() {
|
||||
if (!CURRENT.isBound()) {
|
||||
throw new IllegalStateException("No Iris object placement is running on this thread");
|
||||
}
|
||||
return CURRENT.get();
|
||||
this.shape = new IrisObjectShape(object);
|
||||
this.settings = new IrisPlacementSettings(config, data, states);
|
||||
this.terrain = new IrisPlacementTerrain(placer, object.getLoader(), data, states);
|
||||
}
|
||||
|
||||
<T> T runBound(Supplier<T> placement) {
|
||||
return ScopedValue.where(CURRENT, this).call(placement::get);
|
||||
return ObjectPlacement.runBound(this, placement);
|
||||
}
|
||||
|
||||
public IrisObject object() {
|
||||
return object;
|
||||
@Override
|
||||
public ObjectShape object() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
/** The settings as the caller passed them; the built-in preparation may derive others for this placement. */
|
||||
public IrisObjectPlacement config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public IObjectPlacer placer() {
|
||||
return placer;
|
||||
}
|
||||
|
||||
/** The cave the object is placed in, or null outside caves. */
|
||||
public CarveResult cave() {
|
||||
return cave;
|
||||
@Override
|
||||
public PlacementSettings settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/** The height the caller asked for, negative when the placement samples it. */
|
||||
@Override
|
||||
public int requestedY() {
|
||||
return requestedY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public IrisData data() {
|
||||
return data;
|
||||
@Override
|
||||
public Optional<CaveSpace> cave() {
|
||||
return Optional.ofNullable(cave).map(space -> new CaveSpace(space.getSurface(), space.getHeight()));
|
||||
}
|
||||
|
||||
/** Converts block states for this placement. */
|
||||
public PlatformBlockStates states() {
|
||||
return states;
|
||||
@Override
|
||||
public PlacementTerrain terrain() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlacementTerrain terrainFor(RNG rng) {
|
||||
if (config.getHeightmap() == null) {
|
||||
return terrain;
|
||||
}
|
||||
return new IrisPlacementTerrain(new HeightmapObjectPlacer(rng, x, requestedY, z, config, placer), object.getLoader(), data, states);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SurfaceWarp> surfaceWarp(RNG rng) {
|
||||
if (config.getWarp().isFlat()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
CNG warp = config.getSurfaceWarp(rng, object.getLoader());
|
||||
double multiplier = config.getWarp().getMultiplier();
|
||||
return Optional.of(new SurfaceWarp() {
|
||||
@Override
|
||||
public double multiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double fit(double min, double max, double x, double y, double z) {
|
||||
return warp.fitDouble(min, max, x, y, z);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaneNoise simplex(long seed) {
|
||||
SimplexNoise noise = new SimplexNoise(seed);
|
||||
return noise::noiseSigned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, ObjectRotation rotation, int spinX, int spinY, int spinZ) {
|
||||
return states.toApi(irisRotation(rotation).rotate(states.toPlatform(state), spinX, spinY, spinZ));
|
||||
}
|
||||
|
||||
/** The rotation model that turns blocks for the rotation the stages chose, which is the settings' own or one derived from it. */
|
||||
private IrisObjectRotation irisRotation(ObjectRotation rotation) {
|
||||
if (settings.gaveRotation(rotation)) {
|
||||
return settings.irisRotation();
|
||||
}
|
||||
if (rotation != derivedRotation) {
|
||||
IrisObjectRotation converted = new IrisObjectRotation();
|
||||
converted.setEnabled(rotation.enabled());
|
||||
converted.setXAxis(rotation.xAxis());
|
||||
converted.setYAxis(rotation.yAxis());
|
||||
converted.setZAxis(rotation.zAxis());
|
||||
derivedIrisRotation = converted;
|
||||
derivedRotation = rotation;
|
||||
}
|
||||
return derivedIrisRotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState merge(BlockState base, BlockState update) {
|
||||
return states.toApi(BlockDataMergeSupport.merge(states.toPlatform(base), states.toPlatform(update)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(BlockState state, BlockState other) {
|
||||
return states.toPlatform(state).matches(states.toPlatform(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTrait(BlockState state, BlockTrait trait) {
|
||||
return IrisBlockRegistry.hasTrait(states.toPlatform(state), trait);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SpawnMarker> marker(String key) {
|
||||
return Optional.ofNullable(SpawnResources.marker(object.getLoader(), key));
|
||||
}
|
||||
|
||||
/** Reports a buffered write as one of the object's own blocks, which Iris's placement listener hears after the commit. */
|
||||
@Override
|
||||
public void objectBlockWritten(BlockPosition position) {
|
||||
edit.recordObjectBlock(position);
|
||||
}
|
||||
|
||||
/** Reports the height the object was anchored at, which the placement returns to its caller. */
|
||||
@Override
|
||||
public void anchoredAt(int y) {
|
||||
anchorY = y;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.placement.MarkerRule;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.marker.IrisObjectMarker;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** An Iris object placement's settings as the placement stages read them. */
|
||||
final class IrisPlacementSettings implements PlacementSettings {
|
||||
private final IrisObjectPlacement config;
|
||||
private final IrisData data;
|
||||
private final PlatformBlockStates states;
|
||||
private final ObjectRotation rotation;
|
||||
|
||||
IrisPlacementSettings(IrisObjectPlacement config, IrisData data, PlatformBlockStates states) {
|
||||
this.config = config;
|
||||
this.data = data;
|
||||
this.states = states;
|
||||
IrisObjectRotation requested = config.getRotation();
|
||||
this.rotation = ObjectRotation.of(requested.isEnabled(), requested.getXAxis(), requested.getYAxis(), requested.getZAxis());
|
||||
}
|
||||
|
||||
/** The Iris rotation the settings were read from, if {@code rotation} is the one they gave. */
|
||||
boolean gaveRotation(ObjectRotation candidate) {
|
||||
return candidate == rotation;
|
||||
}
|
||||
|
||||
IrisObjectRotation irisRotation() {
|
||||
return config.getRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forcePlace() {
|
||||
return config.isForcePlace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlopeClip slopeCondition() {
|
||||
return config.getSlopeCondition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateTowardsSlope() {
|
||||
return config.isRotateTowardsSlope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectRotation rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectTranslate translate() {
|
||||
IrisObjectTranslate translate = config.getTranslate();
|
||||
return ObjectTranslate.of(translate.getX(), translate.getY(), translate.getYRandom(), translate.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPlaceMode mode() {
|
||||
return config.getMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fromBottom() {
|
||||
return config.isFromBottom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bottom() {
|
||||
return config.isBottom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvingMode carvingSupport() {
|
||||
return config.getCarvingSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean underwater() {
|
||||
return config.isUnderwater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onwater() {
|
||||
return config.isOnwater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireSurfaceSupport() {
|
||||
return config.isRequireSurfaceSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int surfaceSupportBuffer() {
|
||||
return config.getSurfaceSupportBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int surfaceSupportDepth() {
|
||||
return config.getSurfaceSupportDepth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectLimit clamp() {
|
||||
return config.getClamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bore() {
|
||||
return config.isBore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int boreExtendMinY() {
|
||||
return config.getBoreExtendMinY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int boreExtendMaxY() {
|
||||
return config.getBoreExtendMaxY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ObjectReplace> edit() {
|
||||
return config.getEdit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean waterloggable() {
|
||||
return config.isWaterloggable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean meld() {
|
||||
return config.isMeld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MarkerRule> markers() {
|
||||
return config.getMarkers().stream().<MarkerRule>map(marker -> new Marker(marker, data, states)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StiltSettings> stilt() {
|
||||
return Optional.ofNullable(config.getStiltSettings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<VacuumSettings> vacuum() {
|
||||
return Optional.ofNullable(config.getVacuumSettings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double snow() {
|
||||
return config.getSnow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> allowedCollisions() {
|
||||
return config.getAllowedCollisions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> forbiddenCollisions() {
|
||||
return config.getForbiddenCollisions();
|
||||
}
|
||||
|
||||
private static final class Marker implements MarkerRule {
|
||||
private final IrisObjectMarker marker;
|
||||
private final IrisData data;
|
||||
private final PlatformBlockStates states;
|
||||
|
||||
private Marker(IrisObjectMarker marker, IrisData data, PlatformBlockStates states) {
|
||||
this.marker = marker;
|
||||
this.data = data;
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marker() {
|
||||
return marker.getMarker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockState> targets() {
|
||||
return marker.getMark(data).stream().map(states::toApi).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exact() {
|
||||
return marker.isExact();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maximum() {
|
||||
return marker.getMaximumMarkers();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.placement.StructureVolumes;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.NativeStructureVolume;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
/**
|
||||
* An Iris object placer as the placement stages see their terrain. {@code loader} is the object's data, which the placer
|
||||
* reads heights through; {@code data} is the pack data the placement was asked to run with, whose engine knows the
|
||||
* objects already placed.
|
||||
*/
|
||||
final class IrisPlacementTerrain implements PlacementTerrain {
|
||||
private static final StructureVolumes NO_VOLUMES = new StructureVolumes() {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsWithin(int x, int y, int z, int margin) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private final IObjectPlacer placer;
|
||||
private final IrisData loader;
|
||||
private final IrisData data;
|
||||
private final PlatformBlockStates states;
|
||||
|
||||
IrisPlacementTerrain(IObjectPlacer placer, IrisData loader, IrisData data, PlatformBlockStates states) {
|
||||
this.placer = placer;
|
||||
this.loader = loader;
|
||||
this.data = data;
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int highest(int x, int z, boolean ignoreFluid) {
|
||||
return placer.getHighest(x, z, loader, ignoreFluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return placer.isCarved(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSurfaceSolid(int x, int y, int z) {
|
||||
return placer.isSurfaceSolid(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderwater(int x, int z) {
|
||||
return placer.isUnderwater(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fluidHeight() {
|
||||
return placer.getFluidHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preventsDecay() {
|
||||
return placer.isPreventingDecay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean debugsSmartBore() {
|
||||
return placer.isDebugSmartBore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWorld() {
|
||||
return placer.getEngine() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double slopeAt(int x, int z) {
|
||||
return engine().getComplex().getSlopeStream().get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heightAt(double x, double z) {
|
||||
return engine().getComplex().getHeightStream().get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBedrock() {
|
||||
return engine().getDimension().isBedrock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minHeight() {
|
||||
return engine().getMinHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int worldHeight() {
|
||||
return engine().getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rockAt(int x, int z) {
|
||||
Engine engine = engine();
|
||||
if (engine.getComplex() == null) {
|
||||
return PlatformBlockStates.AIR;
|
||||
}
|
||||
return states.toApi(TerrainPalettes.of(engine).rockAt(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVolumes structureVolumes(int minX, int minZ, int maxX, int maxZ) {
|
||||
KList<NativeStructureVolume> volumes = engine().getNativeStructureVolumes(minX, minZ, maxX, maxZ);
|
||||
if (volumes == null || volumes.isEmpty()) {
|
||||
return NO_VOLUMES;
|
||||
}
|
||||
return new NativeVolumes(volumes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String objectKeyAt(int x, int y, int z) {
|
||||
Engine engine = data.getEngine();
|
||||
if (engine == null) {
|
||||
throw new IllegalStateException("Object placement requires active Iris data for collision settings.");
|
||||
}
|
||||
var placed = engine.getObjectPlacement(x, y, z);
|
||||
return placed == null || placed.getObject() == null ? null : placed.getObject().getLoadKey();
|
||||
}
|
||||
|
||||
private Engine engine() {
|
||||
Engine engine = placer.getEngine();
|
||||
if (engine == null) {
|
||||
throw new IllegalStateException("This placement runs without an Iris engine, so it has no world");
|
||||
}
|
||||
return engine;
|
||||
}
|
||||
|
||||
private record NativeVolumes(KList<NativeStructureVolume> volumes) implements StructureVolumes {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
return volumes.stream().anyMatch(volume -> volume.intersects(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsWithin(int x, int y, int z, int margin) {
|
||||
for (NativeStructureVolume volume : volumes) {
|
||||
if (volume.containsWithin(x, y, z, margin)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:placement-settings}: describes the classes an object placement's settings hold, which Iris's own
|
||||
* {@code IrisObjectPlacement} holds as fields. Only a module compiled into Iris may describe such a class, so the
|
||||
* placement stages, which ship in the built-ins jar, cannot. It has no stages and goes when the placement settings move
|
||||
* into a module and nothing of Iris's holds these classes.
|
||||
*/
|
||||
public final class PlacementSettingsModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:placement-settings", "Placement settings", VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerHeldType(SlopeClip.class);
|
||||
registry.registerHeldType(AxisRotationClamp.class);
|
||||
registry.registerHeldType(ObjectLimit.class);
|
||||
registry.registerHeldType(StiltSettings.class);
|
||||
registry.registerHeldType(VacuumSettings.class);
|
||||
registry.registerHeldType(ObjectReplace.class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user