mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
iris:decorant ported onto IrisApi and listed in the built-ins jar; decorate becomes a dimension setting
This commit is contained in:
1 parent
b59538ca6f
commit
3ac31c573b
25 files changed
+778
-653
No files matched your search
@@ -22,3 +22,5 @@ module art.arcane.iris.engine.modifier.DepositModule
|
||||
include art/arcane/iris/engine/modifier/DepositPlacer*.class
|
||||
include art/arcane/iris/engine/modifier/DepositClump*.class
|
||||
include art/arcane/iris/engine/modifier/ResolvedDeposit*.class
|
||||
module art.arcane.iris.engine.actuator.DecorantModule
|
||||
include art/arcane/iris/engine/decorator/**
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.builtin.decorant;
|
||||
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether a dimension decorates at all, written as {@code "decorate": false}. A dimension without the key decorates. */
|
||||
@Desc("Generate decorations or not")
|
||||
@Feature(id = "iris:decorant/decorate", name = "Decorate", key = "decorate", root = "decorate", targets = Target.DIMENSION)
|
||||
public final class DecorateSettings implements IrisFeature {
|
||||
@Desc("Generate decorations or not")
|
||||
private boolean decorate = true;
|
||||
|
||||
public DecorateSettings() {
|
||||
}
|
||||
|
||||
public boolean decorate() {
|
||||
return decorate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.builtin.decorant;
|
||||
|
||||
/** How loaded with decorating a biome is, which studio's decorator load view colours it by. */
|
||||
public final class DecoratorLoad {
|
||||
private static final int COLUMNS_PER_CHUNK = 256;
|
||||
|
||||
private DecoratorLoad() {
|
||||
}
|
||||
|
||||
/** The sum of the decorators' chances times their stack heights, at least one block each; 0 for a biome without decorators. */
|
||||
public static double of(DecorantSettings settings) {
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += Math.max(decorator.stackMax(), 1) * decorator.chance();
|
||||
}
|
||||
return load;
|
||||
}
|
||||
|
||||
/** The sum of the decorators' chances over a chunk's columns, which is how strongly the view colours the biome. */
|
||||
public static double colour(DecorantSettings settings) {
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += decorator.chance() * Math.min(1, decorator.stackMax()) * COLUMNS_PER_CHUNK;
|
||||
}
|
||||
return load;
|
||||
}
|
||||
}
|
||||
@@ -19,40 +19,36 @@
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorateSettings;
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.engine.decorator.DecoratedBiome;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaFloorDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaSurfaceDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisShoreLineDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineDecorator;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLifecycle;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
/**
|
||||
* Module {@code iris:decorant}: the biomes' decorators ({@link DecorantSettings}), placed on the surface the mantle's
|
||||
* blocks left: the surface itself, the sea surface and floor, and the shore line. A dimension turns decorating off with
|
||||
* {@code decorate}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
|
||||
* {@link DecorateSettings}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
|
||||
*/
|
||||
public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
@@ -62,6 +58,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(DecorantSettings.class);
|
||||
registry.registerSettings(DecorateSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
@@ -77,87 +74,62 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
}
|
||||
|
||||
private static void decorate(ChunkStageContext context) {
|
||||
IrisChunk chunk = IrisChunk.current();
|
||||
decorating(context.world()).decorate(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
|
||||
if (!decorates(context)) {
|
||||
return;
|
||||
}
|
||||
decorate(DecorationScene.of(context), context.settings(), context.originX(), context.originZ());
|
||||
}
|
||||
|
||||
/** The world's decorating, kept in its state store. */
|
||||
static Decorating decorating(PackWorld world) {
|
||||
return world.state(Decorating.class, Decorating::new);
|
||||
/** A dimension decorates unless it says {@code decorate: false}. */
|
||||
private static boolean decorates(ChunkStageContext context) {
|
||||
return context.settings().at(DecorateSettings.class, context.originX() + CHUNK_CENTRE, context.originZ() + CHUNK_CENTRE).stream()
|
||||
.allMatch(entry -> entry.value().decorate());
|
||||
}
|
||||
|
||||
/** What decorating keeps for one world: one decorator per kind of place. */
|
||||
static final class Decorating {
|
||||
private static final Predicate<PlatformBlockState> PREDICATE_SOLID = (s) -> s != null && !B.isAirOrFluid(s);
|
||||
/** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
|
||||
static void decorate(DecorationScene scene, FeatureSettings settings, int x, int z) {
|
||||
Hunk<BlockState> output = scene.blocks();
|
||||
TerrainSampler terrain = scene.terrain();
|
||||
BiomeDecorators decorators = scene.decorators();
|
||||
IrisSurfaceDecorator surfaceDecorator = new IrisSurfaceDecorator(scene);
|
||||
IrisSeaSurfaceDecorator seaSurfaceDecorator = new IrisSeaSurfaceDecorator(scene);
|
||||
IrisSeaFloorDecorator seaFloorDecorator = new IrisSeaFloorDecorator(scene);
|
||||
IrisShoreLineDecorator shoreLineDecorator = new IrisShoreLineDecorator(scene);
|
||||
int fluidHeight = scene.fluidHeight();
|
||||
int worldHeight = scene.worldHeight();
|
||||
|
||||
private final Engine engine;
|
||||
private final BiomeDecorators decorators;
|
||||
private final IrisSurfaceDecorator surfaceDecorator;
|
||||
private final EngineDecorator seaSurfaceDecorator;
|
||||
private final EngineDecorator seaFloorDecorator;
|
||||
private final EngineDecorator shoreLineDecorator;
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
int realX = Math.round(x + i);
|
||||
for (int j = 0; j < output.getDepth(); j++) {
|
||||
int realZ = Math.round(z + j);
|
||||
DecoratedBiome biome = BiomeDecorators.biomeOf(settings, realX, realZ, terrain.surfaceKind(realX, realZ));
|
||||
if (!decorators.hasDecorators(biome)) {
|
||||
continue;
|
||||
}
|
||||
int height = (int) Math.round(terrain.surfaceY(realX, realZ));
|
||||
|
||||
Decorating(PackWorld world) {
|
||||
this(IrisPackWorld.of(world).engine());
|
||||
}
|
||||
if (height >= 0 && height < fluidHeight && scene.isSolid(output.get(i, height, j))
|
||||
&& height + 1 < output.getHeight() && scene.isWater(output.get(i, height + 1, j))) {
|
||||
seaSurfaceDecorator.decorate(i, j,
|
||||
realX, Math.round(i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
biome, fluidHeight, worldHeight);
|
||||
seaFloorDecorator.decorate(i, j,
|
||||
realX, realZ, biome, height + 1,
|
||||
fluidHeight + 1);
|
||||
}
|
||||
|
||||
Decorating(Engine engine) {
|
||||
this.engine = engine;
|
||||
decorators = BiomeDecorators.of(engine);
|
||||
surfaceDecorator = new IrisSurfaceDecorator(engine);
|
||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
|
||||
shoreLineDecorator = new IrisShoreLineDecorator(engine);
|
||||
seaFloorDecorator = new IrisSeaFloorDecorator(engine);
|
||||
}
|
||||
if (height == fluidHeight) {
|
||||
shoreLineDecorator.decorate(i, j,
|
||||
realX, Math.round(x + i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
biome, height, worldHeight);
|
||||
}
|
||||
|
||||
/** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
|
||||
@BlockCoordinates
|
||||
void decorate(int x, int z, Hunk<PlatformBlockState> output, ChunkContext context) {
|
||||
if (!engine.getDimension().isDecorate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
int height;
|
||||
int realX = Math.round(x + i);
|
||||
int realZ;
|
||||
IrisBiome biome;
|
||||
for (int j = 0; j < output.getDepth(); j++) {
|
||||
realZ = Math.round(z + j);
|
||||
height = context.getRoundedHeight(i, j);
|
||||
biome = context.getBiome().get(i, j);
|
||||
|
||||
if (!decorators.hasDecorators(biome)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (height < engine.getDimension().getFluidHeight() && PREDICATE_SOLID.test(output.get(i, height, j))
|
||||
&& height + 1 < output.getHeight() && B.isWater(output.get(i, height + 1, j))) {
|
||||
seaSurfaceDecorator.decorate(i, j,
|
||||
realX, Math.round(i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, engine.getDimension().getFluidHeight(), engine.getHeight());
|
||||
seaFloorDecorator.decorate(i, j,
|
||||
realX, realZ, output, biome, height + 1,
|
||||
engine.getDimension().getFluidHeight() + 1);
|
||||
}
|
||||
|
||||
if (height == engine.getDimension().getFluidHeight()) {
|
||||
shoreLineDecorator.decorate(i, j,
|
||||
realX, Math.round(x + i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, height, engine.getHeight());
|
||||
}
|
||||
|
||||
if (height >= 0 && height < output.getHeight()) {
|
||||
surfaceDecorator.decorate(i, j, realX, realZ, output, biome, height, engine.getHeight() - height);
|
||||
}
|
||||
if (height >= 0 && height < output.getHeight()) {
|
||||
surfaceDecorator.decorate(i, j, realX, realZ, biome, height, worldHeight - height);
|
||||
}
|
||||
}
|
||||
|
||||
engine.getMetrics().getDecoration().put(p.getMilliseconds());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,17 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,41 +36,30 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* What the decorant module keeps for one world: the decorators of its biomes made ready ({@link ResolvedDecorator}),
|
||||
* sorted into the places they decorate, and how loaded the busiest biome is. Built from the biomes' {@link DecorantSettings}
|
||||
* when first asked for, or ahead of generation by {@link #warm()}.
|
||||
* What the decorant module keeps for one world: the decorators of its biomes made ready ({@link ResolvedDecorator}), sorted into
|
||||
* the places they decorate. Built from the biomes' {@link DecorantSettings} when first asked for, or ahead of generation by
|
||||
* {@link #warm()}.
|
||||
*
|
||||
* <p>A decorator's noise seed is a function of the world's decorator seed, its biome's key and its place in the biome's
|
||||
* list, so it does not depend on which column or which warm-up reached it first.
|
||||
*/
|
||||
public final class BiomeDecorators {
|
||||
private static final ResolvedDecorator[] NO_DECORATORS = new ResolvedDecorator[0];
|
||||
private static final int COLUMNS_PER_CHUNK = 256;
|
||||
private static final String BIOME_PATH_PREFIX = "biome/";
|
||||
private static final long KEY_SEED_FACTOR = 0x9E3779B97F4A7C15L;
|
||||
private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL;
|
||||
|
||||
private final Engine engine;
|
||||
private final PackWorld world;
|
||||
private final PackResources resources;
|
||||
private final ModuleLog log;
|
||||
private final long decoratorSeed;
|
||||
private final Map<DecorantSettings, Map<DecorationPart, ResolvedDecorator[]>> decorators = new ConcurrentHashMap<>();
|
||||
private volatile Double busiestBiomeLoad;
|
||||
|
||||
/** @param world a world of an Iris engine */
|
||||
BiomeDecorators(PackWorld world) {
|
||||
this(IrisPackWorld.of(world).engine(), world.log());
|
||||
}
|
||||
|
||||
BiomeDecorators(Engine engine) {
|
||||
this(engine, engine.getGeneration().world().log());
|
||||
}
|
||||
|
||||
BiomeDecorators(Engine engine, ModuleLog log) {
|
||||
this.engine = engine;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/** The world {@code engine} generates now. */
|
||||
public static BiomeDecorators of(Engine engine) {
|
||||
return engine.getGeneration().state(BiomeDecorators.class, BiomeDecorators::new);
|
||||
this.world = world;
|
||||
this.resources = world.resources();
|
||||
this.log = world.log();
|
||||
this.decoratorSeed = IrisSeed.DECORATOR.of(world);
|
||||
}
|
||||
|
||||
/** The world's decorators, kept in its state store. */
|
||||
@@ -77,36 +67,51 @@ public final class BiomeDecorators {
|
||||
return world.state(BiomeDecorators.class, BiomeDecorators::new);
|
||||
}
|
||||
|
||||
/** The key of the biome a settings entry was declared by, such as {@code desert/dunes} for {@code overworld:biome/desert/dunes}. */
|
||||
public static String biomeKey(ResourceId source) {
|
||||
String path = source.path();
|
||||
return path.startsWith(BIOME_PATH_PREFIX) ? path.substring(BIOME_PATH_PREFIX.length()) : path;
|
||||
}
|
||||
|
||||
/** The biome of the entry a column's settings gave, which is the column's surface biome; null when the biome declares nothing. */
|
||||
public static DecoratedBiome biomeOf(FeatureSettings settings, int worldX, int worldZ, com.volmit.world.BiomeKind kind) {
|
||||
List<Entry<DecorantSettings>> entries = settings.at(DecorantSettings.class, worldX, worldZ);
|
||||
if (entries.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Entry<DecorantSettings> entry = entries.getLast();
|
||||
return new DecoratedBiome(biomeKey(entry.source()), entry.value(), kind);
|
||||
}
|
||||
|
||||
/** The log of the module that decorates, which the decorators write to. */
|
||||
ModuleLog log() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/** Whether the biome declares any decorator. */
|
||||
public boolean hasDecorators(IrisBiome biome) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
return settings != null && !settings.decorators().isEmpty();
|
||||
public boolean hasDecorators(DecoratedBiome biome) {
|
||||
return biome != null && biome.settings() != null && !biome.settings().decorators().isEmpty();
|
||||
}
|
||||
|
||||
/** The biome's decorators for {@code part}, in the order the biome lists them. */
|
||||
ResolvedDecorator[] decorators(IrisBiome biome, DecorationPart part) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
if (settings == null) {
|
||||
ResolvedDecorator[] decorators(DecoratedBiome biome, DecorationPart part) {
|
||||
if (biome == null || biome.settings() == null) {
|
||||
return NO_DECORATORS;
|
||||
}
|
||||
return decorators.computeIfAbsent(settings, declared -> resolve(biome.getLoadKey(), declared)).getOrDefault(part, NO_DECORATORS);
|
||||
return decorators.computeIfAbsent(biome.settings(), declared -> resolve(biome.key(), declared)).getOrDefault(part, NO_DECORATORS);
|
||||
}
|
||||
|
||||
/** Whether the biome has a decorator for {@code part}. */
|
||||
public boolean hasDecorators(IrisBiome biome, DecorationPart part) {
|
||||
public boolean hasDecorators(DecoratedBiome biome, DecorationPart part) {
|
||||
return decorators(biome, part).length > 0;
|
||||
}
|
||||
|
||||
/** Resolves every decorator of every biome the dimension reaches and builds its noise, so that generation finds them ready. */
|
||||
public void warm() {
|
||||
List<IrisBiome> biomes = engine.getAllBiomes();
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
List<Entry<DecorantSettings>> declared = new ArrayList<>(world.settings().declared(DecorantSettings.class));
|
||||
declared.sort(Comparator.comparing(entry -> biomeKey(entry.source())));
|
||||
for (Entry<DecorantSettings> entry : declared) {
|
||||
DecoratedBiome biome = new DecoratedBiome(biomeKey(entry.source()), entry.value(), null);
|
||||
for (DecorationPart part : DecorationPart.values()) {
|
||||
for (ResolvedDecorator decorator : decorators(biome, part)) {
|
||||
decorator.warm();
|
||||
@@ -115,53 +120,6 @@ public final class BiomeDecorators {
|
||||
}
|
||||
}
|
||||
|
||||
/** The most decorating any reachable biome does, as the sum of its decorators' chances times their stack heights. */
|
||||
public double busiestBiomeLoad() {
|
||||
Double cached = busiestBiomeLoad;
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
double busiest = 0D;
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
busiest = Math.max(busiest, load(biome));
|
||||
}
|
||||
busiestBiomeLoad = busiest;
|
||||
return busiest;
|
||||
}
|
||||
|
||||
/** How loaded the biome is with decorators: the sum of their chances times their stack heights, at least one block each. */
|
||||
public double load(IrisBiome biome) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += Math.max(decorator.stackMax(), 1) * decorator.chance();
|
||||
}
|
||||
return load;
|
||||
}
|
||||
|
||||
/** How strongly studio's decorator load view colours the biome: the sum of its decorators' chances over a chunk's columns. */
|
||||
public double colourLoad(IrisBiome biome) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += decorator.chance() * Math.min(1, decorator.stackMax()) * COLUMNS_PER_CHUNK;
|
||||
}
|
||||
return load;
|
||||
}
|
||||
|
||||
private static DecorantSettings settingsOf(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(DecorantSettings.class).orElse(null);
|
||||
}
|
||||
|
||||
private Map<DecorationPart, ResolvedDecorator[]> resolve(String biomeKey, DecorantSettings settings) {
|
||||
Map<DecorationPart, List<ResolvedDecorator>> staging = new EnumMap<>(DecorationPart.class);
|
||||
List<Decorator> declared = settings.decorators();
|
||||
@@ -170,7 +128,7 @@ public final class BiomeDecorators {
|
||||
if (decorator == null) {
|
||||
continue;
|
||||
}
|
||||
ResolvedDecorator resolved = ResolvedDecorator.of(decorator, engine, decoratorSeed(biomeKey, index), log);
|
||||
ResolvedDecorator resolved = ResolvedDecorator.of(decorator, resources, seedOf(biomeKey, index), log, biomeKey);
|
||||
staging.computeIfAbsent(decorator.partOf(), part -> new ArrayList<>()).add(resolved);
|
||||
}
|
||||
|
||||
@@ -179,7 +137,7 @@ public final class BiomeDecorators {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
private long decoratorSeed(String biomeKey, int index) {
|
||||
return engine.getSeedManager().getDecorator() + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
|
||||
private long seedOf(String biomeKey, int index) {
|
||||
return decoratorSeed + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import com.volmit.world.BiomeKind;
|
||||
|
||||
/**
|
||||
* A biome as the decorators see it: the key the pack names it by, which seeds its decorators' noise, the decorators it declares
|
||||
* (none when it declares no {@link DecorantSettings}) and what it was generated as.
|
||||
*/
|
||||
public record DecoratedBiome(String key, DecorantSettings settings, BiomeKind kind) {
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Everything the decorators of one chunk look at: its blocks, the blocks the mantle planned around it, the terrain, the pack's
|
||||
* block rules and the biomes' decorators. A decorator places into {@link #blocks()} only. What it asks of a block is asked
|
||||
* once for each distinct block instance, since a chunk holds few.
|
||||
*/
|
||||
public final class DecorationScene {
|
||||
private final Hunk<BlockState> blocks;
|
||||
private final BlockRegistry registry;
|
||||
private final TerrainSampler terrain;
|
||||
private final MantleLayer<BlockState> planned;
|
||||
private final BiomeDecorators decorators;
|
||||
private final long seed;
|
||||
private final ModuleLog log;
|
||||
private final Map<BlockTrait, Map<BlockState, Boolean>> traits = new EnumMap<>(BlockTrait.class);
|
||||
private final Map<BlockState, Map<BlockState, Boolean>> supports = new IdentityHashMap<>();
|
||||
|
||||
/** The chunk of {@code context}, decorated with the world's decorators. */
|
||||
public static DecorationScene of(ChunkStageContext context) {
|
||||
Mantle mantle = context.mantle();
|
||||
return new DecorationScene(context.hunk(BlockState.class), context.resources().blocks(), context.terrain(),
|
||||
mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), IrisSeed.COMPONENT.of(context.world()),
|
||||
context.log());
|
||||
}
|
||||
|
||||
public DecorationScene(Hunk<BlockState> blocks, BlockRegistry registry, TerrainSampler terrain, MantleLayer<BlockState> planned,
|
||||
BiomeDecorators decorators, long seed, ModuleLog log) {
|
||||
this.blocks = blocks;
|
||||
this.registry = registry;
|
||||
this.terrain = terrain;
|
||||
this.planned = planned;
|
||||
this.decorators = decorators;
|
||||
this.seed = seed;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public Hunk<BlockState> blocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public BlockRegistry registry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
public TerrainSampler terrain() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
public BiomeDecorators decorators() {
|
||||
return decorators;
|
||||
}
|
||||
|
||||
/** The seed the decorators of every place draw from, each shifted by its own part. */
|
||||
long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
ModuleLog log() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/** The height of the chunk's volume. */
|
||||
public int worldHeight() {
|
||||
return blocks.getHeight();
|
||||
}
|
||||
|
||||
public int fluidHeight() {
|
||||
return terrain.fluidHeight();
|
||||
}
|
||||
|
||||
/** The slope of the terrain at the column. */
|
||||
double slopeAt(int worldX, int worldZ) {
|
||||
return terrain.column(worldX, worldZ).slope();
|
||||
}
|
||||
|
||||
/** The height of the terrain at the column, rounded. */
|
||||
long roundedHeightAt(int worldX, int worldZ) {
|
||||
return Math.round(terrain.surfaceY(worldX, worldZ));
|
||||
}
|
||||
|
||||
/** The block a placement planned at the position, or air; positions the mantle does not cover read as air. */
|
||||
BlockState plannedAt(int worldX, int y, int worldZ) {
|
||||
if (planned == null || y < 0 || y >= worldHeight()) {
|
||||
return null;
|
||||
}
|
||||
return planned.get(worldX, y, worldZ);
|
||||
}
|
||||
|
||||
boolean has(BlockTrait trait, BlockState block) {
|
||||
return traits.computeIfAbsent(trait, ignored -> new IdentityHashMap<>())
|
||||
.computeIfAbsent(block, known -> registry.hasTrait(known, trait));
|
||||
}
|
||||
|
||||
public boolean isAir(BlockState block) {
|
||||
return has(BlockTrait.AIR, block);
|
||||
}
|
||||
|
||||
public boolean isFluid(BlockState block) {
|
||||
return has(BlockTrait.FLUID, block);
|
||||
}
|
||||
|
||||
public boolean isSolid(BlockState block) {
|
||||
return has(BlockTrait.SOLID, block);
|
||||
}
|
||||
|
||||
public boolean isWater(BlockState block) {
|
||||
return has(BlockTrait.WATER, block);
|
||||
}
|
||||
|
||||
/** Whether {@code decoration} may stand on {@code surface}: its kind of block on that kind of block, and the surface carries a block on its top face. */
|
||||
boolean canGoOn(BlockState decoration, BlockState surface) {
|
||||
return supports.computeIfAbsent(decoration, ignored -> new IdentityHashMap<>())
|
||||
.computeIfAbsent(surface, known -> registry.canPlaceOn(decoration, known)
|
||||
&& registry.canAttach(decoration, known, com.volmit.block.BlockFace.UP));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,35 +15,41 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockState;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.ModuleLog;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockSupport;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
import com.volmit.block.BlockFace;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
final class DecoratorCore {
|
||||
|
||||
private static final long SEED_OFFSET = 29356788L;
|
||||
private static final long PART_FACTOR = 10439677L;
|
||||
private static final String WEEPING_VINES = "minecraft:weeping_vines";
|
||||
private static final String WEEPING_VINES_PLANT = "minecraft:weeping_vines_plant";
|
||||
private static final String TWISTING_VINES = "minecraft:twisting_vines";
|
||||
private static final String TWISTING_VINES_PLANT = "minecraft:twisting_vines_plant";
|
||||
private static volatile PlatformBlockState weepingVines;
|
||||
private static volatile PlatformBlockState weepingVinesPlant;
|
||||
private static volatile PlatformBlockState twistingVines;
|
||||
private static volatile PlatformBlockState twistingVinesPlant;
|
||||
private static final String HALF = "half";
|
||||
private static final ResourceId WEEPING_VINES = ResourceId.parse("minecraft:weeping_vines");
|
||||
private static final ResourceId WEEPING_VINES_PLANT = ResourceId.parse("minecraft:weeping_vines_plant");
|
||||
private static final ResourceId TWISTING_VINES = ResourceId.parse("minecraft:twisting_vines");
|
||||
private static final ResourceId TWISTING_VINES_PLANT = ResourceId.parse("minecraft:twisting_vines_plant");
|
||||
private static final ResourceId POINTED_DRIPSTONE = ResourceId.parse("minecraft:pointed_dripstone");
|
||||
private static final String[] DRIPSTONE_THICKNESS = {"tip", "frustum", "base"};
|
||||
private static final BlockState[] DRIPSTONE_UP = dripstones("up");
|
||||
private static final BlockState[] DRIPSTONE_DOWN = dripstones("down");
|
||||
private static final BlockState AIR = new BlockState("minecraft:air");
|
||||
/** The faces a vine can grow on, in the order Iris looks at them, with the neighbour each faces. */
|
||||
private static final List<Face> FACES = List.of(new Face(BlockFace.NORTH, "north", 0, 0, -1), new Face(BlockFace.EAST, "east", 1, 0, 0),
|
||||
new Face(BlockFace.SOUTH, "south", 0, 0, 1), new Face(BlockFace.WEST, "west", -1, 0, 0), new Face(BlockFace.UP, "up", 0, 1, 0),
|
||||
new Face(BlockFace.DOWN, "down", 0, -1, 0));
|
||||
private static final Map<BlockFace, BlockFace> OPPOSITES = Map.of(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH, BlockFace.NORTH,
|
||||
BlockFace.EAST, BlockFace.WEST, BlockFace.WEST, BlockFace.EAST, BlockFace.UP, BlockFace.DOWN, BlockFace.DOWN, BlockFace.UP);
|
||||
private static final int CHUNK_LAST = 15;
|
||||
|
||||
static final ThreadLocal<PlaceOpts> SCRATCH_OPTS = ThreadLocal.withInitial(PlaceOpts::new);
|
||||
|
||||
@@ -59,6 +65,9 @@ final class DecoratorCore {
|
||||
}
|
||||
}
|
||||
|
||||
private record Face(BlockFace face, String property, int dx, int dy, int dz) {
|
||||
}
|
||||
|
||||
static long partSeed(long baseSeed, int partOrdinal) {
|
||||
return baseSeed + SEED_OFFSET - (partOrdinal * PART_FACTOR);
|
||||
}
|
||||
@@ -96,77 +105,75 @@ final class DecoratorCore {
|
||||
return half.equals("upper") || half.equals("lower") ? "lower" : "bottom";
|
||||
}
|
||||
|
||||
static void placeSurfaceSingle(ResolvedDecorator decorator,
|
||||
static void placeSurfaceSingle(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int x, int z, int realX, int height, int realZ,
|
||||
Hunk<PlatformBlockState> data,
|
||||
boolean underwater, boolean caveSkipFluid, EngineMantle mantle, ModuleLog log) {
|
||||
boolean underwater, boolean caveSkipFluid) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState bdx = data.get(x, height, z);
|
||||
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
|
||||
BlockState bdx = data.get(x, height, z);
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
|
||||
if (!underwater && !canGoOn(bd, bdx)
|
||||
if (!underwater && !canGoOn(scene, bd, bdx)
|
||||
&& !decorator.isForcePlace() && decorator.forceBlock() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decorator.forceBlock() != null) {
|
||||
if (caveSkipFluid && B.isFluid(bdx)) {
|
||||
if (caveSkipFluid && scene.isFluid(bdx)) {
|
||||
return;
|
||||
}
|
||||
data.set(x, height, z, fixFacesForHunk(
|
||||
decorator.forceBlock(), data, x, z, realX, height, realZ, mantle));
|
||||
data.set(x, height, z, fixFacesForHunk(scene, decorator.forceBlock(), x, z, realX, height, realZ));
|
||||
}
|
||||
|
||||
if (!decorator.isForcePlace() && decorator.rejectsSurface(bdx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String half = bd == null ? null : IrisProceduralBlocks.propertyValue(bd, "half");
|
||||
String half = bd == null ? null : bd.properties().get(HALF);
|
||||
if (half != null) {
|
||||
int lowerY = height + 1;
|
||||
int upperY = height + 2;
|
||||
if (!canPlaceTwoBlockPlant(data, x, z, lowerY, upperY, caveSkipFluid)) {
|
||||
if (!canPlaceTwoBlockPlant(scene, x, z, lowerY, upperY, caveSkipFluid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
PlatformBlockState upper = bd.withProperty("half", topHalfValue(half));
|
||||
PlatformBlockState lower = fixFacesForHunk(
|
||||
bd.withProperty("half", bottomHalfValue(half)),
|
||||
data, x, z, realX, lowerY, realZ, mantle);
|
||||
BlockState upper = bd.withProperty(HALF, topHalfValue(half));
|
||||
BlockState lower = fixFacesForHunk(scene,
|
||||
bd.withProperty(HALF, bottomHalfValue(half)),
|
||||
x, z, realX, lowerY, realZ);
|
||||
data.set(x, lowerY, z, lower);
|
||||
data.set(x, upperY, z, upper);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to place a two-block plant", e);
|
||||
scene.log().error("Failed to place a two-block plant", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int targetY = height + 1;
|
||||
if (targetY < data.getHeight() && B.isAir(data.get(x, targetY, z))) {
|
||||
data.set(x, targetY, z, fixFacesForHunk(bd, data, x, z, realX, targetY, realZ, mantle));
|
||||
if (bd != null && targetY < data.getHeight() && scene.isAir(data.get(x, targetY, z))) {
|
||||
data.set(x, targetY, z, fixFacesForHunk(scene, bd, x, z, realX, targetY, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
static void placeSingleAt(ResolvedDecorator decorator, int x, int z,
|
||||
int realX, int height, int realZ, Hunk<PlatformBlockState> data,
|
||||
boolean applyFixFaces, EngineMantle mantle) {
|
||||
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
|
||||
static void placeSingleAt(ResolvedDecorator decorator, DecorationScene scene, int x, int z,
|
||||
int realX, int height, int realZ, boolean applyFixFaces) {
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
if (applyFixFaces) {
|
||||
bd = fixFacesForHunk(bd, data, x, z, realX, height, realZ, mantle);
|
||||
bd = fixFacesForHunk(scene, bd, x, z, realX, height, realZ);
|
||||
}
|
||||
data.set(x, height, z, bd);
|
||||
scene.blocks().set(x, height, z, bd);
|
||||
}
|
||||
|
||||
static void placeStackUp(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data,
|
||||
PlaceOpts opts) {
|
||||
static void placeStackUp(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
|
||||
int height, int max, PlaceOpts opts) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
@@ -184,14 +191,14 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState existing = data.get(x, targetY, z);
|
||||
if (!canReplaceStackTarget(existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && B.isFluid(existing))) {
|
||||
BlockState existing = data.get(x, targetY, z);
|
||||
if (!canReplaceStackTarget(scene, existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && scene.isFluid(existing))) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null || (!opts.underwater && !canGoOn(block, data.get(x, height, z)))) {
|
||||
BlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null || (!opts.underwater && !canGoOn(scene, block, data.get(x, height, z)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -200,12 +207,11 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState bdx = data.get(x, height, z);
|
||||
BlockState bdx = data.get(x, height, z);
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
PlatformBlockState bd = threshold >= decorator.topThreshold()
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
|
||||
@@ -213,7 +219,7 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0 && !opts.underwater && !canGoOn(bd, bdx)) {
|
||||
if (i == 0 && !opts.underwater && !canGoOn(scene, bd, bdx)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -225,14 +231,14 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
|
||||
PlatformBlockState existing = data.get(x, height + 1 + i, z);
|
||||
if (!canReplaceStackTarget(existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && B.isFluid(existing))) {
|
||||
BlockState existing = data.get(x, height + 1 + i, z);
|
||||
if (!canReplaceStackTarget(scene, existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && scene.isFluid(existing))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IrisProceduralBlocks.materialKey(bd).equals("minecraft:pointed_dripstone")) {
|
||||
bd = dripstoneBlock(stack, i, "up");
|
||||
if (bd.material().equals(POINTED_DRIPSTONE)) {
|
||||
bd = dripstoneBlock(stack, i, DRIPSTONE_UP);
|
||||
}
|
||||
|
||||
bd = stackedVineBlock(bd, stack, i);
|
||||
@@ -240,9 +246,9 @@ final class DecoratorCore {
|
||||
}
|
||||
}
|
||||
|
||||
static void placeStackDown(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int minHeight, Hunk<PlatformBlockState> data,
|
||||
int max, PlaceOpts opts, EngineMantle mantle) {
|
||||
static void placeStackDown(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
|
||||
int height, int minHeight, int max, PlaceOpts opts) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
@@ -250,15 +256,15 @@ final class DecoratorCore {
|
||||
int stack = computeStack(decorator, realX, realZ, max);
|
||||
|
||||
if (stack == 1) {
|
||||
if (opts.caveSkipFluid && B.isFluid(data.get(x, height, z))) {
|
||||
if (opts.caveSkipFluid && scene.isFluid(data.get(x, height, z))) {
|
||||
return;
|
||||
}
|
||||
PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
BlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
block = stackedVineBlock(block, stack, 0);
|
||||
data.set(x, height, z, fixFacesForHunk(block, data, x, z, realX, height, realZ, mantle));
|
||||
data.set(x, height, z, fixFacesForHunk(scene, block, x, z, realX, height, realZ));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,7 +275,7 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
double threshold = ((double) i) / (double) (stack - 1);
|
||||
PlatformBlockState bd = threshold >= decorator.topThreshold()
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
|
||||
@@ -277,41 +283,42 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IrisProceduralBlocks.materialKey(bd).equals("minecraft:pointed_dripstone")) {
|
||||
bd = dripstoneBlock(stack, i, "down");
|
||||
if (bd.material().equals(POINTED_DRIPSTONE)) {
|
||||
bd = dripstoneBlock(stack, i, DRIPSTONE_DOWN);
|
||||
}
|
||||
|
||||
bd = stackedVineBlock(bd, stack, i);
|
||||
if (opts.caveSkipFluid && B.isFluid(data.get(x, h, z))) {
|
||||
if (opts.caveSkipFluid && scene.isFluid(data.get(x, h, z))) {
|
||||
break;
|
||||
}
|
||||
data.set(x, h, z, fixFacesForHunk(bd, data, x, z, realX, h, realZ, mantle));
|
||||
data.set(x, h, z, fixFacesForHunk(scene, bd, x, z, realX, h, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
static void placeFloatingSimple(ResolvedDecorator decorator,
|
||||
static void placeFloatingSimple(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data, ModuleLog log) {
|
||||
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
|
||||
int height, int max) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String half = IrisProceduralBlocks.propertyValue(bd, "half");
|
||||
String half = bd.properties().get(HALF);
|
||||
if (half != null) {
|
||||
int lowerY = height + 1;
|
||||
int upperY = height + 2;
|
||||
if (max <= 2 || !canPlaceTwoBlockPlant(data, xf, zf, lowerY, upperY, false)) {
|
||||
if (max <= 2 || !canPlaceTwoBlockPlant(scene, xf, zf, lowerY, upperY, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
PlatformBlockState upper = bd.withProperty("half", topHalfValue(half));
|
||||
PlatformBlockState lower = bd.withProperty("half", bottomHalfValue(half));
|
||||
BlockState upper = bd.withProperty(HALF, topHalfValue(half));
|
||||
BlockState lower = bd.withProperty(HALF, bottomHalfValue(half));
|
||||
data.set(xf, lowerY, zf, lower);
|
||||
data.set(xf, upperY, zf, upper);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to place a two-block plant", e);
|
||||
scene.log().error("Failed to place a two-block plant", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -321,9 +328,10 @@ final class DecoratorCore {
|
||||
}
|
||||
}
|
||||
|
||||
static int placeFloatingStacked(ResolvedDecorator decorator,
|
||||
static int placeFloatingStacked(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data) {
|
||||
int height, int max) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
int stack = decorator.stackHeight(realX, realZ);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.absoluteMaxStack());
|
||||
@@ -338,7 +346,7 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
double threshold = stack == 1 ? 0.0 : ((double) i) / (stack - 1);
|
||||
PlatformBlockState bd = threshold >= decorator.topThreshold()
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
@@ -351,94 +359,85 @@ final class DecoratorCore {
|
||||
return placed;
|
||||
}
|
||||
|
||||
static PlatformBlockState fixFacesForHunk(PlatformBlockState b, Hunk<PlatformBlockState> hunk, int rX, int rZ,
|
||||
int x, int y, int z, EngineMantle mantle) {
|
||||
if (!B.isVineBlock(b)) {
|
||||
/**
|
||||
* A vine placed at {@code x}, {@code y}, {@code z} (the chunk's local column {@code rX}, {@code rZ}) faces the neighbours that
|
||||
* can hold it: the blocks the mantle planned there, else the chunk's own blocks. A vine with no such neighbour faces down,
|
||||
* or up when it cannot face down. Any other block is returned as it is.
|
||||
*/
|
||||
static BlockState fixFacesForHunk(DecorationScene scene, BlockState b, int rX, int rZ, int x, int y, int z) {
|
||||
if (b == null || !scene.has(BlockTrait.VINE, b)) {
|
||||
return b;
|
||||
}
|
||||
DecoratorPlatformHooks.FaceFixer fixer = DecoratorPlatformHooks.faceFixer();
|
||||
if (fixer != null) {
|
||||
return fixer.fixFaces(b, hunk, rX, rZ, x, y, z, mantle);
|
||||
Hunk<BlockState> hunk = scene.blocks();
|
||||
BlockState fixed = b;
|
||||
for (Face face : FACES) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
fixed = fixed.withProperty(face.property(), "false");
|
||||
}
|
||||
}
|
||||
BlockData rawB = (BlockData) b.nativeHandle();
|
||||
BlockData cloned = rawB.clone();
|
||||
MultipleFacing data = (MultipleFacing) cloned;
|
||||
data.getFaces().forEach(f -> data.setFace(f, false));
|
||||
|
||||
boolean found = false;
|
||||
for (BlockFace f : BlockFace.values()) {
|
||||
if (!f.isCartesian()) {
|
||||
continue;
|
||||
}
|
||||
int yy = y + f.getModY();
|
||||
for (Face face : FACES) {
|
||||
int yy = y + face.dy();
|
||||
BlockFace opposite = OPPOSITES.get(face.face());
|
||||
|
||||
PlatformBlockState rs = null;
|
||||
if (mantle != null) {
|
||||
rs = mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), PlatformBlockState.class);
|
||||
}
|
||||
BlockData r = rs == null ? (BlockData) EngineMantle.AIR.nativeHandle() : (BlockData) rs.nativeHandle();
|
||||
if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
|
||||
if (data.getAllowedFaces().contains(f)) {
|
||||
BlockState planned = scene.plannedAt(x + face.dx(), yy, z + face.dz());
|
||||
BlockState support = planned == null ? AIR : planned;
|
||||
if (scene.registry().canAttach(b, support, opposite)) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
found = true;
|
||||
data.setFace(f, true);
|
||||
fixed = fixed.withProperty(face.property(), "true");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int xx = rX + f.getModX();
|
||||
int zz = rZ + f.getModZ();
|
||||
if (xx < 0 || xx > 15 || zz < 0 || zz > 15 || yy < 0 || yy >= hunk.getHeight()) {
|
||||
int xx = rX + face.dx();
|
||||
int zz = rZ + face.dz();
|
||||
if (xx < 0 || xx > CHUNK_LAST || zz < 0 || zz > CHUNK_LAST || yy < 0 || yy >= hunk.getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
r = (BlockData) hunk.get(xx, yy, zz).nativeHandle();
|
||||
if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
|
||||
if (data.getAllowedFaces().contains(f)) {
|
||||
if (scene.registry().canAttach(b, hunk.get(xx, yy, zz), opposite)) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
found = true;
|
||||
data.setFace(f, true);
|
||||
fixed = fixed.withProperty(face.property(), "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
BlockFace fallback = data.getAllowedFaces().contains(BlockFace.DOWN) ? BlockFace.DOWN : BlockFace.UP;
|
||||
if (data.getAllowedFaces().contains(fallback)) {
|
||||
data.setFace(fallback, true);
|
||||
String fallback = b.properties().containsKey("down") ? "down" : "up";
|
||||
if (b.properties().containsKey(fallback)) {
|
||||
fixed = fixed.withProperty(fallback, "true");
|
||||
}
|
||||
}
|
||||
return BukkitBlockState.of(cloned);
|
||||
return fixed;
|
||||
}
|
||||
|
||||
static boolean canGoOn(PlatformBlockState decorator, PlatformBlockState surface) {
|
||||
if (!B.canPlaceOnto(decorator, surface)) {
|
||||
return false;
|
||||
}
|
||||
DecoratorPlatformHooks.SurfaceSturdiness sturdiness = DecoratorPlatformHooks.surfaceSturdiness();
|
||||
if (sturdiness != null) {
|
||||
return sturdiness.canGoOn(surface);
|
||||
}
|
||||
return ((BlockData) surface.nativeHandle()).isFaceSturdy(BlockFace.UP, BlockSupport.FULL);
|
||||
static boolean canGoOn(DecorationScene scene, BlockState decorator, BlockState surface) {
|
||||
return decorator != null && surface != null && scene.canGoOn(decorator, surface);
|
||||
}
|
||||
|
||||
static boolean isValidShorelineSupport(ResolvedDecorator decorator, PlatformBlockState decorant, PlatformBlockState surface) {
|
||||
static boolean isValidShorelineSupport(DecorationScene scene, ResolvedDecorator decorator, BlockState decorant, BlockState surface) {
|
||||
return surface != null
|
||||
&& B.isSolid(surface)
|
||||
&& (decorator.isForcePlace() || canGoOn(decorant, surface));
|
||||
&& scene.isSolid(surface)
|
||||
&& (decorator.isForcePlace() || canGoOn(scene, decorant, surface));
|
||||
}
|
||||
|
||||
static boolean canReplaceStackTarget(PlatformBlockState state, boolean allowFluid) {
|
||||
return B.isAir(state) || allowFluid && B.isFluid(state);
|
||||
static boolean canReplaceStackTarget(DecorationScene scene, BlockState state, boolean allowFluid) {
|
||||
return scene.isAir(state) || allowFluid && scene.isFluid(state);
|
||||
}
|
||||
|
||||
private static boolean canPlaceTwoBlockPlant(Hunk<PlatformBlockState> data, int x, int z,
|
||||
private static boolean canPlaceTwoBlockPlant(DecorationScene scene, int x, int z,
|
||||
int lowerY, int upperY, boolean caveSkipFluid) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (lowerY < 0 || upperY >= data.getHeight()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlatformBlockState lower = data.get(x, lowerY, z);
|
||||
PlatformBlockState upper = data.get(x, upperY, z);
|
||||
return B.isAir(lower) && B.isAir(upper)
|
||||
&& (!caveSkipFluid || !B.isFluid(lower) && !B.isFluid(upper));
|
||||
BlockState lower = data.get(x, lowerY, z);
|
||||
BlockState upper = data.get(x, upperY, z);
|
||||
return scene.isAir(lower) && scene.isAir(upper)
|
||||
&& (!caveSkipFluid || !scene.isFluid(lower) && !scene.isFluid(upper));
|
||||
}
|
||||
|
||||
private static int computeStack(ResolvedDecorator decorator, double realX, double realZ, int max) {
|
||||
@@ -451,19 +450,15 @@ final class DecoratorCore {
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static volatile PlatformBlockState[] dripstoneUp;
|
||||
private static volatile PlatformBlockState[] dripstoneDown;
|
||||
|
||||
private static PlatformBlockState[] buildDripstoneArr(String direction) {
|
||||
String[] order = {"tip", "frustum", "base"};
|
||||
PlatformBlockState[] arr = new PlatformBlockState[3];
|
||||
for (int k = 0; k < 3; k++) {
|
||||
arr[k] = B.getState("minecraft:pointed_dripstone[thickness=" + order[k] + ",vertical_direction=" + direction + "]");
|
||||
private static BlockState[] dripstones(String direction) {
|
||||
BlockState[] arr = new BlockState[DRIPSTONE_THICKNESS.length];
|
||||
for (int k = 0; k < arr.length; k++) {
|
||||
arr[k] = BlockState.parse("minecraft:pointed_dripstone[thickness=" + DRIPSTONE_THICKNESS[k] + ",vertical_direction=" + direction + "]");
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
private static PlatformBlockState dripstoneBlock(int stack, int i, String direction) {
|
||||
private static BlockState dripstoneBlock(int stack, int i, BlockState[] byThickness) {
|
||||
int thIdx;
|
||||
if (i == stack - 1) {
|
||||
thIdx = 0;
|
||||
@@ -472,39 +467,24 @@ final class DecoratorCore {
|
||||
} else {
|
||||
thIdx = 2;
|
||||
}
|
||||
if (direction.equals("up")) {
|
||||
if (dripstoneUp == null) {
|
||||
dripstoneUp = buildDripstoneArr("up");
|
||||
}
|
||||
return dripstoneUp[thIdx];
|
||||
}
|
||||
if (dripstoneDown == null) {
|
||||
dripstoneDown = buildDripstoneArr("down");
|
||||
}
|
||||
return dripstoneDown[thIdx];
|
||||
return byThickness[thIdx];
|
||||
}
|
||||
|
||||
static String stackedVineKey(PlatformBlockState state, int stack, int index) {
|
||||
String material = IrisProceduralBlocks.materialKey(state);
|
||||
/** The key of the vine block that fills a stack of vines at {@code index}: the tip at the end, the plant before it; null for other blocks. */
|
||||
static ResourceId stackedVineMaterial(BlockState state, int stack, int index) {
|
||||
ResourceId material = state.material();
|
||||
boolean tip = index == stack - 1;
|
||||
return switch (material) {
|
||||
case WEEPING_VINES, WEEPING_VINES_PLANT -> tip ? WEEPING_VINES : WEEPING_VINES_PLANT;
|
||||
case TWISTING_VINES, TWISTING_VINES_PLANT -> tip ? TWISTING_VINES : TWISTING_VINES_PLANT;
|
||||
default -> null;
|
||||
};
|
||||
if (material.equals(WEEPING_VINES) || material.equals(WEEPING_VINES_PLANT)) {
|
||||
return tip ? WEEPING_VINES : WEEPING_VINES_PLANT;
|
||||
}
|
||||
if (material.equals(TWISTING_VINES) || material.equals(TWISTING_VINES_PLANT)) {
|
||||
return tip ? TWISTING_VINES : TWISTING_VINES_PLANT;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PlatformBlockState stackedVineBlock(PlatformBlockState state, int stack, int index) {
|
||||
String key = stackedVineKey(state, stack, index);
|
||||
if (key == null) {
|
||||
return state;
|
||||
}
|
||||
return switch (key) {
|
||||
case WEEPING_VINES -> weepingVines == null ? weepingVines = B.getState(key) : weepingVines;
|
||||
case WEEPING_VINES_PLANT -> weepingVinesPlant == null ? weepingVinesPlant = B.getState(key) : weepingVinesPlant;
|
||||
case TWISTING_VINES -> twistingVines == null ? twistingVines = B.getState(key) : twistingVines;
|
||||
case TWISTING_VINES_PLANT -> twistingVinesPlant == null ? twistingVinesPlant = B.getState(key) : twistingVinesPlant;
|
||||
default -> state;
|
||||
};
|
||||
private static BlockState stackedVineBlock(BlockState state, int stack, int index) {
|
||||
ResourceId material = stackedVineMaterial(state, stack, index);
|
||||
return material == null ? state : new BlockState(material.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
|
||||
public final class DecoratorPlatformHooks {
|
||||
private static volatile FaceFixer FACE_FIXER = null;
|
||||
private static volatile SurfaceSturdiness SURFACE_STURDINESS = null;
|
||||
|
||||
private DecoratorPlatformHooks() {
|
||||
}
|
||||
|
||||
public interface FaceFixer {
|
||||
PlatformBlockState fixFaces(PlatformBlockState state, Hunk<PlatformBlockState> hunk, int rX, int rZ, int x, int y, int z, EngineMantle mantle);
|
||||
}
|
||||
|
||||
public interface SurfaceSturdiness {
|
||||
boolean canGoOn(PlatformBlockState surface);
|
||||
}
|
||||
|
||||
public static synchronized Bindings bind(FaceFixer faceFixer, SurfaceSturdiness surfaceSturdiness) {
|
||||
Bindings previous = new Bindings(FACE_FIXER, SURFACE_STURDINESS);
|
||||
FACE_FIXER = faceFixer;
|
||||
SURFACE_STURDINESS = surfaceSturdiness;
|
||||
return previous;
|
||||
}
|
||||
|
||||
public static synchronized void restore(Bindings bindings) {
|
||||
FACE_FIXER = bindings.faceFixer();
|
||||
SURFACE_STURDINESS = bindings.surfaceSturdiness();
|
||||
}
|
||||
|
||||
static FaceFixer faceFixer() {
|
||||
return FACE_FIXER;
|
||||
}
|
||||
|
||||
static SurfaceSturdiness surfaceSturdiness() {
|
||||
return SURFACE_STURDINESS;
|
||||
}
|
||||
|
||||
public record Bindings(FaceFixer faceFixer, SurfaceSturdiness surfaceSturdiness) {
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,28 +15,23 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
/*
|
||||
* Floating island decoration path. Bypasses all canGoOn, slope, whitelist, and blacklist
|
||||
* gating from IrisSurfaceDecorator — the island top IS the biome's designated surface by
|
||||
* gating from IrisSurfaceDecorator: the island top IS the biome's designated surface by
|
||||
* construction, so those material-compatibility checks are never meaningful here.
|
||||
*/
|
||||
public class FloatingDecorator {
|
||||
|
||||
public static int decorateColumn(Engine engine, IrisBiome target, DecorationPart part,
|
||||
public static int decorateColumn(DecorationScene scene, DecoratedBiome target, DecorationPart part,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data, RNG rng,
|
||||
int height, int max, RNG rng,
|
||||
Runnable candidatesNullCallback) {
|
||||
BiomeDecorators decorators = BiomeDecorators.of(engine);
|
||||
BiomeDecorators decorators = scene.decorators();
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(target, part), rng, realX, realZ, decorators.log());
|
||||
|
||||
if (decorator == null) {
|
||||
@@ -45,10 +40,10 @@ public class FloatingDecorator {
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data, decorators.log());
|
||||
DecoratorCore.placeFloatingSimple(decorator, scene, xf, zf, realX, realZ, height, max);
|
||||
return max > 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
return DecoratorCore.placeFloatingStacked(decorator, xf, zf, realX, realZ, height, max, data);
|
||||
return DecoratorCore.placeFloatingStacked(decorator, scene, xf, zf, realX, realZ, height, max);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,35 +15,20 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
public IrisCeilingDecorator(Engine engine) {
|
||||
super(engine, "Ceiling", DecorationPart.CEILING);
|
||||
public IrisCeilingDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.CEILING);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
decorate(x, z, realX, realX1, realX_1, realZ, realZ1, realZ_1, data, biome, biome.getInferredType(), height, max);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
|
||||
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(biome.kind());
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -52,19 +37,16 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
if (caveSkipFluid) {
|
||||
PlatformBlockState state = data.get(x, height, z);
|
||||
if (B.isFluid(state)) {
|
||||
return;
|
||||
}
|
||||
if (caveSkipFluid && scene.isFluid(scene.blocks().get(x, height, z))) {
|
||||
return;
|
||||
}
|
||||
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, true, getEngine().getMantle());
|
||||
DecoratorCore.placeSingleAt(decorator, scene, x, z, realX, height, realZ, true);
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.PlaceOpts opts = DecoratorCore.SCRATCH_OPTS.get();
|
||||
opts.reset();
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, max, opts, getEngine().getMantle());
|
||||
DecoratorCore.placeStackDown(decorator, scene, x, z, realX, realZ, height, 0, max, opts);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,33 +15,49 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineAssignedComponent;
|
||||
import art.arcane.iris.engine.framework.EngineDecorator;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.Getter;
|
||||
|
||||
public abstract class IrisEngineDecorator extends EngineAssignedComponent implements EngineDecorator {
|
||||
@Getter
|
||||
/** A decorator of one kind of place, placing into the blocks of a {@link DecorationScene}. */
|
||||
public abstract class IrisEngineDecorator {
|
||||
private static final long COLUMN_X_FACTOR = 29356788L;
|
||||
private static final long COLUMN_Z_FACTOR = 10439677L;
|
||||
private static final int X_PART_OFFSET = 6;
|
||||
private static final int Z_PART_OFFSET = 1;
|
||||
|
||||
private final DecorationPart part;
|
||||
protected final DecorationScene scene;
|
||||
protected final BiomeDecorators decorators;
|
||||
|
||||
public IrisEngineDecorator(Engine engine, String name, DecorationPart part) {
|
||||
super(engine, name + " Decorator");
|
||||
protected IrisEngineDecorator(DecorationScene scene, DecorationPart part) {
|
||||
this.scene = scene;
|
||||
this.part = part;
|
||||
this.decorators = BiomeDecorators.of(engine);
|
||||
this.decorators = scene.decorators();
|
||||
}
|
||||
|
||||
public DecorationPart getPart() {
|
||||
return part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates one column. {@code x} and {@code z} are the column in the chunk, {@code realX} and {@code realZ} in the world,
|
||||
* with the world columns next to it on either side; {@code height} is the Y to decorate from and {@code max} how much room
|
||||
* there is.
|
||||
*/
|
||||
public abstract void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
DecoratedBiome biome, int height, int max);
|
||||
|
||||
/** {@link #decorate} for a decorator that looks at no neighbouring column. */
|
||||
public void decorate(int x, int z, int realX, int realZ, DecoratedBiome biome, int height, int max) {
|
||||
decorate(x, z, realX, realX, realX, realZ, realZ, realZ, biome, height, max);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
protected RNG getRNG(int x, int z) {
|
||||
long seed = DecoratorCore.partSeed(getSeed(), part);
|
||||
long modX = 29356788L ^ (part.ordinal() + 6);
|
||||
long modZ = 10439677L ^ (part.ordinal() + 1);
|
||||
long seed = DecoratorCore.partSeed(scene.seed(), part);
|
||||
long modX = COLUMN_X_FACTOR ^ (part.ordinal() + X_PART_OFFSET);
|
||||
long modZ = COLUMN_Z_FACTOR ^ (part.ordinal() + Z_PART_OFFSET);
|
||||
return new RNG(x * modX + z * modZ + seed);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,26 +15,20 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
public IrisSeaFloorDecorator(Engine engine) {
|
||||
super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
|
||||
public IrisSeaFloorDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.SEA_FLOOR);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -42,12 +36,13 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = scene.blocks();
|
||||
if (!decorator.isStacking()) {
|
||||
if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
|
||||
if (decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ))) {
|
||||
return;
|
||||
}
|
||||
if (height >= 0 && height < getEngine().getHeight()) {
|
||||
data.set(x, height, z, decorator.blockAt(biome, realX, height, realZ));
|
||||
if (height >= 0 && height < scene.worldHeight()) {
|
||||
place(x, height, z, decorator.blockAt(realX, height, realZ));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -60,20 +55,27 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
if (stack == 1) {
|
||||
data.set(x, height, z, decorator.topBlockAt(biome, realX, height, realZ));
|
||||
place(x, height, z, decorator.topBlockAt(realX, height, realZ));
|
||||
return;
|
||||
}
|
||||
|
||||
int engineHeight = getEngine().getHeight();
|
||||
int engineHeight = scene.worldHeight();
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
if (h > max || h > engineHeight) {
|
||||
continue;
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, h, z, threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(biome, realX, h, realZ)
|
||||
: decorator.blockAt(biome, realX, h, realZ));
|
||||
place(x, h, z, threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(realX, h, realZ)
|
||||
: decorator.blockAt(realX, h, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
/** A block the decorator has none of leaves the water as it is. */
|
||||
private void place(int x, int y, int z, BlockState block) {
|
||||
if (block != null && y < scene.worldHeight()) {
|
||||
scene.blocks().set(x, y, z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,26 +15,20 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
public IrisSeaSurfaceDecorator(Engine engine) {
|
||||
super(engine, "Sea Surface", DecorationPart.SEA_SURFACE);
|
||||
public IrisSeaSurfaceDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.SEA_SURFACE);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -42,11 +36,12 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = scene.blocks();
|
||||
if (!decorator.isStacking()) {
|
||||
int targetY = height + 1;
|
||||
if (height >= 0 && targetY < getEngine().getHeight()
|
||||
&& DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
|
||||
if (height >= 0 && targetY < scene.worldHeight()
|
||||
&& DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
BlockState block = decorator.blockAt(realX, height, realZ);
|
||||
if (block != null) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
@@ -61,29 +56,29 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
|
||||
if (stack == 1) {
|
||||
int targetY = height + 1;
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
|
||||
BlockState block = decorator.topBlockAt(realX, height, realZ);
|
||||
if (block != null) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int engineHeight = getEngine().getHeight();
|
||||
int engineHeight = scene.worldHeight();
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
int targetY = h + 1;
|
||||
if (h >= max || targetY >= engineHeight
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
|| !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
break;
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
PlatformBlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(biome, realX, h, realZ)
|
||||
: decorator.blockAt(biome, realX, h, realZ);
|
||||
BlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(realX, h, realZ)
|
||||
: decorator.blockAt(realX, h, realZ);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,37 +15,29 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.iris.util.project.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
public IrisShoreLineDecorator(Engine engine) {
|
||||
super(engine, "Shore Line", DecorationPart.SHORE_LINE);
|
||||
public IrisShoreLineDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.SHORE_LINE);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
if (height != getDimension().getFluidHeight()) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
if (height != scene.fluidHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double complexFluidHeight = getComplex().getFluidHeight();
|
||||
ProceduralStream<Double> heightStream = getComplex().getHeightStream();
|
||||
if (Math.round(heightStream.get(realX1, realZ)) >= complexFluidHeight
|
||||
&& Math.round(heightStream.get(realX_1, realZ)) >= complexFluidHeight
|
||||
&& Math.round(heightStream.get(realX, realZ1)) >= complexFluidHeight
|
||||
&& Math.round(heightStream.get(realX, realZ_1)) >= complexFluidHeight) {
|
||||
double complexFluidHeight = scene.fluidHeight();
|
||||
if (scene.roundedHeightAt(realX1, realZ) >= complexFluidHeight
|
||||
&& scene.roundedHeightAt(realX_1, realZ) >= complexFluidHeight
|
||||
&& scene.roundedHeightAt(realX, realZ1) >= complexFluidHeight
|
||||
&& scene.roundedHeightAt(realX, realZ_1) >= complexFluidHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,23 +48,24 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
|
||||
if (decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ))) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState support = data.get(x, height, z);
|
||||
if (support == null || !support.isSolid()) {
|
||||
var data = scene.blocks();
|
||||
BlockState support = data.get(x, height, z);
|
||||
if (support == null || !scene.isSolid(support)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
int targetY = height + 1;
|
||||
if (targetY >= data.getHeight()
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
|| !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
|
||||
BlockState block = decorator.blockAt(realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
return;
|
||||
@@ -87,12 +80,12 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
|
||||
if (stack == 1) {
|
||||
int targetY = height + 1;
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
|
||||
BlockState block = decorator.topBlockAt(realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
return;
|
||||
@@ -102,17 +95,17 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
int h = height + i;
|
||||
int targetY = h + 1;
|
||||
if (targetY >= data.getHeight()
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
|| !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
break;
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
PlatformBlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(biome, realX, h, realZ)
|
||||
: decorator.blockAt(biome, realX, h, realZ);
|
||||
BlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(realX, h, realZ)
|
||||
: decorator.blockAt(realX, h, realZ);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
if (i == 0 && !DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
|
||||
if (i == 0 && !DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
|
||||
break;
|
||||
}
|
||||
data.set(x, targetY, z, block);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,48 +15,32 @@
|
||||
* 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.engine.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.world.BiomeKind;
|
||||
|
||||
public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
public IrisSurfaceDecorator(Engine engine) {
|
||||
super(engine, "Surface", DecorationPart.NONE);
|
||||
}
|
||||
|
||||
protected IrisSurfaceDecorator(Engine engine, String name) {
|
||||
super(engine, name, DecorationPart.NONE);
|
||||
public IrisSurfaceDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.NONE);
|
||||
}
|
||||
|
||||
protected boolean isSlopeValid(ResolvedDecorator decorator, int realX, int realZ) {
|
||||
return !decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ));
|
||||
return !decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ));
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
decorate(x, z, realX, realX1, realX_1, realZ, realZ1, realZ_1, data, biome, biome.getInferredType(), height, max);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
|
||||
int fluidHeight = getDimension().getFluidHeight();
|
||||
if (inferredType == InferredType.SHORE && height < fluidHeight) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
BiomeKind kind = biome.kind();
|
||||
int fluidHeight = scene.fluidHeight();
|
||||
if (kind == BiomeKind.SHORE && height < fluidHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean underwater = isUnderwater(inferredType, height, fluidHeight);
|
||||
boolean caveSkipFluid = skipsFluid(inferredType);
|
||||
boolean underwater = isUnderwater(kind, height, fluidHeight);
|
||||
boolean caveSkipFluid = skipsFluid(kind);
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -70,19 +54,18 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
opts.underwater = underwater;
|
||||
opts.fluidHeight = fluidHeight;
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, opts);
|
||||
DecoratorCore.placeStackUp(decorator, scene, x, z, realX, realZ, height, max, opts);
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ,
|
||||
data, underwater, caveSkipFluid, getEngine().getMantle(), decorators.log());
|
||||
DecoratorCore.placeSurfaceSingle(decorator, scene, x, z, realX, height, realZ, underwater, caveSkipFluid);
|
||||
}
|
||||
|
||||
static boolean isUnderwater(InferredType inferredType, int height, int fluidHeight) {
|
||||
return height < fluidHeight && inferredType != InferredType.CAVE;
|
||||
static boolean isUnderwater(BiomeKind kind, int height, int fluidHeight) {
|
||||
return height < fluidHeight && kind != BiomeKind.CAVE;
|
||||
}
|
||||
|
||||
static boolean skipsFluid(InferredType inferredType) {
|
||||
return inferredType == InferredType.CAVE;
|
||||
static boolean skipsFluid(BiomeKind kind) {
|
||||
return kind == BiomeKind.CAVE;
|
||||
}
|
||||
}
|
||||
@@ -21,22 +21,20 @@ package art.arcane.iris.engine.decorator;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
/**
|
||||
* One {@link Decorator} made ready for one world: its palettes resolved to the platform's blocks, and the noise that
|
||||
* One {@link Decorator} made ready for one world: its palettes resolved to blocks, and the noise that
|
||||
* decides where it places, which block of the palette it picks and how tall it stacks, built when first asked for. What
|
||||
* the decorator describes stays in the settings; everything that needs the platform, the pack or the world seed is here.
|
||||
*
|
||||
@@ -47,17 +45,18 @@ final class ResolvedDecorator {
|
||||
private final Decorator settings;
|
||||
private final long seed;
|
||||
private final NoiseFactory noise;
|
||||
private final List<PlatformBlockState> blocks;
|
||||
private final List<PlatformBlockState> topBlocks;
|
||||
private final PlatformBlockState[] blockArray;
|
||||
private final PlatformBlockState[] topBlockArray;
|
||||
private final PlatformBlockState forceBlock;
|
||||
private final PlatformBlockState[] whitelist;
|
||||
private final PlatformBlockState[] blacklist;
|
||||
private final List<BlockState> blocks;
|
||||
private final List<BlockState> topBlocks;
|
||||
private final BlockState[] blockArray;
|
||||
private final BlockState[] topBlockArray;
|
||||
private final BlockState forceBlock;
|
||||
private final BlockState[] whitelist;
|
||||
private final BlockState[] blacklist;
|
||||
private final AtomicCache<NoiseSampler> chanceNoise = new AtomicCache<>();
|
||||
private final AtomicCache<NoiseSampler> varianceNoise = new AtomicCache<>();
|
||||
private final AtomicCache<NoiseSampler> heightNoise = new AtomicCache<>();
|
||||
private final ModuleLog log;
|
||||
private final String biomeKey;
|
||||
|
||||
/**
|
||||
* @param blocks the palette as the platform's blocks, each repeated by its weight
|
||||
@@ -66,43 +65,38 @@ final class ResolvedDecorator {
|
||||
* @param whitelist the blocks it may only be placed onto; ignored unless the decorator has a whitelist
|
||||
* @param blacklist the blocks it is never placed onto; ignored unless the decorator has a blacklist
|
||||
* @param log the log of the module that decorates
|
||||
* @param biomeKey the key of the biome that declares the decorator, which names it in the log
|
||||
*/
|
||||
ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List<PlatformBlockState> blocks, List<PlatformBlockState> topBlocks,
|
||||
PlatformBlockState forceBlock, List<PlatformBlockState> whitelist, List<PlatformBlockState> blacklist,
|
||||
ModuleLog log) {
|
||||
ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List<BlockState> blocks, List<BlockState> topBlocks,
|
||||
BlockState forceBlock, List<BlockState> whitelist, List<BlockState> blacklist,
|
||||
ModuleLog log, String biomeKey) {
|
||||
this.settings = settings;
|
||||
this.seed = seed;
|
||||
this.noise = noise;
|
||||
this.blocks = List.copyOf(blocks);
|
||||
this.topBlocks = List.copyOf(topBlocks);
|
||||
this.blockArray = blocks.toArray(new PlatformBlockState[0]);
|
||||
this.topBlockArray = topBlocks.toArray(new PlatformBlockState[0]);
|
||||
this.blockArray = blocks.toArray(new BlockState[0]);
|
||||
this.topBlockArray = topBlocks.toArray(new BlockState[0]);
|
||||
this.forceBlock = forceBlock;
|
||||
this.whitelist = whitelist.toArray(new PlatformBlockState[0]);
|
||||
this.blacklist = blacklist.toArray(new PlatformBlockState[0]);
|
||||
this.whitelist = whitelist.toArray(new BlockState[0]);
|
||||
this.blacklist = blacklist.toArray(new BlockState[0]);
|
||||
this.log = log;
|
||||
this.biomeKey = biomeKey;
|
||||
}
|
||||
|
||||
/** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its noise seeded from {@code seed}. */
|
||||
static ResolvedDecorator of(Decorator settings, Engine engine, long seed, ModuleLog log) {
|
||||
var resources = engine.getData().getPackResources();
|
||||
/** {@code settings} ready for a world with {@code resources}: its blocks resolved through the pack, its noise seeded from {@code seed}. */
|
||||
static ResolvedDecorator of(Decorator settings, PackResources resources, long seed, ModuleLog log, String biomeKey) {
|
||||
BlockRegistry registry = resources.blocks();
|
||||
PlatformBlockState forced = settings.forceBlock().map(spec -> platformState(registry, spec)).orElse(null);
|
||||
BlockState forced = settings.forceBlock().map(registry::resolve).orElse(null);
|
||||
return new ResolvedDecorator(settings, seed, resources.noise(), weighted(registry, settings.palette()),
|
||||
weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist()), log);
|
||||
weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist()), log,
|
||||
biomeKey);
|
||||
}
|
||||
|
||||
private static PlatformBlockState platformState(BlockRegistry registry, BlockSpec spec) {
|
||||
return B.getState(registry.resolve(spec).key());
|
||||
}
|
||||
|
||||
private static List<PlatformBlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
List<PlatformBlockState> weighted = new ArrayList<>();
|
||||
private static List<BlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
List<BlockState> weighted = new ArrayList<>();
|
||||
for (BlockSpec spec : palette) {
|
||||
PlatformBlockState state = platformState(registry, spec);
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
BlockState state = registry.resolve(spec);
|
||||
for (int n = 0; n < spec.weight(); n++) {
|
||||
weighted.add(state);
|
||||
}
|
||||
@@ -110,8 +104,8 @@ final class ResolvedDecorator {
|
||||
return weighted;
|
||||
}
|
||||
|
||||
private static List<PlatformBlockState> each(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
return palette.stream().map(spec -> platformState(registry, spec)).toList();
|
||||
private static List<BlockState> each(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
return palette.stream().map(registry::resolve).toList();
|
||||
}
|
||||
|
||||
Decorator settings() {
|
||||
@@ -148,7 +142,7 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The block it forces onto the surface instead of the one found there, or null. */
|
||||
PlatformBlockState forceBlock() {
|
||||
BlockState forceBlock() {
|
||||
return forceBlock;
|
||||
}
|
||||
|
||||
@@ -161,15 +155,15 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** Whether the white and black lists keep the decorator off {@code surface}. */
|
||||
boolean rejectsSurface(PlatformBlockState surface) {
|
||||
boolean rejectsSurface(BlockState surface) {
|
||||
if (settings.hasWhitelist() && !matches(whitelist, surface)) {
|
||||
return true;
|
||||
}
|
||||
return settings.hasBlacklist() && matches(blacklist, surface);
|
||||
}
|
||||
|
||||
private static boolean matches(PlatformBlockState[] palette, PlatformBlockState surface) {
|
||||
for (PlatformBlockState state : palette) {
|
||||
private static boolean matches(BlockState[] palette, BlockState surface) {
|
||||
for (BlockState state : palette) {
|
||||
if (state.equals(surface)) {
|
||||
return true;
|
||||
}
|
||||
@@ -197,9 +191,9 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */
|
||||
PlatformBlockState blockAt(IrisBiome biome, double x, double y, double z) {
|
||||
BlockState blockAt(double x, double y, double z) {
|
||||
if (blocks.isEmpty()) {
|
||||
log.warnOnce("decorator-empty:" + biome.getName(), "Empty Block Data for " + biome.getName());
|
||||
log.warnOnce("decorator-empty:" + biomeKey, "Empty Block Data for " + biomeKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -211,9 +205,9 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The top palette's block at the position, or the palette's when there is no top palette; null where the chance noise declines. */
|
||||
PlatformBlockState topBlockAt(IrisBiome biome, double x, double y, double z) {
|
||||
BlockState topBlockAt(double x, double y, double z) {
|
||||
if (topBlocks.isEmpty()) {
|
||||
return blockAt(biome, x, y, z);
|
||||
return blockAt(x, y, z);
|
||||
}
|
||||
|
||||
double zoom = settings.style().zoom();
|
||||
@@ -229,19 +223,19 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The palette's block for the column, or null when the palette has no block. */
|
||||
PlatformBlockState pickBlock(double x, double z) {
|
||||
BlockState pickBlock(double x, double z) {
|
||||
return pick(blockArray, x, z);
|
||||
}
|
||||
|
||||
/** The top palette's block for the column; the palette's when there is no top palette. */
|
||||
PlatformBlockState pickTopBlock(double x, double z) {
|
||||
BlockState pickTopBlock(double x, double z) {
|
||||
if (topBlockArray.length == 0) {
|
||||
return pickBlock(x, z);
|
||||
}
|
||||
return pick(topBlockArray, x, z);
|
||||
}
|
||||
|
||||
private PlatformBlockState pick(PlatformBlockState[] palette, double x, double z) {
|
||||
private BlockState pick(BlockState[] palette, double x, double z) {
|
||||
if (palette.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class CarveModule implements IrisModule {
|
||||
}
|
||||
ModuleLog log = context.log();
|
||||
chunk.state(CaveApplying.class, generating -> new CaveApplying(generating, log)).apply(chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT,
|
||||
chunk.blocks(), chunk.multicore(), chunk.context());
|
||||
chunk.blocks(), chunk.multicore(), chunk.context(), context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,13 +20,13 @@ package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.engine.decorator.DecoratedBiome;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.engine.decorator.IrisCeilingDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
@@ -45,6 +45,8 @@ import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.volmlib.util.matter.slices.MarkerMatter;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import lombok.Data;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -67,30 +69,25 @@ public class CaveApplying {
|
||||
private final RNG rng;
|
||||
private final PlatformBlockState AIR = B.getState("CAVE_AIR");
|
||||
private final PlatformBlockState LAVA = B.getState("LAVA");
|
||||
private final BiomeDecorators decorators;
|
||||
private final BiomeLayers layers;
|
||||
private final TerrainPalettes palettes;
|
||||
private final IrisSurfaceDecorator surfaceDecorator;
|
||||
private final IrisCeilingDecorator ceilingDecorator;
|
||||
|
||||
public CaveApplying(Engine engine, ModuleLog log) {
|
||||
this.engine = engine;
|
||||
rng = new RNG(engine.getSeedManager().getCarve());
|
||||
decorators = BiomeDecorators.of(engine);
|
||||
layers = BiomeLayers.of(engine, log);
|
||||
palettes = TerrainPalettes.of(engine);
|
||||
surfaceDecorator = new IrisSurfaceDecorator(engine);
|
||||
ceilingDecorator = new IrisCeilingDecorator(engine);
|
||||
}
|
||||
|
||||
/** Applies the caves to the chunk at chunk coordinates {@code x}, {@code z}. */
|
||||
@ChunkCoordinates
|
||||
public void apply(int x, int z, Hunk<PlatformBlockState> output, boolean multicore, ChunkContext context) {
|
||||
public void apply(int x, int z, Hunk<PlatformBlockState> output, boolean multicore, ChunkContext context, ChunkStageContext chunk) {
|
||||
PrecisionStopwatch caveStopwatch = PrecisionStopwatch.start();
|
||||
Mantle<Matter> mantle = engine.getMantle().getMantle();
|
||||
Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache = new Long2ObjectOpenHashMap<>(2048);
|
||||
IrisCarveScratch scratch = SCRATCH.get();
|
||||
scratch.reset();
|
||||
scratch.decoration = DecorationScene.of(chunk);
|
||||
CarveWallBuffer walls = scratch.walls;
|
||||
CarveColumnMask[] columnMasks = scratch.columnMasks;
|
||||
CarveColumnMask[] boundaryMasks = scratch.boundaryMasks;
|
||||
@@ -644,12 +641,19 @@ public class CaveApplying {
|
||||
}
|
||||
}
|
||||
|
||||
if (floorBiome != null && decorators.hasDecorators(floorBiome, DecorationPart.NONE) && hasStableCaveFloorSupport(output, rx, zone.getFloor(), rz)) {
|
||||
surfaceDecorator.decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, floorBiome, InferredType.CAVE, zone.getFloor() - 1, zone.airThickness());
|
||||
DecorationScene scene = SCRATCH.get().decoration;
|
||||
if (floorBiome != null) {
|
||||
DecoratedBiome floor = IrisDecoratedBiomes.of(floorBiome, BiomeKind.CAVE);
|
||||
if (scene.decorators().hasDecorators(floor, DecorationPart.NONE) && hasStableCaveFloorSupport(output, rx, zone.getFloor(), rz)) {
|
||||
new IrisSurfaceDecorator(scene).decorate(rx, rz, xx, xx, xx, zz, zz, zz, floor, zone.getFloor() - 1, zone.airThickness());
|
||||
}
|
||||
}
|
||||
|
||||
if (ceilingBiome != null && decorators.hasDecorators(ceilingBiome, DecorationPart.CEILING) && zone.getCeiling() + 1 < maxY && B.isSolid(output.getRaw(rx, zone.getCeiling() + 1, rz))) {
|
||||
ceilingDecorator.decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, ceilingBiome, InferredType.CAVE, zone.getCeiling(), zone.airThickness());
|
||||
if (ceilingBiome != null) {
|
||||
DecoratedBiome ceiling = IrisDecoratedBiomes.of(ceilingBiome, BiomeKind.CAVE);
|
||||
if (scene.decorators().hasDecorators(ceiling, DecorationPart.CEILING) && zone.getCeiling() + 1 < maxY && B.isSolid(output.getRaw(rx, zone.getCeiling() + 1, rz))) {
|
||||
new IrisCeilingDecorator(scene).decorate(rx, rz, xx, xx, xx, zz, zz, zz, ceiling, zone.getCeiling(), zone.airThickness());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.decorator.FloatingDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaSurfaceDecorator;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineDecorator;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
@@ -51,6 +51,7 @@ import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import java.util.IdentityHashMap;
|
||||
|
||||
import static art.arcane.iris.engine.mantle.EngineMantle.AIR;
|
||||
@@ -66,7 +67,6 @@ public class FloatingIslands {
|
||||
};
|
||||
private final Engine engine;
|
||||
private final RNG rng;
|
||||
private final EngineDecorator seaSurfaceDecorator;
|
||||
private final BiomeLayers biomeLayers;
|
||||
private final ModuleLog log;
|
||||
|
||||
@@ -212,7 +212,6 @@ public class FloatingIslands {
|
||||
this.engine = engine;
|
||||
this.log = log;
|
||||
rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL);
|
||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
|
||||
biomeLayers = BiomeLayers.of(engine, log);
|
||||
}
|
||||
|
||||
@@ -305,7 +304,7 @@ public class FloatingIslands {
|
||||
}
|
||||
|
||||
/** Decorates the tops of the islands in the chunk whose first block is {@code x}, {@code z}. */
|
||||
public void decorateColumns(int x, int z, Hunk<PlatformBlockState> output, boolean multicore, ChunkContext context) {
|
||||
public void decorateColumns(int x, int z, Hunk<PlatformBlockState> output, boolean multicore, ChunkContext context, DecorationScene scene) {
|
||||
int chunkHeight = output.getHeight();
|
||||
IrisData data = engine.getData();
|
||||
IrisComplex complex = engine.getComplex();
|
||||
@@ -338,7 +337,7 @@ public class FloatingIslands {
|
||||
if (above == null || above.isAir()) {
|
||||
try {
|
||||
RNG colRng = rng.nextParallelRNG((int) FloatingIslandSample.columnSeed(baseSeed, wx, wz));
|
||||
FloatingDecorator.decorateColumn(engine, target, DecorationPart.NONE, xf, zf, wx, wz, topY, max, output, colRng, NOOP_DECORATION_MISS);
|
||||
FloatingDecorator.decorateColumn(scene, IrisDecoratedBiomes.of(target, BiomeKind.LAND), DecorationPart.NONE, xf, zf, wx, wz, topY, max, colRng, NOOP_DECORATION_MISS);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to decorate the top of a floating island", e);
|
||||
}
|
||||
@@ -370,7 +369,7 @@ public class FloatingIslands {
|
||||
}
|
||||
if (fluidTopY > 0 && fluidTopY + 1 < chunkHeight && B.isAir(output.get(xf, fluidTopY + 1, zf))) {
|
||||
try {
|
||||
seaSurfaceDecorator.decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, output, target, fluidTopY, chunkHeight);
|
||||
new IrisSeaSurfaceDecorator(scene).decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, IrisDecoratedBiomes.of(target, BiomeKind.LAND), fluidTopY, chunkHeight);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to decorate the sea surface of a floating island", e);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -65,7 +66,8 @@ public final class FloatingModule implements IrisModule {
|
||||
.run(FloatingModule::objects);
|
||||
// Ordering only: iris:post ships in the built-ins jar, which a pack may not have.
|
||||
graph.define(IrisStages.Floating.SOLIDS).softAfter(IrisStages.Post.SMOOTH.ref()).run(FloatingModule::solids);
|
||||
graph.define(IrisStages.Floating.DECORATE).requires(IrisStages.Decorant.DECORATE).run(FloatingModule::decorate);
|
||||
// Ordering only: iris:decorant ships in the built-ins jar, which a pack may not have.
|
||||
graph.define(IrisStages.Floating.DECORATE).softAfter(IrisStages.Decorant.DECORATE.ref()).run(FloatingModule::decorate);
|
||||
}
|
||||
|
||||
private static void objects(MantleStageContext context) {
|
||||
@@ -84,7 +86,8 @@ public final class FloatingModule implements IrisModule {
|
||||
|
||||
private static void decorate(ChunkStageContext context) {
|
||||
IrisChunk chunk = IrisChunk.current();
|
||||
islands(chunk, context.log()).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
|
||||
islands(chunk, context.log()).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context(),
|
||||
DecorationScene.of(context));
|
||||
}
|
||||
|
||||
private static FloatingObjectPlacing objectPlacing(Engine engine, ModuleLog log) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.volmlib.util.math.PowerOfTwoCoordinates;
|
||||
@@ -34,6 +35,8 @@ final class IrisCarveScratch {
|
||||
final Map<String, IrisBiome> customBiomeCache = new HashMap<>();
|
||||
int[] upperSurfaceHeights;
|
||||
boolean customCaveBiomePresent;
|
||||
/** The chunk being carved, for the cave decorators; set by each apply. */
|
||||
DecorationScene decoration;
|
||||
|
||||
IrisCarveScratch() {
|
||||
for (int index = 0; index < columnMasks.length; index++) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.engine.decorator.DecoratedBiome;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.volmit.world.BiomeKind;
|
||||
|
||||
/** The decorators' view of a biome Iris's carving and floating islands hold as an {@link IrisBiome}. */
|
||||
final class IrisDecoratedBiomes {
|
||||
private IrisDecoratedBiomes() {
|
||||
}
|
||||
|
||||
static DecoratedBiome of(IrisBiome biome, BiomeKind kind) {
|
||||
return new DecoratedBiome(biome.getLoadKey(), biome.getModuleSettings().find(DecorantSettings.class).orElse(null), kind);
|
||||
}
|
||||
}
|
||||
+11
-3
@@ -18,7 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecoratorLoad;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -77,8 +78,11 @@ final class IrisBiomeColorRenderer {
|
||||
}
|
||||
case DECORATOR_LOAD -> {
|
||||
return biome.getCacheColorDecoratorLoad().aquire(() -> {
|
||||
BiomeDecorators decorators = BiomeDecorators.of(engine);
|
||||
return Color.getHSBColor(0.41f, (float) (decorators.colourLoad(biome) / decorators.busiestBiomeLoad()), 1f);
|
||||
double busiest = 0D;
|
||||
for (IrisBiome reachable : engine.getDimension().getReachableBiomes(engine)) {
|
||||
busiest = Math.max(busiest, DecoratorLoad.of(decorantSettingsOf(reachable)));
|
||||
}
|
||||
return Color.getHSBColor(0.41f, (float) (DecoratorLoad.colour(decorantSettingsOf(biome)) / busiest), 1f);
|
||||
});
|
||||
}
|
||||
case LAYER_LOAD -> {
|
||||
@@ -91,4 +95,8 @@ final class IrisBiomeColorRenderer {
|
||||
|
||||
return Color.black;
|
||||
}
|
||||
|
||||
private static DecorantSettings decorantSettingsOf(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(DecorantSettings.class).orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -148,8 +148,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private IrisGeneratorStyle caveBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||
@Desc("Instead of filling objects with air, fills them with cobweb so you can see them")
|
||||
private boolean debugSmartBore = false;
|
||||
@Desc("Generate decorations or not")
|
||||
private boolean decorate = true;
|
||||
@Desc("Refuse to place surface objects and trees over carved surface openings.")
|
||||
private boolean requireObjectSurfaceSupport = true;
|
||||
@MinNumber(0)
|
||||
|
||||
Reference in new issue
Block a user