mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Merge master (T, C, L) into wave3/s: iris:post reads T's post and terrain settings, iris:perfection C's hideOresForHiddenOre; a layer's block picks move into the shared, portable LayerBlocks so terrain, caves and post keep one noise per layer; PendingSettings is gone
This commit is contained in:
commit
2148eb28cd
140 files changed
+5658
-3746
No files matched your search
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
|
||||
/** Whether a dimension hides its ores ({@code hideOresForHiddenOre}): the terrain places none and the perfection pass turns the rest into their base blocks. */
|
||||
public final class HiddenOres {
|
||||
private HiddenOres() {
|
||||
}
|
||||
|
||||
public static boolean in(IrisDimension dimension) {
|
||||
return dimension.getModuleSettings().find(HideOresSettings.class).map(HideOresSettings::hide).orElse(false);
|
||||
}
|
||||
}
|
||||
@@ -19,55 +19,52 @@
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
* Builds the noise of every ore generator the world's biomes, regions and dimension declare before generation needs it.
|
||||
* A generator keeps the noise of the first random it is given, so each one is warmed with the random of its place in
|
||||
* A generator keeps the noise of the first seed it is given, so each one is warmed with the seed of its place in
|
||||
* this order: the biomes by key, the regions by key, then the dimension. The order is part of what a world generates.
|
||||
*/
|
||||
final class OreWarmUp {
|
||||
private static final long ROOT_SEED_SALT = 7777L;
|
||||
|
||||
private final Engine engine;
|
||||
private final TerrainOres ores;
|
||||
private final RNG root;
|
||||
private int warmed;
|
||||
|
||||
OreWarmUp(Engine engine) {
|
||||
this(engine, TerrainOres.of(engine));
|
||||
}
|
||||
|
||||
OreWarmUp(Engine engine, TerrainOres ores) {
|
||||
this.engine = engine;
|
||||
this.ores = ores;
|
||||
this.root = new RNG(engine.getSeedManager().getComponent() + ROOT_SEED_SALT);
|
||||
}
|
||||
|
||||
void warm() {
|
||||
LongSupplier seeds = () -> root.nextParallelRNG(warmed++).getSeed();
|
||||
|
||||
KList<IrisBiome> biomes = engine.getAllBiomes();
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
warmAll(biome.getOres());
|
||||
ores.of(biome).warm(seeds);
|
||||
}
|
||||
|
||||
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
||||
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
|
||||
for (IrisRegion region : regions) {
|
||||
warmAll(region.getOres());
|
||||
ores.of(region).warm(seeds);
|
||||
}
|
||||
|
||||
warmAll(engine.getDimension().getOres());
|
||||
}
|
||||
|
||||
private void warmAll(KList<IrisOreGenerator> ores) {
|
||||
if (ores == null) {
|
||||
return;
|
||||
}
|
||||
for (IrisOreGenerator ore : ores) {
|
||||
if (ore != null) {
|
||||
ore.warm(root.nextParallelRNG(warmed++), engine.getData());
|
||||
}
|
||||
}
|
||||
ores.of(engine.getDimension()).warm(seeds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.OreGenerator;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.PaletteSampler;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* One {@link OreGenerator} made ready for one world: its palette resolved to the platform's blocks and the noise that
|
||||
* decides where it places ore, built from the seed it is warmed with or, when nothing warmed it, from the terrain seed
|
||||
* of its first use. The palette picks with the terrain seed. What the generator describes stays in the settings;
|
||||
* everything that needs the platform, the pack or the world seed is here.
|
||||
*/
|
||||
final class ResolvedOre {
|
||||
private final OreGenerator settings;
|
||||
private final NoiseFactory noise;
|
||||
private final BlockRegistry blockRegistry;
|
||||
private final long terrainSeed;
|
||||
private final List<PlatformBlockState> blocks;
|
||||
private final AtomicCache<NoiseSampler> chance = new AtomicCache<>();
|
||||
private final AtomicCache<PaletteSampler> palette = new AtomicCache<>();
|
||||
|
||||
/**
|
||||
* @param terrainSeed the seed the palette picks with, and the noise is built from when nothing warmed it first
|
||||
* @param blocks the palette as the platform's blocks, each repeated by its weight
|
||||
*/
|
||||
ResolvedOre(OreGenerator settings, NoiseFactory noise, BlockRegistry blockRegistry, long terrainSeed, List<PlatformBlockState> blocks) {
|
||||
this.settings = settings;
|
||||
this.noise = noise;
|
||||
this.blockRegistry = blockRegistry;
|
||||
this.terrainSeed = terrainSeed;
|
||||
this.blocks = List.copyOf(blocks);
|
||||
}
|
||||
|
||||
/** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its picks seeded with the terrain seed. */
|
||||
static ResolvedOre of(OreGenerator settings, Engine engine) {
|
||||
var resources = engine.getData().getPackResources();
|
||||
BlockRegistry registry = resources.blocks();
|
||||
return new ResolvedOre(settings, resources.noise(), registry, engine.getSeedManager().getTerrain(), weighted(registry, settings.palette().palette()));
|
||||
}
|
||||
|
||||
private static List<PlatformBlockState> weighted(BlockRegistry registry, List<BlockSpec> specs) {
|
||||
List<PlatformBlockState> weighted = new ArrayList<>();
|
||||
for (BlockSpec spec : specs) {
|
||||
PlatformBlockState state = B.getState(registry.resolve(spec).key());
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
for (int n = 0; n < spec.weight(); n++) {
|
||||
weighted.add(state);
|
||||
}
|
||||
}
|
||||
return weighted;
|
||||
}
|
||||
|
||||
boolean generatesSurface() {
|
||||
return settings.generateSurface();
|
||||
}
|
||||
|
||||
double minY() {
|
||||
return settings.range().min();
|
||||
}
|
||||
|
||||
double maxY() {
|
||||
return settings.range().max();
|
||||
}
|
||||
|
||||
/** Builds the chance noise from {@code seed}, unless it is built already: the first seed it is given is the one it keeps. */
|
||||
void warm(long seed) {
|
||||
chance.aquire(() -> noise.sampler(settings.chanceStyle(), seed));
|
||||
}
|
||||
|
||||
/** The ore block at the position, or null when the position is out of the band, the chance noise is above the threshold or the palette has no block. */
|
||||
PlatformBlockState generate(int x, int y, int z) {
|
||||
if (!settings.range().contains(y)) {
|
||||
return null;
|
||||
}
|
||||
if (settings.palette().palette().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (chanceNoise().sample(x, y, z) > settings.threshold()) {
|
||||
return null;
|
||||
}
|
||||
return pick(x, y, z);
|
||||
}
|
||||
|
||||
/** The chance noise, which this runs per block of the terrain, so a built one is read without creating a supplier. */
|
||||
private NoiseSampler chanceNoise() {
|
||||
NoiseSampler built = chance.getIfPresent();
|
||||
if (built != null) {
|
||||
return built;
|
||||
}
|
||||
return chance.aquire(() -> noise.sampler(settings.chanceStyle(), terrainSeed));
|
||||
}
|
||||
|
||||
private PlatformBlockState pick(int x, int y, int z) {
|
||||
if (blocks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (blocks.size() == 1) {
|
||||
return blocks.getFirst();
|
||||
}
|
||||
PaletteSampler sampler = palette.aquire(() -> blockRegistry.palette(settings.palette(), terrainSeed));
|
||||
return B.getState(sampler.at(x, y, z).key());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.OreGenerator;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
* The ore generators of one dimension, region or biome made ready ({@link ResolvedOre}), in the order its settings list them
|
||||
* and split into the ones that also replace surface blocks and the ones that only replace rock. A level without ores is
|
||||
* {@link #NONE}.
|
||||
*/
|
||||
final class ResolvedOres {
|
||||
static final ResolvedOres NONE = new ResolvedOres(List.of());
|
||||
|
||||
private final List<ResolvedOre> all;
|
||||
private final List<ResolvedOre> surface;
|
||||
private final List<ResolvedOre> underground;
|
||||
private final YBand surfaceBand;
|
||||
private final YBand undergroundBand;
|
||||
|
||||
ResolvedOres(List<ResolvedOre> all) {
|
||||
this.all = List.copyOf(all);
|
||||
this.surface = this.all.stream().filter(ResolvedOre::generatesSurface).toList();
|
||||
this.underground = this.all.stream().filter(ore -> !ore.generatesSurface()).toList();
|
||||
this.surfaceBand = YBand.of(surface);
|
||||
this.undergroundBand = YBand.of(underground);
|
||||
}
|
||||
|
||||
/** {@code settings} ready for {@code engine}; generators the pack wrote as {@code null} are left out. */
|
||||
static ResolvedOres of(OreSettings settings, Engine engine) {
|
||||
List<ResolvedOre> ores = new ArrayList<>();
|
||||
for (OreGenerator generator : settings.generators()) {
|
||||
if (generator != null) {
|
||||
ores.add(ResolvedOre.of(generator, engine));
|
||||
}
|
||||
}
|
||||
return ores.isEmpty() ? NONE : new ResolvedOres(ores);
|
||||
}
|
||||
|
||||
/** The heights where any surface ore can generate. */
|
||||
YBand surfaceBand() {
|
||||
return surfaceBand;
|
||||
}
|
||||
|
||||
/** The heights where any rock-only ore can generate. */
|
||||
YBand undergroundBand() {
|
||||
return undergroundBand;
|
||||
}
|
||||
|
||||
/** Warms every ore in the order the settings list them, each with the next seed. */
|
||||
void warm(LongSupplier seeds) {
|
||||
for (ResolvedOre ore : all) {
|
||||
ore.warm(seeds.getAsLong());
|
||||
}
|
||||
}
|
||||
|
||||
PlatformBlockState generateSurface(int x, int y, int z) {
|
||||
return firstOre(surface, x, y, z);
|
||||
}
|
||||
|
||||
PlatformBlockState generateUnderground(int x, int y, int z) {
|
||||
return firstOre(underground, x, y, z);
|
||||
}
|
||||
|
||||
private static PlatformBlockState firstOre(List<ResolvedOre> ores, int x, int y, int z) {
|
||||
for (int index = 0; index < ores.size(); index++) {
|
||||
PlatformBlockState ore = ores.get(index).generate(x, y, z);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The lowest and highest height any of a set of ores reaches; empty when there are none. */
|
||||
record YBand(boolean hasOres, double min, double max) {
|
||||
static final YBand EMPTY = new YBand(false, 0, 0);
|
||||
|
||||
static YBand of(List<ResolvedOre> ores) {
|
||||
if (ores.isEmpty()) {
|
||||
return EMPTY;
|
||||
}
|
||||
double min = Double.POSITIVE_INFINITY;
|
||||
double max = Double.NEGATIVE_INFINITY;
|
||||
for (ResolvedOre ore : ores) {
|
||||
min = Math.min(min, ore.minY());
|
||||
max = Math.max(max, ore.maxY());
|
||||
}
|
||||
return new YBand(true, min, max);
|
||||
}
|
||||
|
||||
boolean contains(int y) {
|
||||
return hasOres && y >= min && y <= max;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,29 @@
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.FluidPaletteSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersMaxSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.RockPaletteSettings;
|
||||
import art.arcane.iris.builtin.terrain.SeaLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.SlabSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.engine.actuator.ResolvedOres.YBand;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
@@ -51,7 +63,7 @@ import com.volmit.world.PackWorld;
|
||||
* Module {@code iris:terrain}: the chunk's ground, fluids and biome layers. Each column is filled from bedrock up
|
||||
* to its height and the fluid height with its biome's layers, with ore generators of the dimension, region and
|
||||
* biome replacing blocks on the way and the upper dimension's ground filled in from the top. The ore generators' noise
|
||||
* is built ahead of generation, in {@link #warmUp}.
|
||||
* and the rock and fluid palettes' noise are built ahead of generation, in {@link #warmUp}.
|
||||
*/
|
||||
public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
@@ -63,12 +75,25 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(LayersSettings.class);
|
||||
registry.registerSettings(SeaLayersSettings.class);
|
||||
registry.registerSettings(CaveCeilingLayersSettings.class);
|
||||
registry.registerSettings(SlabSettings.class);
|
||||
registry.registerSettings(WallSettings.class);
|
||||
registry.registerSettings(LockLayersSettings.class);
|
||||
registry.registerSettings(LockLayersMaxSettings.class);
|
||||
registry.registerSettings(RockPaletteSettings.class);
|
||||
registry.registerSettings(FluidPaletteSettings.class);
|
||||
registry.registerSettings(OreSettings.class);
|
||||
registry.registerSettings(HideOresSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warmUp(PackWorld world) {
|
||||
new OreWarmUp(IrisPackWorld.of(world).engine()).warm();
|
||||
Engine engine = IrisPackWorld.of(world).engine();
|
||||
TerrainPalettes.of(engine).warm();
|
||||
new OreWarmUp(engine).warm();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,10 +111,20 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
private static final PlatformBlockState BEDROCK = B.getState("BEDROCK");
|
||||
|
||||
private final Engine engine;
|
||||
private final TerrainPalettes palettes;
|
||||
private final BiomeLayers layers;
|
||||
private final TerrainOres ores;
|
||||
private final RNG rng;
|
||||
|
||||
TerrainShaper(Engine engine) {
|
||||
this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine), TerrainOres.of(engine));
|
||||
}
|
||||
|
||||
TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) {
|
||||
this.engine = engine;
|
||||
this.palettes = palettes;
|
||||
this.layers = layers;
|
||||
this.ores = ores;
|
||||
this.rng = new RNG(engine.getSeedManager().getTerrain());
|
||||
}
|
||||
|
||||
@@ -115,19 +150,16 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
int fluidHeight = dimension.getFluidHeight();
|
||||
int clampedFluidHeight = Math.min(chunkHeight, fluidHeight);
|
||||
boolean bedrockEnabled = dimension.isBedrock();
|
||||
boolean hideOres = dimension.isHideOresForHiddenOre();
|
||||
boolean hideOres = HiddenOres.in(dimension);
|
||||
ChunkedDataCache<IrisBiome> biomeCache = context.getBiome();
|
||||
ChunkedDataCache<IrisRegion> regionCache = context.getRegion();
|
||||
ChunkedDataCache<PlatformBlockState> fluidCache = context.getFluid();
|
||||
ChunkedDataCache<PlatformBlockState> rockCache = context.getRock();
|
||||
int realX = xf + x;
|
||||
UpperDimensionContext upperContext = engine.getUpperContext();
|
||||
// Dimension-level ore lookups are chunk-invariant; resolving them per column paid
|
||||
// four accessor chains times 256 per chunk for constants.
|
||||
KList<IrisOreGenerator> dimensionSurfaceOres = hideOres ? null : dimension.getSurfaceOreGenerators();
|
||||
KList<IrisOreGenerator> dimensionUndergroundOres = hideOres ? null : dimension.getUndergroundOreGenerators();
|
||||
IrisOreGeneratorBounds dimensionSurfaceOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : dimension.getSurfaceOreGeneratorBounds();
|
||||
IrisOreGeneratorBounds dimensionUndergroundOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : dimension.getUndergroundOreGeneratorBounds();
|
||||
// the settings lookup times 256 per chunk for a constant.
|
||||
ResolvedOres dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(dimension);
|
||||
YBand dimensionSurfaceBand = dimensionOres.surfaceBand();
|
||||
YBand dimensionUndergroundBand = dimensionOres.undergroundBand();
|
||||
|
||||
for (int zf = 0; zf < chunkDepth; zf++) {
|
||||
int realZ = zf + z;
|
||||
@@ -140,19 +172,17 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
}
|
||||
|
||||
int topY = Math.min(hf, chunkHeight - 1);
|
||||
PlatformBlockState fluid = fluidCache.get(xf, zf);
|
||||
PlatformBlockState rock = rockCache.get(xf, zf);
|
||||
PlatformBlockState fluid = palettes.fluidAt(realX, realZ);
|
||||
PlatformBlockState rock = palettes.rockAt(realX, realZ);
|
||||
PlatformBlockState mappedSurfaceBlock = complex.getImageMapRuntime().sampleSurfaceBlock(realX, realZ);
|
||||
KList<IrisOreGenerator> biomeSurfaceOres = hideOres ? null : biome.getSurfaceOreGenerators();
|
||||
KList<IrisOreGenerator> regionSurfaceOres = hideOres ? null : region.getSurfaceOreGenerators();
|
||||
KList<IrisOreGenerator> biomeUndergroundOres = hideOres ? null : biome.getUndergroundOreGenerators();
|
||||
KList<IrisOreGenerator> regionUndergroundOres = hideOres ? null : region.getUndergroundOreGenerators();
|
||||
IrisOreGeneratorBounds biomeSurfaceOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : biome.getSurfaceOreGeneratorBounds();
|
||||
IrisOreGeneratorBounds regionSurfaceOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : region.getSurfaceOreGeneratorBounds();
|
||||
IrisOreGeneratorBounds biomeUndergroundOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : biome.getUndergroundOreGeneratorBounds();
|
||||
IrisOreGeneratorBounds regionUndergroundOreBounds = hideOres ? IrisOreGeneratorBounds.EMPTY : region.getUndergroundOreGeneratorBounds();
|
||||
boolean hasSurfaceOres = biomeSurfaceOreBounds.hasOres() || regionSurfaceOreBounds.hasOres() || dimensionSurfaceOreBounds.hasOres();
|
||||
boolean hasUndergroundOres = biomeUndergroundOreBounds.hasOres() || regionUndergroundOreBounds.hasOres() || dimensionUndergroundOreBounds.hasOres();
|
||||
ResolvedOres biomeOres = hideOres ? ResolvedOres.NONE : ores.of(biome);
|
||||
ResolvedOres regionOres = hideOres ? ResolvedOres.NONE : ores.of(region);
|
||||
YBand biomeSurfaceBand = biomeOres.surfaceBand();
|
||||
YBand regionSurfaceBand = regionOres.surfaceBand();
|
||||
YBand biomeUndergroundBand = biomeOres.undergroundBand();
|
||||
YBand regionUndergroundBand = regionOres.undergroundBand();
|
||||
boolean hasSurfaceOres = biomeSurfaceBand.hasOres() || regionSurfaceBand.hasOres() || dimensionSurfaceBand.hasOres();
|
||||
boolean hasUndergroundOres = biomeUndergroundBand.hasOres() || regionUndergroundBand.hasOres() || dimensionUndergroundBand.hasOres();
|
||||
KList<PlatformBlockState> blocks = null;
|
||||
KList<PlatformBlockState> fblocks = null;
|
||||
|
||||
@@ -164,14 +194,14 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
|
||||
PlatformBlockState ore = null;
|
||||
if (hasSurfaceOres) {
|
||||
if (biomeSurfaceOreBounds.contains(i)) {
|
||||
ore = generateOres(biomeSurfaceOres, realX, i, realZ, localRng, data);
|
||||
if (biomeSurfaceBand.contains(i)) {
|
||||
ore = biomeOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionSurfaceOreBounds.contains(i)) {
|
||||
ore = generateOres(regionSurfaceOres, realX, i, realZ, localRng, data);
|
||||
if (ore == null && regionSurfaceBand.contains(i)) {
|
||||
ore = regionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionSurfaceOreBounds.contains(i)) {
|
||||
ore = generateOres(dimensionSurfaceOres, realX, i, realZ, localRng, data);
|
||||
if (ore == null && dimensionSurfaceBand.contains(i)) {
|
||||
ore = dimensionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
if (ore != null) {
|
||||
@@ -182,7 +212,7 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
if (i > he && i <= hf) {
|
||||
int fdepth = hf - i;
|
||||
if (fblocks == null) {
|
||||
fblocks = biome.generateSeaLayers(realX, realZ, localRng, hf - he, data);
|
||||
fblocks = layers.generateSeaLayers(biome, realX, realZ, localRng, hf - he, data);
|
||||
}
|
||||
|
||||
if (fblocks.hasIndex(fdepth)) {
|
||||
@@ -200,7 +230,7 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
blocks = biome.generateLayers(dimension, realX, realZ, localRng, he, he, data, complex);
|
||||
blocks = layers.generateLayers(biome, dimension, realX, realZ, localRng, he, he, data, complex);
|
||||
}
|
||||
|
||||
if (blocks.hasIndex(depth)) {
|
||||
@@ -209,14 +239,14 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
}
|
||||
|
||||
if (hasUndergroundOres) {
|
||||
if (biomeUndergroundOreBounds.contains(i)) {
|
||||
ore = generateOres(biomeUndergroundOres, realX, i, realZ, localRng, data);
|
||||
if (biomeUndergroundBand.contains(i)) {
|
||||
ore = biomeOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionUndergroundOreBounds.contains(i)) {
|
||||
ore = generateOres(regionUndergroundOres, realX, i, realZ, localRng, data);
|
||||
if (ore == null && regionUndergroundBand.contains(i)) {
|
||||
ore = regionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionUndergroundOreBounds.contains(i)) {
|
||||
ore = generateOres(dimensionUndergroundOres, realX, i, realZ, localRng, data);
|
||||
if (ore == null && dimensionUndergroundBand.contains(i)) {
|
||||
ore = dimensionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,11 +265,11 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
|
||||
if (upperSurfaceY < chunkHeight - 1) {
|
||||
IrisBiome upperBiome = upperContext.getUpperBiome(realX, realZ);
|
||||
PlatformBlockState upperRock = upperContext.getRockBlock(realX, realZ);
|
||||
PlatformBlockState upperRock = palettes.upperRockAt(upperContext, realX, realZ);
|
||||
PlatformBlockState upperMappedSurface = upperContext.getSurfaceBlock(realX, realZ);
|
||||
int upperThickness = chunkHeight - 1 - upperSurfaceY;
|
||||
KList<PlatformBlockState> upperBlocks = upperBiome != null
|
||||
? upperBiome.generateLayers(upperContext.getDimension(),
|
||||
? layers.generateLayers(upperBiome, upperContext.getDimension(),
|
||||
realX, realZ, localRng, upperThickness, upperThickness,
|
||||
upperContext.getData(), complex)
|
||||
: null;
|
||||
@@ -264,22 +294,5 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PlatformBlockState generateOres(KList<IrisOreGenerator> oreGenerators, int x, int y, int z, RNG rng, IrisData data) {
|
||||
if (oreGenerators == null || oreGenerators.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int oreCount = oreGenerators.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = oreGenerators.get(oreIndex);
|
||||
PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* What the terrain module keeps for one world: the ore generators of its dimension, regions and biomes made ready
|
||||
* ({@link ResolvedOres}), built from their {@link OreSettings} when first asked for or ahead of generation by {@link OreWarmUp}.
|
||||
*/
|
||||
final class TerrainOres {
|
||||
private final Engine engine;
|
||||
private final Map<OreSettings, ResolvedOres> resolved = new ConcurrentHashMap<>();
|
||||
|
||||
TerrainOres(Engine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/** The ores of the world {@code engine} generates now. */
|
||||
static TerrainOres of(Engine engine) {
|
||||
return engine.getGeneration().state(TerrainOres.class, TerrainOres::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ore generators {@code owner}, a dimension, region or biome, declares; {@link ResolvedOres#NONE} when it declares none. The
|
||||
* terrain asks this for two owners per column, so a resolved set is read without taking the map's lock.
|
||||
*/
|
||||
ResolvedOres of(IrisRegistrant owner) {
|
||||
OreSettings settings = owner.getModuleSettings().find(OreSettings.class).orElse(null);
|
||||
if (settings == null) {
|
||||
return ResolvedOres.NONE;
|
||||
}
|
||||
ResolvedOres existing = resolved.get(settings);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, engine));
|
||||
}
|
||||
}
|
||||
@@ -18,20 +18,25 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.BlockDrop;
|
||||
import art.arcane.iris.builtin.loot.BlockDropSettings;
|
||||
import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.loot.IrisBlockDrops;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.service.BlockDrops;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* How {@code iris:loot} drops items for broken blocks: the block drops of the biome, the region and the dimension, the
|
||||
@@ -44,23 +49,53 @@ public final class BlockDropping implements BlockDrops {
|
||||
int x = broken.position().x();
|
||||
int y = broken.position().y();
|
||||
int z = broken.position().z();
|
||||
PlatformBlockState block = IrisPlatforms.get().registries().block(broken.block().key());
|
||||
String brokenKey = IrisPlatforms.get().registries().block(broken.block().key()).key();
|
||||
ResolvedDrops resolved = world.state(ResolvedDrops.class, ignored -> new ResolvedDrops());
|
||||
|
||||
IrisBiome biome = engine.getBiome(x, y, z);
|
||||
List<IrisBlockDrops> providers = dropsFor(biome.getBlockDrops(), block, engine);
|
||||
if (providers.stream().noneMatch(IrisBlockDrops::isSkipParents)) {
|
||||
List<ResolvedBlockDrop> providers = dropsFor(biome, brokenKey, resolved, world);
|
||||
if (providers.stream().noneMatch(provider -> provider.drop().skipParents())) {
|
||||
IrisRegion region = engine.getRegion(x, z);
|
||||
providers.addAll(dropsFor(region.getBlockDrops(), block, engine));
|
||||
providers.addAll(dropsFor(engine.getDimension().getBlockDrops(), block, engine));
|
||||
providers.addAll(dropsFor(region, brokenKey, resolved, world));
|
||||
providers.addAll(dropsFor(engine.getDimension(), brokenKey, resolved, world));
|
||||
}
|
||||
|
||||
LootItems items = new LootItems(world.resources().items(), false);
|
||||
List<ItemDrop> drops = new ArrayList<>();
|
||||
providers.forEach(provider -> provider.fillDrops(items, drops));
|
||||
return new Result(drops, providers.stream().anyMatch(IrisBlockDrops::isReplaceVanillaDrops));
|
||||
providers.forEach(provider -> fillDrops(provider.drop(), items, drops));
|
||||
return new Result(drops, providers.stream().anyMatch(provider -> provider.drop().replaceVanillaDrops()));
|
||||
}
|
||||
|
||||
private static List<IrisBlockDrops> dropsFor(KList<IrisBlockDrops> candidates, PlatformBlockState block, Engine engine) {
|
||||
return new KList<>(candidates.stream().filter(drops -> drops.shouldDropFor(block, engine.getData())).toList());
|
||||
/** Adds the items of the drops that pass their rarity to {@code into}. */
|
||||
private static void fillDrops(BlockDrop drop, LootItems items, List<ItemDrop> into) {
|
||||
for (LootEntry entry : drop.drops()) {
|
||||
if (!LootResolver.oneIn(RNG.r, entry.rarity())) {
|
||||
continue;
|
||||
}
|
||||
ItemDrop given = items.give(entry, RNG.r);
|
||||
if (given != null) {
|
||||
into.add(given);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ResolvedBlockDrop> dropsFor(IrisRegistrant owner, String brokenKey, ResolvedDrops resolved, PackWorld world) {
|
||||
List<ResolvedBlockDrop> matching = new ArrayList<>();
|
||||
for (BlockDrop drop : owner.getModuleSettings().find(BlockDropSettings.class).map(BlockDropSettings::drops).orElse(List.of())) {
|
||||
ResolvedBlockDrop candidate = resolved.of(drop, world);
|
||||
if (candidate.dropsFor(brokenKey)) {
|
||||
matching.add(candidate);
|
||||
}
|
||||
}
|
||||
return matching;
|
||||
}
|
||||
|
||||
/** The drops of the world with their blocks resolved, once per drop. */
|
||||
private static final class ResolvedDrops {
|
||||
private final ConcurrentMap<BlockDrop, ResolvedBlockDrop> byDrop = new ConcurrentHashMap<>();
|
||||
|
||||
private ResolvedBlockDrop of(BlockDrop drop, PackWorld world) {
|
||||
return byDrop.computeIfAbsent(drop, key -> ResolvedBlockDrop.of(key, world.resources().blocks()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,22 +18,22 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.framework.PlacedObject;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
import art.arcane.iris.engine.object.loot.IrisVanillaLootTable;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.service.Loot;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* How {@code iris:loot} fills containers: the tables of the object placed around a container, then those of the
|
||||
@@ -47,36 +47,42 @@ public final class LootGiving implements Loot {
|
||||
int x = site.position().x();
|
||||
int z = site.position().z();
|
||||
int relativeY = site.position().y();
|
||||
RNG rng = LootResolver.containerRng(lootSeed(engine), x, relativeY + engine.getMinHeight(), z);
|
||||
int worldY = relativeY + engine.getMinHeight();
|
||||
RNG rng = LootResolver.containerRng(lootSeed(engine), x, worldY, z);
|
||||
|
||||
List<IrisLootTable> tables = new KList<>();
|
||||
List<Source> sources = new ArrayList<>();
|
||||
boolean objectLootDefined = site.nativeLootDefined();
|
||||
IrisObjectPlacement placement = site.container() == null ? null : placementAt(engine, x, relativeY, z);
|
||||
if (placement != null) {
|
||||
objectLootDefined = objectLootDefined || placement.getLoot().isNotEmpty() || placement.getVanillaLoot().isNotEmpty();
|
||||
IrisLootTable table = placement.getTable(platformState(site), engine.getData(), rng);
|
||||
if (table != null) {
|
||||
tables.add(table);
|
||||
Source picked = placementLoot(world, engine).pick(placement.getVanillaLoot(), placement.getLoot(), platformState(site), rng, x, worldY, z);
|
||||
if (picked != null) {
|
||||
sources.add(picked);
|
||||
if (placement.isOverrideGlobalLoot()) {
|
||||
return sourcesOf(engine, site, List.of(table));
|
||||
return sources;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LootTables.resolveEnvironmentSources(tables, engine, rng, x, relativeY, z, objectLootDefined, table -> table);
|
||||
return sourcesOf(engine, site, tables);
|
||||
LootTables.resolveEnvironmentSources(sources, engine, rng, x, relativeY, z, objectLootDefined, Table::new);
|
||||
return sources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDrop> items(PackWorld world, Site site, String key) {
|
||||
Engine engine = engine(world);
|
||||
IrisLootTable table = LootResources.table(engine.getData(), key);
|
||||
LootTable table = LootResources.table(engine.getData(), key);
|
||||
if (table == null) {
|
||||
return List.of();
|
||||
}
|
||||
int worldY = site.position().y() + engine.getMinHeight();
|
||||
return new LootItems(world.resources().items(), site.debug())
|
||||
.draw(table, lootSeed(engine), site.position().x(), worldY, site.position().z());
|
||||
.draw(key, table, lootSeed(engine), site.position().x(), worldY, site.position().z());
|
||||
}
|
||||
|
||||
private static PlacementLoot placementLoot(PackWorld world, Engine engine) {
|
||||
PlatformLootTables platformTables = world.state(PlatformLootTables.class, ignored -> new PlatformLootTables());
|
||||
return new PlacementLoot(engine.getData(), platformTables::keys, lootSeed(engine));
|
||||
}
|
||||
|
||||
private static IrisObjectPlacement placementAt(Engine engine, int x, int relativeY, int z) {
|
||||
@@ -84,22 +90,6 @@ public final class LootGiving implements Loot {
|
||||
return placed == null ? null : placed.getPlacement();
|
||||
}
|
||||
|
||||
private static List<Source> sourcesOf(Engine engine, Site site, List<IrisLootTable> tables) {
|
||||
int worldY = site.position().y() + engine.getMinHeight();
|
||||
List<Source> sources = new KList<>();
|
||||
for (IrisLootTable table : tables) {
|
||||
if (table instanceof IrisVanillaLootTable vanilla) {
|
||||
long seed = LootTables.seed(lootSeed(engine), vanilla, site.position().x(), worldY, site.position().z());
|
||||
sources.add(new PlatformTable(vanilla.getLootTableKey(), seed));
|
||||
continue;
|
||||
}
|
||||
if (table != null && table.getLoadKey() != null) {
|
||||
sources.add(new Table(table.getLoadKey()));
|
||||
}
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
|
||||
private static PlatformBlockState platformState(Site site) {
|
||||
return IrisPlatforms.get().registries().block(site.container().key());
|
||||
}
|
||||
@@ -111,4 +101,18 @@ public final class LootGiving implements Loot {
|
||||
private static Engine engine(PackWorld world) {
|
||||
return IrisPackWorld.of(world).engine();
|
||||
}
|
||||
|
||||
/** The loot table keys of the platform, which do not change while a world runs. */
|
||||
private static final class PlatformLootTables {
|
||||
private volatile Set<String> keys;
|
||||
|
||||
private Set<String> keys() {
|
||||
Set<String> known = keys;
|
||||
if (known == null) {
|
||||
known = PlacementLoot.platformTableKeys();
|
||||
keys = known;
|
||||
}
|
||||
return known;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.ItemAttributeModifier;
|
||||
import art.arcane.iris.builtin.loot.LootEnchantment;
|
||||
import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.builtin.loot.LootSlot;
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.object.entity.IrisAttributeModifier;
|
||||
import art.arcane.iris.engine.object.loot.IrisEnchantment;
|
||||
import art.arcane.iris.engine.object.loot.InventorySlotType;
|
||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.item.ItemAttribute;
|
||||
import com.volmit.item.ItemDrop;
|
||||
@@ -54,26 +54,28 @@ public final class LootItems {
|
||||
}
|
||||
|
||||
/**
|
||||
* The items {@code table} gives at the spot {@code x}, {@code y}, {@code z} (world coordinates): picks entries
|
||||
* from the table's own random stream until it has the number of items the table asks for or runs out of tries.
|
||||
* The items {@code table}, which the pack names {@code tableKey}, gives at the spot {@code x}, {@code y}, {@code z}
|
||||
* (world coordinates): picks entries from the table's own random stream until it has the number of items the table
|
||||
* asks for or runs out of tries.
|
||||
*/
|
||||
public List<ItemDrop> draw(IrisLootTable table, long lootSeed, int x, int y, int z) {
|
||||
public List<ItemDrop> draw(String tableKey, LootTable table, long lootSeed, int x, int y, int z) {
|
||||
List<ItemDrop> drops = new ArrayList<>();
|
||||
List<IrisLoot> entries = table.getLoot();
|
||||
if (entries.isEmpty() || table.getMaxTries() <= 0) {
|
||||
List<LootEntry> entries = table.loot();
|
||||
if (entries.isEmpty() || table.maxTries() <= 0) {
|
||||
return drops;
|
||||
}
|
||||
|
||||
RNG rng = LootTables.rng(lootSeed, table, x, y, z);
|
||||
int wanted = Math.max(0, LootResolver.inclusive(rng, table.getMinPicked(), table.getMaxPicked()));
|
||||
String identity = LootTables.identity(tableKey);
|
||||
RNG rng = LootTables.rng(lootSeed, identity, x, y, z);
|
||||
int wanted = Math.max(0, LootResolver.inclusive(rng, table.minPicked(), table.maxPicked()));
|
||||
int tries = 0;
|
||||
while (drops.size() < wanted && tries++ < table.getMaxTries()) {
|
||||
while (drops.size() < wanted && tries++ < table.maxTries()) {
|
||||
int index = rng.nextInt(entries.size());
|
||||
IrisLoot entry = entries.get(index);
|
||||
if (entry == null || entry.getSlotTypes() != InventorySlotType.STORAGE) {
|
||||
LootEntry entry = entries.get(index);
|
||||
if (entry == null || entry.slotTypes() != LootSlot.STORAGE) {
|
||||
continue;
|
||||
}
|
||||
ItemDrop drop = drawEntry(entry, table, rng, lootSeed, index, x, y, z);
|
||||
ItemDrop drop = drawEntry(entry, table, identity, rng, lootSeed, index, x, y, z);
|
||||
if (drop != null) {
|
||||
drops.add(drop);
|
||||
}
|
||||
@@ -82,66 +84,67 @@ public final class LootItems {
|
||||
}
|
||||
|
||||
/** The item {@code entry} gives when nothing else decides whether it does, such as a block's drop or a mob's equipment; null for no item. */
|
||||
public ItemDrop give(IrisLoot entry, RNG rng) {
|
||||
public ItemDrop give(LootEntry entry, RNG rng) {
|
||||
return resolve(entry, rng, null);
|
||||
}
|
||||
|
||||
private ItemDrop drawEntry(IrisLoot entry, IrisLootTable table, RNG rng, long lootSeed, int index, int x, int y, int z) {
|
||||
long combinedRarity = LootResolver.combinedRarity(entry.getRarity(), table.getRarity());
|
||||
if (!LootTables.spatialOneIn(lootSeed, table, index, x, y, z, combinedRarity)) {
|
||||
private ItemDrop drawEntry(LootEntry entry, LootTable table, String identity, RNG rng, long lootSeed, int index, int x, int y, int z) {
|
||||
long combinedRarity = LootResolver.combinedRarity(entry.rarity(), table.rarity());
|
||||
if (!LootTables.spatialOneIn(lootSeed, identity, index, x, y, z, combinedRarity)) {
|
||||
return null;
|
||||
}
|
||||
return resolve(entry, rng, table);
|
||||
}
|
||||
|
||||
private ItemDrop resolve(IrisLoot entry, RNG rng, IrisLootTable table) {
|
||||
String type = entry.getTypeKey();
|
||||
private ItemDrop resolve(LootEntry entry, RNG rng, LootTable table) {
|
||||
String type = entry.type();
|
||||
OptionalInt maxDurability = items.maxDurability(type);
|
||||
if (maxDurability.isEmpty() || isAir(type)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int amount = Math.max(MIN_AMOUNT, LootResolver.inclusive(rng, entry.getMinAmount(), entry.getMaxAmount()));
|
||||
int amount = Math.max(MIN_AMOUNT, LootResolver.inclusive(rng, entry.minAmount(), entry.maxAmount()));
|
||||
List<ItemEnchantment> enchantments = drawEnchantments(entry, rng);
|
||||
List<ItemAttribute> attributes = drawAttributes(entry, rng);
|
||||
Double damage = maxDurability.getAsInt() > 0 ? 1D - rng.d(entry.getMinDurability(), entry.getMaxDurability()) : null;
|
||||
return new ItemDrop(type, amount, entry.getDisplayName(), entry.getLore(), enchantments, attributes,
|
||||
entry.isUnbreakable(), entry.getItemFlags(), entry.getCustomModel(), damage, entry.getLeatherColor(),
|
||||
entry.getDyeColorKey(), entry.getCustomNbt(), debug ? sourceOf(entry, table) : null);
|
||||
Double damage = maxDurability.getAsInt() > 0 ? 1D - rng.d(entry.minDurability(), entry.maxDurability()) : null;
|
||||
return new ItemDrop(type, amount, entry.displayName(), entry.lore(), enchantments, attributes,
|
||||
entry.unbreakable(), entry.itemFlags(), entry.customModel(), damage, entry.leatherColor(),
|
||||
entry.dyeColor(), entry.customNbt(), debug ? sourceOf(entry, table) : null);
|
||||
}
|
||||
|
||||
private static List<ItemEnchantment> drawEnchantments(IrisLoot entry, RNG rng) {
|
||||
private static List<ItemEnchantment> drawEnchantments(LootEntry entry, RNG rng) {
|
||||
List<ItemEnchantment> enchantments = new ArrayList<>();
|
||||
for (IrisEnchantment enchantment : entry.getEnchantments()) {
|
||||
String key = enchantment.getEnchantment();
|
||||
if (key == null || key.isBlank() || rng.nextDouble() >= enchantment.getChance()) {
|
||||
for (LootEnchantment enchantment : entry.enchantments()) {
|
||||
String key = enchantment.enchantment();
|
||||
if (key == null || key.isBlank() || rng.nextDouble() >= enchantment.chance()) {
|
||||
continue;
|
||||
}
|
||||
enchantments.add(new ItemEnchantment(key, Math.max(1, enchantment.getLevel(rng))));
|
||||
int level = LootResolver.inclusive(rng, enchantment.minLevel(), enchantment.maxLevel());
|
||||
enchantments.add(new ItemEnchantment(key, Math.max(1, level)));
|
||||
}
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
private static List<ItemAttribute> drawAttributes(IrisLoot entry, RNG rng) {
|
||||
private static List<ItemAttribute> drawAttributes(LootEntry entry, RNG rng) {
|
||||
List<ItemAttribute> attributes = new ArrayList<>();
|
||||
for (IrisAttributeModifier modifier : entry.getAttributes()) {
|
||||
if (rng.nextDouble() >= modifier.getChance()) {
|
||||
for (ItemAttributeModifier modifier : entry.attributes()) {
|
||||
if (rng.nextDouble() >= modifier.chance()) {
|
||||
continue;
|
||||
}
|
||||
String attribute = modifier.getAttribute();
|
||||
String attribute = modifier.attribute();
|
||||
if (attribute == null || attribute.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
attributes.add(new ItemAttribute(attribute, modifier.getName(), modifier.getOperation(), modifier.getAmount(rng)));
|
||||
attributes.add(new ItemAttribute(attribute, modifier.name(), modifier.operation(), rng.d(modifier.minAmount(), modifier.maxAmount())));
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
private static ItemDrop.Source sourceOf(IrisLoot entry, IrisLootTable table) {
|
||||
private static ItemDrop.Source sourceOf(LootEntry entry, LootTable table) {
|
||||
if (table == null) {
|
||||
return new ItemDrop.Source(null, 0, entry.getRarity());
|
||||
return new ItemDrop.Source(null, 0, entry.rarity());
|
||||
}
|
||||
return new ItemDrop.Source(table.getName(), table.getRarity(), entry.getRarity());
|
||||
return new ItemDrop.Source(table.name(), table.rarity(), entry.rarity());
|
||||
}
|
||||
|
||||
private static boolean isAir(String type) {
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.BlockDropSettings;
|
||||
import art.arcane.iris.builtin.loot.LootSettings;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -26,9 +28,10 @@ import com.volmit.service.Loot;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:loot}: the loot tables of the pack ({@link LootResources}) and the items they and the block drops
|
||||
* of the dimension, regions and biomes give. It checks the tables and the references to them ({@link LootValidator}). It has no generation stage; Iris asks it through {@link Loot} when a container is filled and through
|
||||
* {@link BlockDrops} when a player breaks a block.
|
||||
* Module {@code iris:loot}: the loot tables of the pack ({@link LootResources}), the {@link LootSettings} and
|
||||
* {@link BlockDropSettings} that dimensions, regions and biomes declare, and the items they give. It checks the tables
|
||||
* and the references to them ({@link LootValidator}). It has no generation stage; Iris asks it through {@link Loot} when
|
||||
* a container is filled and through {@link BlockDrops} when a player breaks a block.
|
||||
*/
|
||||
public final class LootModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
@@ -44,6 +47,8 @@ public final class LootModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(LootSettings.class);
|
||||
registry.registerSettings(BlockDropSettings.class);
|
||||
LootResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerValidator(new LootValidator());
|
||||
registry.registerService(Loot.class, new LootGiving());
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
|
||||
@@ -37,7 +36,7 @@ import java.util.List;
|
||||
*/
|
||||
public final class LootResources {
|
||||
/** Loot tables, in {@code loot/}. */
|
||||
public static final ResourceKind<IrisLootTable> TABLES = ResourceKind.of("iris:loot/table", "loot", IrisLootTable.class);
|
||||
public static final ResourceKind<LootTable> TABLES = ResourceKind.of("iris:loot/table", "loot", LootTable.class);
|
||||
|
||||
private LootResources() {
|
||||
}
|
||||
@@ -47,7 +46,7 @@ public final class LootResources {
|
||||
return List.of(TABLES);
|
||||
}
|
||||
|
||||
public static IrisLootTable table(IrisData data, String key) {
|
||||
public static LootTable table(IrisData data, String key) {
|
||||
if (key == null || key.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
@@ -59,18 +58,6 @@ public final class LootResources {
|
||||
}
|
||||
}
|
||||
|
||||
/** The tables of the pack named by {@code keys}, in order, without the ones the pack lacks. */
|
||||
public static KList<IrisLootTable> tables(IrisData data, List<String> keys) {
|
||||
KList<IrisLootTable> tables = new KList<>();
|
||||
for (String key : keys) {
|
||||
IrisLootTable table = table(data, key);
|
||||
if (table != null) {
|
||||
tables.add(table);
|
||||
}
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
/** The key of every loot table of the pack, in key order. */
|
||||
public static List<String> tableKeys(IrisData data) {
|
||||
return data.getPackResources().ids(TABLES.type()).stream().map(ResourceId::path).toList();
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.LootMode;
|
||||
import art.arcane.iris.builtin.loot.LootSettings;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootMode;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootReference;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,42 +33,46 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Which loot tables a place in the world draws from, and the random streams that draw from them: the part of loot
|
||||
* that reads the pack's tables, loot references and layout. The streams themselves are
|
||||
* {@link LootResolver}'s; here a table is named by its {@linkplain #identity identity}.
|
||||
* that reads the pack's tables, loot settings and layout. The streams themselves are {@link LootResolver}'s; here a
|
||||
* table is named by its {@linkplain #identity identity}, the key the pack names it by.
|
||||
*/
|
||||
public final class LootTables {
|
||||
private static final String VANILLA_IDENTITY_PREFIX = "Vanilla ";
|
||||
|
||||
private LootTables() {
|
||||
}
|
||||
|
||||
/** What names a table in the random streams: its key, else its name. */
|
||||
public static String identity(IrisLootTable table) {
|
||||
if (table == null) {
|
||||
return "";
|
||||
}
|
||||
String loadKey = table.getLoadKey();
|
||||
if (loadKey != null && !loadKey.isBlank()) {
|
||||
return loadKey;
|
||||
}
|
||||
String name = table.getName();
|
||||
return name == null ? "" : name;
|
||||
/** What names a table in the random streams: the key a pack table is named by. */
|
||||
public static String identity(String tableKey) {
|
||||
return tableKey;
|
||||
}
|
||||
|
||||
public static RNG rng(long lootSeed, IrisLootTable table, int x, int y, int z) {
|
||||
return LootResolver.tableRng(lootSeed, identity(table), x, y, z);
|
||||
/** What names a table of the platform in the random streams. */
|
||||
public static String platformIdentity(String platformKey) {
|
||||
return VANILLA_IDENTITY_PREFIX + platformKey;
|
||||
}
|
||||
|
||||
public static long seed(long lootSeed, IrisLootTable table, int x, int y, int z) {
|
||||
return LootResolver.tableSeed(lootSeed, identity(table), x, y, z);
|
||||
public static RNG rng(long lootSeed, String identity, int x, int y, int z) {
|
||||
return LootResolver.tableRng(lootSeed, identity, x, y, z);
|
||||
}
|
||||
|
||||
public static boolean spatialOneIn(long lootSeed, IrisLootTable table, int entryIndex, int x, int y, int z, long rarity) {
|
||||
return LootResolver.spatialOneIn(lootSeed, identity(table), entryIndex, x, y, z, rarity);
|
||||
public static long seed(long lootSeed, String identity, int x, int y, int z) {
|
||||
return LootResolver.tableSeed(lootSeed, identity, x, y, z);
|
||||
}
|
||||
|
||||
public static boolean spatialOneIn(long lootSeed, String identity, int entryIndex, int x, int y, int z, long rarity) {
|
||||
return LootResolver.spatialOneIn(lootSeed, identity, entryIndex, x, y, z, rarity);
|
||||
}
|
||||
|
||||
/** The loot settings a dimension, region or biome declares; the defaults, which add nothing, when it declares none. */
|
||||
public static LootSettings settingsOf(IrisRegistrant owner) {
|
||||
return owner.getModuleSettings().find(LootSettings.class).orElseGet(LootSettings::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the tables of the dimension, the region, the surface biome and (below the surface) the cave biome at a
|
||||
* column to {@code sources}, as their loot references say, then scales their number by the areas' multipliers.
|
||||
* {@code mapper} turns a table into the caller's own source; a null result skips it.
|
||||
* column to {@code sources}, as their loot settings say, then scales their number by the areas' multipliers.
|
||||
* {@code mapper} turns the key of a table into the caller's own source; a null result skips it.
|
||||
*/
|
||||
public static <T> void resolveEnvironmentSources(
|
||||
List<T> sources,
|
||||
@@ -79,7 +82,7 @@ public final class LootTables {
|
||||
int relativeY,
|
||||
int z,
|
||||
boolean objectLootDefined,
|
||||
Function<IrisLootTable, T> mapper
|
||||
Function<String, T> mapper
|
||||
) {
|
||||
IrisRegion region = engine.getComplex().getRegionStream().get(x, z);
|
||||
IrisBiome surfaceBiome = engine.getComplex().getTrueBiomeStream().get(x, z);
|
||||
@@ -91,20 +94,21 @@ public final class LootTables {
|
||||
contextualBiome = surfaceBiome;
|
||||
}
|
||||
|
||||
LootSettings dimensionLoot = settingsOf(engine.getDimension());
|
||||
LootSettings regionLoot = settingsOf(region);
|
||||
LootSettings surfaceLoot = settingsOf(surfaceBiome);
|
||||
boolean distinctContextualBiome = !sameBiome(surfaceBiome, contextualBiome);
|
||||
double multiplier = engine.getDimension().getLoot().getMultiplier()
|
||||
* region.getLoot().getMultiplier()
|
||||
* surfaceBiome.getLoot().getMultiplier();
|
||||
double multiplier = dimensionLoot.multiplier() * regionLoot.multiplier() * surfaceLoot.multiplier();
|
||||
if (distinctContextualBiome) {
|
||||
multiplier *= contextualBiome.getLoot().getMultiplier();
|
||||
multiplier *= settingsOf(contextualBiome).multiplier();
|
||||
}
|
||||
|
||||
boolean fallback = !objectLootDefined;
|
||||
injectReference(sources, engine.getDimension().getLoot(), engine, mapper, fallback);
|
||||
injectReference(sources, region.getLoot(), engine, mapper, fallback);
|
||||
injectReference(sources, surfaceBiome.getLoot(), engine, mapper, fallback);
|
||||
injectReference(sources, dimensionLoot, engine, mapper, fallback);
|
||||
injectReference(sources, regionLoot, engine, mapper, fallback);
|
||||
injectReference(sources, surfaceLoot, engine, mapper, fallback);
|
||||
if (distinctContextualBiome) {
|
||||
injectReference(sources, contextualBiome.getLoot(), engine, mapper, fallback);
|
||||
injectReference(sources, settingsOf(contextualBiome), engine, mapper, fallback);
|
||||
}
|
||||
LootResolver.scaleSources(sources, multiplier, rng);
|
||||
}
|
||||
@@ -113,17 +117,17 @@ public final class LootTables {
|
||||
public static <T> void injectSources(
|
||||
List<T> sources,
|
||||
List<? extends T> additions,
|
||||
IrisLootMode mode,
|
||||
LootMode mode,
|
||||
boolean fallback
|
||||
) {
|
||||
if (mode == IrisLootMode.FALLBACK && !fallback) {
|
||||
if (mode == LootMode.FALLBACK && !fallback) {
|
||||
return;
|
||||
}
|
||||
if (mode == IrisLootMode.CLEAR) {
|
||||
if (mode == LootMode.CLEAR) {
|
||||
sources.clear();
|
||||
return;
|
||||
}
|
||||
if (mode == IrisLootMode.REPLACE) {
|
||||
if (mode == LootMode.REPLACE) {
|
||||
sources.clear();
|
||||
}
|
||||
sources.addAll(additions);
|
||||
@@ -141,22 +145,16 @@ public final class LootTables {
|
||||
|
||||
private static <T> void injectReference(
|
||||
List<T> sources,
|
||||
IrisLootReference reference,
|
||||
LootSettings loot,
|
||||
Engine engine,
|
||||
Function<IrisLootTable, T> mapper,
|
||||
Function<String, T> mapper,
|
||||
boolean fallback
|
||||
) {
|
||||
KList<IrisLootTable> tables = reference.getLootTables(engine.getComplex());
|
||||
KList<T> additions = new KList<>();
|
||||
for (IrisLootTable table : tables) {
|
||||
if (table == null) {
|
||||
continue;
|
||||
}
|
||||
T source = mapper.apply(table);
|
||||
if (source != null) {
|
||||
additions.add(source);
|
||||
}
|
||||
}
|
||||
injectSources(sources, additions, reference.getMode(), fallback);
|
||||
List<T> additions = loot.tables().stream()
|
||||
.filter(key -> LootResources.table(engine.getData(), key) != null)
|
||||
.map(mapper)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
injectSources(sources, additions, loot.mode(), fallback);
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,9 @@ package art.arcane.iris.engine.loot;
|
||||
import art.arcane.iris.core.modules.IrisValidationContext;
|
||||
import art.arcane.iris.core.pack.PackIntegerChecks;
|
||||
import art.arcane.iris.core.pack.PackValidationIo;
|
||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootReference;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.builtin.loot.LootSettings;
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.volmit.validation.Problem;
|
||||
@@ -162,9 +162,9 @@ public final class LootValidator implements Validator {
|
||||
PackIntegerChecks.requireMinimum(path + ".minPicked", minimumPicked, 0, blockingErrors);
|
||||
PackIntegerChecks.requireMinimum(path + ".maxPicked", maximumPicked, 1, blockingErrors);
|
||||
PackIntegerChecks.requireMinimum(path + ".maxTries", maximumTries, 1, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(path + ".minPicked", minimumPicked, IrisLootTable.MAX_PICKED, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(path + ".maxPicked", maximumPicked, IrisLootTable.MAX_PICKED, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(path + ".maxTries", maximumTries, IrisLootTable.MAX_TRIES, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(path + ".minPicked", minimumPicked, LootTable.MAX_PICKED, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(path + ".maxPicked", maximumPicked, LootTable.MAX_PICKED, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(path + ".maxTries", maximumTries, LootTable.MAX_TRIES, blockingErrors);
|
||||
PackIntegerChecks.requireOrdered(path + ".minPicked", minimumPicked, path + ".maxPicked", maximumPicked, blockingErrors);
|
||||
|
||||
JSONArray entries = table.optJSONArray("loot");
|
||||
@@ -189,8 +189,8 @@ public final class LootValidator implements Validator {
|
||||
PackIntegerChecks.requireMinimum(entryPath + ".rarity", entryRarity, 1, blockingErrors);
|
||||
PackIntegerChecks.requireMinimum(entryPath + ".minAmount", minimumAmount, 1, blockingErrors);
|
||||
PackIntegerChecks.requireMinimum(entryPath + ".maxAmount", maximumAmount, 1, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(entryPath + ".minAmount", minimumAmount, IrisLoot.MAX_AMOUNT, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(entryPath + ".maxAmount", maximumAmount, IrisLoot.MAX_AMOUNT, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(entryPath + ".minAmount", minimumAmount, LootEntry.MAX_AMOUNT, blockingErrors);
|
||||
PackIntegerChecks.requireMaximum(entryPath + ".maxAmount", maximumAmount, LootEntry.MAX_AMOUNT, blockingErrors);
|
||||
PackIntegerChecks.requireOrdered(entryPath + ".minAmount", minimumAmount,
|
||||
entryPath + ".maxAmount", maximumAmount, blockingErrors);
|
||||
validateLootEnchantments(entryPath, entry.opt("enchantments"), blockingErrors);
|
||||
@@ -256,9 +256,9 @@ public final class LootValidator implements Validator {
|
||||
if (!(rawMultiplier instanceof Number multiplier)
|
||||
|| !Double.isFinite(multiplier.doubleValue())
|
||||
|| multiplier.doubleValue() < 0D
|
||||
|| multiplier.doubleValue() > IrisLootReference.MAX_MULTIPLIER) {
|
||||
|| multiplier.doubleValue() > LootSettings.MAX_MULTIPLIER) {
|
||||
blockingErrors.add(path + ".multiplier must be a finite number from 0 to "
|
||||
+ (int) IrisLootReference.MAX_MULTIPLIER + ".");
|
||||
+ (int) LootSettings.MAX_MULTIPLIER + ".");
|
||||
}
|
||||
}
|
||||
if (!reference.has("tables")) {
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.object.loot.IObjectLoot;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.service.Loot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* The loot table an object placement gives to one of its containers: the placement's tables and the platform's own,
|
||||
* each with the blocks it applies to and a weight. A table that names the container's exact block wins over one that
|
||||
* names the container's kind of block, which wins over one that names no blocks; among equals the weights pick.
|
||||
*/
|
||||
final class PlacementLoot {
|
||||
private static final String VANILLA_NAMESPACE = "minecraft:";
|
||||
private static final char NAMESPACE_SEPARATOR = ':';
|
||||
private static final char PROPERTIES_START = '[';
|
||||
|
||||
private final IrisData data;
|
||||
private final Supplier<Set<String>> platformTables;
|
||||
private final long lootSeed;
|
||||
|
||||
/** @param platformTables the keys of the loot tables the platform has, asked for only when a placement names one */
|
||||
PlacementLoot(IrisData data, Supplier<Set<String>> platformTables, long lootSeed) {
|
||||
this.data = data;
|
||||
this.platformTables = platformTables;
|
||||
this.lootSeed = lootSeed;
|
||||
}
|
||||
|
||||
/** The platform's loot table keys, which a placement may name, in the form a placement names them. */
|
||||
static Set<String> platformTableKeys() {
|
||||
return Set.copyOf(IrisPlatforms.get().registries().lootTableKeys());
|
||||
}
|
||||
|
||||
/**
|
||||
* The table a placement, whose platform tables are {@code platformLoot} and whose pack tables are {@code packLoot},
|
||||
* gives {@code container}, a storage chest, at the spot {@code x}, {@code worldY}, {@code z}; null when it gives
|
||||
* it none.
|
||||
*/
|
||||
Loot.Source pick(List<? extends IObjectLoot> platformLoot, List<? extends IObjectLoot> packLoot, PlatformBlockState container,
|
||||
RNG rng, int x, int worldY, int z) {
|
||||
Candidates candidates = new Candidates(container);
|
||||
add(candidates, platformLoot, name -> platformSource(name, x, worldY, z));
|
||||
add(candidates, packLoot, this::packSource);
|
||||
List<Candidate> pool = candidates.pool();
|
||||
Candidate picked = LootResolver.pickWeighted(pool, Candidate::weight, rng);
|
||||
return picked == null ? null : picked.source();
|
||||
}
|
||||
|
||||
private void add(Candidates candidates, List<? extends IObjectLoot> entries, Function<String, Loot.Source> sourceOf) {
|
||||
for (IObjectLoot entry : entries) {
|
||||
if (entry == null || entry.getWeight() <= 0) {
|
||||
continue;
|
||||
}
|
||||
Loot.Source source = sourceOf.apply(entry.getName());
|
||||
if (source == null) {
|
||||
IrisLogging.warn("Couldn't find loot table " + entry.getName());
|
||||
continue;
|
||||
}
|
||||
candidates.add(entry, data, new Candidate(source, entry.getWeight()));
|
||||
}
|
||||
}
|
||||
|
||||
private Loot.Source packSource(String key) {
|
||||
return LootResources.table(data, key) == null ? null : new Loot.Table(key);
|
||||
}
|
||||
|
||||
private Loot.Source platformSource(String name, int x, int worldY, int z) {
|
||||
String key = platformKey(name);
|
||||
if (key == null || !platformTables.get().contains(key)) {
|
||||
return null;
|
||||
}
|
||||
return new Loot.PlatformTable(key, LootTables.seed(lootSeed, LootTables.platformIdentity(key), x, worldY, z));
|
||||
}
|
||||
|
||||
/** A placement's name for a platform table as the platform's key for it, or null for a name that cannot be one. */
|
||||
static String platformKey(String name) {
|
||||
if (name == null || name.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
return name.indexOf(NAMESPACE_SEPARATOR) < 0 ? VANILLA_NAMESPACE + name : name;
|
||||
}
|
||||
|
||||
private record Candidate(Loot.Source source, int weight) {
|
||||
}
|
||||
|
||||
/** The candidates for one container, in the groups the placement gives them. */
|
||||
private static final class Candidates {
|
||||
private final String containerKey;
|
||||
private final String containerMaterial;
|
||||
private final List<Candidate> exact = new ArrayList<>();
|
||||
private final List<Candidate> basic = new ArrayList<>();
|
||||
private final List<Candidate> global = new ArrayList<>();
|
||||
|
||||
private Candidates(PlatformBlockState container) {
|
||||
this.containerKey = container.key();
|
||||
this.containerMaterial = materialOf(containerKey);
|
||||
}
|
||||
|
||||
void add(IObjectLoot entry, IrisData data, Candidate candidate) {
|
||||
List<PlatformBlockState> filter = entry.getFilter(data);
|
||||
if (filter.isEmpty()) {
|
||||
global.add(candidate);
|
||||
return;
|
||||
}
|
||||
for (PlatformBlockState filterState : filter) {
|
||||
if (entry.isExact() && filterState.key().equals(containerKey)) {
|
||||
exact.add(candidate);
|
||||
} else if (!entry.isExact() && materialOf(filterState.key()).equals(containerMaterial)) {
|
||||
basic.add(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Candidate> pool() {
|
||||
if (!exact.isEmpty()) {
|
||||
return exact;
|
||||
}
|
||||
return basic.isEmpty() ? global : basic;
|
||||
}
|
||||
|
||||
private static String materialOf(String blockKey) {
|
||||
int properties = blockKey.indexOf(PROPERTIES_START);
|
||||
return properties < 0 ? blockKey : blockKey.substring(0, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.BlockDrop;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/** A {@link BlockDrop} with the blocks it names resolved to the platform's: which broken blocks it drops for. */
|
||||
final class ResolvedBlockDrop {
|
||||
private static final char PROPERTIES_START = '[';
|
||||
|
||||
private final BlockDrop drop;
|
||||
private final boolean exact;
|
||||
private final Set<String> blocks;
|
||||
|
||||
private ResolvedBlockDrop(BlockDrop drop, Set<String> blocks) {
|
||||
this.drop = drop;
|
||||
this.exact = drop.exactBlocks();
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
/** @param blocks the pack's blocks, which the drop's block specs resolve against */
|
||||
static ResolvedBlockDrop of(BlockDrop drop, BlockRegistry blocks) {
|
||||
Set<String> keys = new LinkedHashSet<>();
|
||||
for (BlockSpec spec : drop.blocks()) {
|
||||
PlatformBlockState state = IrisPlatforms.get().registries().block(blocks.resolve(spec).key());
|
||||
if (state != null) {
|
||||
keys.add(comparable(state.key(), drop.exactBlocks()));
|
||||
}
|
||||
}
|
||||
return new ResolvedBlockDrop(drop, keys);
|
||||
}
|
||||
|
||||
BlockDrop drop() {
|
||||
return drop;
|
||||
}
|
||||
|
||||
/** Whether the drop applies to {@code brokenKey}, the platform's key for the broken block: its exact state, or just its kind of block. */
|
||||
boolean dropsFor(String brokenKey) {
|
||||
return blocks.contains(comparable(brokenKey, exact));
|
||||
}
|
||||
|
||||
private static String comparable(String key, boolean exact) {
|
||||
if (exact) {
|
||||
return key;
|
||||
}
|
||||
int properties = key.indexOf(PROPERTIES_START);
|
||||
return properties < 0 ? key : key.substring(0, properties);
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,18 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.core.modules.IrisValues;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CaveProfiles;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
|
||||
import art.arcane.iris.engine.object.terrain.carving.ResolvedCarvingEntry;
|
||||
import art.arcane.iris.engine.modifier.CaveBiomeBands;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingBands;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingResolver;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -89,7 +94,7 @@ public class CaveCarving {
|
||||
/** Carves the caves of the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */
|
||||
public void carve(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||
IrisComplex complex = context.getComplex();
|
||||
IrisDimensionCarvingResolver.State resolverState = new IrisDimensionCarvingResolver.State();
|
||||
CarvingResolver.State resolverState = new CarvingResolver.State();
|
||||
BlendScratch blendScratch = BLEND_SCRATCH.get();
|
||||
int[] chunkSurfaceHeights = prepareChunkSurfaceHeights(x, z, context, blendScratch.chunkSurfaceHeights);
|
||||
PrecisionStopwatch resolveStopwatch = PrecisionStopwatch.start();
|
||||
@@ -200,7 +205,7 @@ public class CaveCarving {
|
||||
}
|
||||
}
|
||||
|
||||
private List<WeightedProfile> resolveWeightedProfiles(int chunkX, int chunkZ, IrisComplex complex, IrisDimensionCarvingResolver.State resolverState) {
|
||||
private List<WeightedProfile> resolveWeightedProfiles(int chunkX, int chunkZ, IrisComplex complex, CarvingResolver.State resolverState) {
|
||||
BlendScratch blendScratch = BLEND_SCRATCH.get();
|
||||
CaveProfile[] profileField = blendScratch.profileField;
|
||||
Map<CaveProfile, double[]> columnProfileWeights = blendScratch.columnProfileWeights;
|
||||
@@ -296,40 +301,40 @@ public class CaveCarving {
|
||||
return resolvedProfiles;
|
||||
}
|
||||
|
||||
private List<WeightedProfile> resolveDimensionCarvingProfiles(int chunkX, int chunkZ, IrisDimensionCarvingResolver.State resolverState, BlendScratch blendScratch) {
|
||||
private List<WeightedProfile> resolveDimensionCarvingProfiles(int chunkX, int chunkZ, CarvingResolver.State resolverState, BlendScratch blendScratch) {
|
||||
List<WeightedProfile> weightedProfiles = new ArrayList<>();
|
||||
List<IrisDimensionCarvingEntry> entries = engine.getDimension().getCarving();
|
||||
if (entries == null || entries.isEmpty()) {
|
||||
List<ResolvedCarvingEntry> entries = CarvingBands.of(engine).entries();
|
||||
if (entries.isEmpty()) {
|
||||
return weightedProfiles;
|
||||
}
|
||||
|
||||
Map<IrisDimensionCarvingEntry, IrisDimensionCarvingEntry[]> dimensionColumnPlans = blendScratch.dimensionColumnPlans;
|
||||
Map<ResolvedCarvingEntry, ResolvedCarvingEntry[]> dimensionColumnPlans = blendScratch.dimensionColumnPlans;
|
||||
dimensionColumnPlans.clear();
|
||||
|
||||
for (IrisDimensionCarvingEntry entry : entries) {
|
||||
if (entry == null || !entry.isEnabled()) {
|
||||
for (ResolvedCarvingEntry entry : entries) {
|
||||
if (!entry.enabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IrisBiome rootBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, entry, resolverState);
|
||||
IrisBiome rootBiome = CarvingResolver.resolveEntryBiome(engine, entry, resolverState);
|
||||
if (rootBiome == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IrisDimensionCarvingEntry[] columnPlan = dimensionColumnPlans.computeIfAbsent(entry, key -> new IrisDimensionCarvingEntry[CHUNK_AREA]);
|
||||
ResolvedCarvingEntry[] columnPlan = dimensionColumnPlans.computeIfAbsent(entry, key -> new ResolvedCarvingEntry[CHUNK_AREA]);
|
||||
buildDimensionColumnPlan(columnPlan, chunkX, chunkZ, entry, resolverState);
|
||||
|
||||
Map<CaveProfile, double[]> rootProfileColumnWeights = new IdentityHashMap<>();
|
||||
List<CaveProfile> rootProfileOrder = new ArrayList<>();
|
||||
IrisRange worldYRange = entry.getWorldYRange();
|
||||
IrisRange worldYRange = entry.worldYRange() == null ? null : IrisValues.range(entry.worldYRange());
|
||||
for (int columnIndex = 0; columnIndex < CHUNK_AREA; columnIndex++) {
|
||||
IrisDimensionCarvingEntry resolvedEntry = columnPlan[columnIndex];
|
||||
IrisBiome resolvedBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, resolvedEntry, resolverState);
|
||||
ResolvedCarvingEntry resolvedEntry = columnPlan[columnIndex];
|
||||
IrisBiome resolvedBiome = CarvingResolver.resolveEntryBiome(engine, resolvedEntry, resolverState);
|
||||
if (resolvedBiome == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CaveProfile profile = resolvedBiome.getCaveProfile();
|
||||
CaveProfile profile = CaveProfiles.declaredBy(resolvedBiome);
|
||||
if (!isProfileEnabled(profile)) {
|
||||
continue;
|
||||
}
|
||||
@@ -351,7 +356,7 @@ public class CaveCarving {
|
||||
return weightedProfiles;
|
||||
}
|
||||
|
||||
private void buildDimensionColumnPlan(IrisDimensionCarvingEntry[] columnPlan, int chunkX, int chunkZ, IrisDimensionCarvingEntry entry, IrisDimensionCarvingResolver.State resolverState) {
|
||||
private void buildDimensionColumnPlan(ResolvedCarvingEntry[] columnPlan, int chunkX, int chunkZ, ResolvedCarvingEntry entry, CarvingResolver.State resolverState) {
|
||||
int baseX = PowerOfTwoCoordinates.chunkToBlock(chunkX);
|
||||
int baseZ = PowerOfTwoCoordinates.chunkToBlock(chunkZ);
|
||||
for (int localX = 0; localX < CHUNK_SIZE; localX++) {
|
||||
@@ -359,12 +364,12 @@ public class CaveCarving {
|
||||
for (int localZ = 0; localZ < CHUNK_SIZE; localZ++) {
|
||||
int worldZ = baseZ + localZ;
|
||||
int columnIndex = PowerOfTwoCoordinates.packLocal16(localX, localZ);
|
||||
columnPlan[columnIndex] = IrisDimensionCarvingResolver.resolveFromRoot(engine, entry, worldX, worldZ, resolverState);
|
||||
columnPlan[columnIndex] = CarvingResolver.resolveFromRoot(engine, entry, worldX, worldZ, resolverState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillProfileField(CaveProfile[] profileField, int chunkX, int chunkZ, IrisComplex complex, IrisDimensionCarvingResolver.State resolverState, BlendScratch blendScratch) {
|
||||
private void fillProfileField(CaveProfile[] profileField, int chunkX, int chunkZ, IrisComplex complex, CarvingResolver.State resolverState, BlendScratch blendScratch) {
|
||||
int startX = PowerOfTwoCoordinates.chunkToBlock(chunkX) - BLEND_RADIUS;
|
||||
int startZ = PowerOfTwoCoordinates.chunkToBlock(chunkZ) - BLEND_RADIUS;
|
||||
prefillProfileFieldSamples(startX, startZ, complex, blendScratch);
|
||||
@@ -404,23 +409,23 @@ public class CaveCarving {
|
||||
IrisRegion region,
|
||||
IrisBiome surfaceBiome,
|
||||
IrisBiome caveBiome,
|
||||
IrisDimensionCarvingResolver.State resolverState
|
||||
CarvingResolver.State resolverState
|
||||
) {
|
||||
CaveProfile resolved = null;
|
||||
CaveProfile dimensionProfile = engine.getDimension().getCaveProfile();
|
||||
CaveProfile dimensionProfile = CaveProfiles.declaredBy(engine.getDimension());
|
||||
if (isProfileEnabled(dimensionProfile)) {
|
||||
resolved = dimensionProfile;
|
||||
}
|
||||
|
||||
if (region != null) {
|
||||
CaveProfile regionProfile = region.getCaveProfile();
|
||||
CaveProfile regionProfile = CaveProfiles.declaredBy(region);
|
||||
if (isProfileEnabled(regionProfile)) {
|
||||
resolved = regionProfile;
|
||||
}
|
||||
}
|
||||
|
||||
if (surfaceBiome != null) {
|
||||
CaveProfile surfaceProfile = surfaceBiome.getCaveProfile();
|
||||
CaveProfile surfaceProfile = CaveProfiles.declaredBy(surfaceBiome);
|
||||
if (isProfileEnabled(surfaceProfile)) {
|
||||
resolved = surfaceProfile;
|
||||
}
|
||||
@@ -429,11 +434,11 @@ public class CaveCarving {
|
||||
int roundedSurfaceY = (int) Math.round(surfaceHeight);
|
||||
int sampleY = Math.max(1, roundedSurfaceY - 56);
|
||||
int worldY = sampleY + engine.getWorld().minHeight();
|
||||
IrisDimensionCarvingEntry rootCarvingEntry = IrisDimensionCarvingResolver.resolveRootEntry(engine, worldY, resolverState);
|
||||
ResolvedCarvingEntry rootCarvingEntry = CarvingResolver.resolveRootEntry(engine, worldY, resolverState);
|
||||
IrisBiome resolvedCarvingBiome = null;
|
||||
if (rootCarvingEntry != null) {
|
||||
IrisDimensionCarvingEntry resolvedCarvingEntry = IrisDimensionCarvingResolver.resolveFromRoot(engine, rootCarvingEntry, worldX, worldZ, resolverState);
|
||||
resolvedCarvingBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, resolvedCarvingEntry, resolverState);
|
||||
ResolvedCarvingEntry resolvedCarvingEntry = CarvingResolver.resolveFromRoot(engine, rootCarvingEntry, worldX, worldZ, resolverState);
|
||||
resolvedCarvingBiome = CarvingResolver.resolveEntryBiome(engine, resolvedCarvingEntry, resolverState);
|
||||
if (resolvedCarvingBiome != null) {
|
||||
caveBiome = resolvedCarvingBiome;
|
||||
}
|
||||
@@ -447,7 +452,7 @@ public class CaveCarving {
|
||||
if (depthBelowSurface <= 0) {
|
||||
effectiveCaveBiome = surfaceBiome;
|
||||
} else {
|
||||
int minDepth = Math.max(0, caveBiome.getCaveMinDepthBelowSurface());
|
||||
int minDepth = Math.max(0, CaveBiomeBands.minDepthBelowSurface(caveBiome));
|
||||
if (depthBelowSurface < minDepth) {
|
||||
effectiveCaveBiome = surfaceBiome;
|
||||
}
|
||||
@@ -455,7 +460,7 @@ public class CaveCarving {
|
||||
}
|
||||
}
|
||||
|
||||
CaveProfile caveProfile = effectiveCaveBiome.getCaveProfile();
|
||||
CaveProfile caveProfile = CaveProfiles.declaredBy(effectiveCaveBiome);
|
||||
if (isProfileEnabled(caveProfile)) {
|
||||
resolved = caveProfile;
|
||||
}
|
||||
@@ -466,7 +471,7 @@ public class CaveCarving {
|
||||
|
||||
private void prefillProfileFieldSamples(int startX, int startZ, IrisComplex complex, BlendScratch blendScratch) {
|
||||
fillFieldHeights(complex.getHeightStream(), startX, startZ, blendScratch.fieldSurfaceHeights);
|
||||
fillFieldFluidPresence(complex.getFluidStream(), startX, startZ, blendScratch.fieldHasFluid);
|
||||
fillFieldFluidPresence(TerrainPalettes.of(engine), startX, startZ, blendScratch.fieldHasFluid);
|
||||
fillFieldObjects(complex.getRegionStream(), startX, startZ, blendScratch.fieldRegions);
|
||||
fillFieldObjects(complex.getTrueBiomeStream(), startX, startZ, blendScratch.fieldSurfaceBiomes);
|
||||
fillFieldObjects(complex.getCaveBiomeStream(), startX, startZ, blendScratch.fieldCaveBiomes);
|
||||
@@ -490,11 +495,11 @@ public class CaveCarving {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillFieldFluidPresence(ProceduralStream<PlatformBlockState> stream, int startX, int startZ, boolean[] target) {
|
||||
private void fillFieldFluidPresence(TerrainPalettes palettes, int startX, int startZ, boolean[] target) {
|
||||
for (int fieldX = 0; fieldX < FIELD_SIZE; fieldX++) {
|
||||
int worldX = startX + fieldX;
|
||||
for (int fieldZ = 0; fieldZ < FIELD_SIZE; fieldZ++) {
|
||||
target[(fieldX * FIELD_SIZE) + fieldZ] = B.isFluid(stream.get(worldX, startZ + fieldZ));
|
||||
target[(fieldX * FIELD_SIZE) + fieldZ] = B.isFluid(palettes.fluidAt(worldX, startZ + fieldZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -680,7 +685,7 @@ public class CaveCarving {
|
||||
private final CaveProfile[] kernelProfiles = new CaveProfile[KERNEL_SIZE];
|
||||
private final double[] kernelProfileWeights = new double[KERNEL_SIZE];
|
||||
private final IdentityHashMap<CaveProfile, double[]> columnProfileWeights = new IdentityHashMap<>();
|
||||
private final IdentityHashMap<IrisDimensionCarvingEntry, IrisDimensionCarvingEntry[]> dimensionColumnPlans = new IdentityHashMap<>();
|
||||
private final IdentityHashMap<ResolvedCarvingEntry, ResolvedCarvingEntry[]> dimensionColumnPlans = new IdentityHashMap<>();
|
||||
private final IdentityHashMap<CaveProfile, Boolean> activeProfiles = new IdentityHashMap<>();
|
||||
private final List<CaveProfile> profileOrder = new ArrayList<>();
|
||||
private final double[] fieldSurfaceHeights = new double[FIELD_SIZE * FIELD_SIZE];
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import art.arcane.iris.engine.data.cache.Cache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.modifier.FloatingIslands;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingChildren;
|
||||
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;
|
||||
@@ -56,7 +57,7 @@ final class FloatingIslandSampleResolver implements IslandObjectPlacer.SamplePro
|
||||
return sampleCache.get(key);
|
||||
}
|
||||
IrisBiome parent = parent(x, z);
|
||||
if (parent == null || parent.getFloatingChildBiomes() == null || parent.getFloatingChildBiomes().isEmpty()) {
|
||||
if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) {
|
||||
resolvedSamples.add(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -543,8 +543,8 @@ public class FloatingObjectPlacing {
|
||||
try {
|
||||
IrisData data = engine.getData();
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
List<FloatingChildBiome> settings = biome.getFloatingChildBiomes();
|
||||
if (settings == null || settings.isEmpty()) {
|
||||
List<FloatingChildBiome> settings = FloatingChildren.declaredBy(biome);
|
||||
if (settings.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (ResolvedFloatingChild entry : FloatingChildren.of(engine).of(settings)) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CaveProfiles;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectVacuum;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
@@ -78,6 +79,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* placement reach of any object the dimension can place.
|
||||
*/
|
||||
public class ObjectPlacing {
|
||||
private static final CaveProfile DEFAULT_CAVE_PROFILE = new CaveProfile();
|
||||
private static final long CAVE_REJECT_LOG_THROTTLE_MS = 5000L;
|
||||
private static final int BEDROCK_CLEARANCE = 6;
|
||||
private static final byte LIQUID_FORCED_AIR = 3;
|
||||
@@ -235,8 +237,8 @@ public class ObjectPlacing {
|
||||
int rejected = 0;
|
||||
int nullObjects = 0;
|
||||
int errors = 0;
|
||||
CaveProfile biomeCaveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile());
|
||||
CaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome.getCaveProfile());
|
||||
CaveProfile biomeCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(caveBiome), CaveProfiles.declaredBy(region));
|
||||
CaveProfile regionCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(region), CaveProfiles.declaredBy(caveBiome));
|
||||
CaveAnchorCache caveAnchorCache = new CaveAnchorCache();
|
||||
|
||||
for (IrisObjectPlacement i : surfaceBiome.getSurfaceObjects()) {
|
||||
@@ -384,12 +386,12 @@ public class ObjectPlacing {
|
||||
|
||||
@ChunkCoordinates
|
||||
private void placeProceduralObjects(MantleWriter writer, RNG rng, int x, int z, IrisBiome surfaceBiome, IrisBiome caveBiome, IrisRegion region) {
|
||||
CaveProfile surfaceCaveProfile = resolveCaveProfile(surfaceBiome.getCaveProfile(), region.getCaveProfile());
|
||||
CaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome == null ? null : caveBiome.getCaveProfile());
|
||||
CaveProfile surfaceCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(surfaceBiome), CaveProfiles.declaredBy(region));
|
||||
CaveProfile regionCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(region), caveBiome == null ? null : CaveProfiles.declaredBy(caveBiome));
|
||||
placeProceduralFrom(writer, rng, x, z, surfaceBiome.getProceduralObjects(), surfaceBiome.getName(), surfaceCaveProfile, surfaceBiome.getLoadKey());
|
||||
placeProceduralFrom(writer, rng, x, z, region.getProceduralObjects(), region.getName(), regionCaveProfile, null);
|
||||
if (caveBiome != null && caveBiome != surfaceBiome) {
|
||||
CaveProfile caveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile());
|
||||
CaveProfile caveProfile = resolveCaveProfile(CaveProfiles.declaredBy(caveBiome), CaveProfiles.declaredBy(region));
|
||||
placeProceduralFrom(writer, rng, x, z, caveBiome.getProceduralObjects(), caveBiome.getName(), caveProfile, caveBiome.getLoadKey());
|
||||
}
|
||||
}
|
||||
@@ -1319,7 +1321,7 @@ public class ObjectPlacing {
|
||||
}
|
||||
|
||||
private CaveProfile resolveCaveProfile(CaveProfile preferred, CaveProfile secondary) {
|
||||
CaveProfile dimensionProfile = engine.getDimension().getCaveProfile();
|
||||
CaveProfile dimensionProfile = CaveProfiles.declaredBy(engine.getDimension());
|
||||
if (preferred != null && preferred.enabled()) {
|
||||
return preferred;
|
||||
}
|
||||
@@ -1332,7 +1334,7 @@ public class ObjectPlacing {
|
||||
return dimensionProfile;
|
||||
}
|
||||
|
||||
return new CaveProfile();
|
||||
return DEFAULT_CAVE_PROFILE;
|
||||
}
|
||||
|
||||
private CaveAnchorMode resolveAnchorMode(IrisObjectPlacement objectPlacement, CaveProfile caveProfile) {
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveFieldModule;
|
||||
import art.arcane.iris.builtin.carve.CarvingBiomeSettings;
|
||||
import art.arcane.iris.builtin.carve.CarvingEnabledSettings;
|
||||
import art.arcane.iris.builtin.carve.CarvingSettings;
|
||||
import art.arcane.iris.builtin.carve.CaveDepthSettings;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
@@ -28,6 +31,7 @@ import art.arcane.iris.engine.mantle.components.CaveCarving;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.service.CaveBiomes;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
@@ -51,8 +55,12 @@ public final class CarveModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerHeldType(CaveProfile.class);
|
||||
registry.registerHeldType(CaveFieldModule.class);
|
||||
registry.registerSettings(CaveProfile.class);
|
||||
registry.registerSettings(CarvingSettings.class);
|
||||
registry.registerSettings(CarvingEnabledSettings.class);
|
||||
registry.registerSettings(CarvingBiomeSettings.class);
|
||||
registry.registerSettings(CaveDepthSettings.class);
|
||||
registry.registerService(CaveBiomes.class, new CaveBiomeBands());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,6 +91,6 @@ public final class CarveModule implements IrisModule {
|
||||
* also does: Iris then skips this stage's mantle pass like any disabled component.
|
||||
*/
|
||||
private static boolean carves(IrisDimension dimension) {
|
||||
return dimension.isCarvingEnabled();
|
||||
return dimension.getModuleSettings().find(CarvingEnabledSettings.class).map(CarvingEnabledSettings::enabled).orElse(true);
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,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.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.engine.object.terrain.carving.IrisDimensionCarvingResolver;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.volmlib.util.documentation.ChunkCoordinates;
|
||||
@@ -66,6 +67,8 @@ public class CaveApplying {
|
||||
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;
|
||||
|
||||
@@ -73,6 +76,8 @@ public class CaveApplying {
|
||||
this.engine = engine;
|
||||
rng = new RNG(engine.getSeedManager().getCarve());
|
||||
decorators = BiomeDecorators.of(engine);
|
||||
layers = BiomeLayers.of(engine);
|
||||
palettes = TerrainPalettes.of(engine);
|
||||
surfaceDecorator = new IrisSurfaceDecorator(engine);
|
||||
ceilingDecorator = new IrisCeilingDecorator(engine);
|
||||
}
|
||||
@@ -82,7 +87,6 @@ public class CaveApplying {
|
||||
public void apply(int x, int z, Hunk<PlatformBlockState> output, boolean multicore, ChunkContext context) {
|
||||
PrecisionStopwatch caveStopwatch = PrecisionStopwatch.start();
|
||||
Mantle<Matter> mantle = engine.getMantle().getMantle();
|
||||
IrisDimensionCarvingResolver.State resolverState = new IrisDimensionCarvingResolver.State();
|
||||
Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache = new Long2ObjectOpenHashMap<>(2048);
|
||||
IrisCarveScratch scratch = SCRATCH.get();
|
||||
scratch.reset();
|
||||
@@ -151,7 +155,7 @@ public class CaveApplying {
|
||||
if (explicitCarveIntent) {
|
||||
// Only a fluid cavern consumes the fluid sample, and on the maintenance path that
|
||||
// sample is a full procedural stream evaluation, so never take it per voxel.
|
||||
PlatformBlockState fluid = isFluidIntent(cavern) ? context.getFluid().get(rx, rz) : null;
|
||||
PlatformBlockState fluid = isFluidIntent(cavern) ? palettes.fluidAt(chunkBlockX + rx, chunkBlockZ + rz) : null;
|
||||
output.setRaw(rx, yy, rz, resolveExplicitCarveState(cavern, fluid, LAVA, AIR));
|
||||
} else if (usesDefaultLava(caveLavaHeight, yy)) {
|
||||
output.setRaw(rx, yy, rz, LAVA);
|
||||
@@ -174,11 +178,11 @@ public class CaveApplying {
|
||||
int worldZ = rz + chunkBlockZ;
|
||||
String customBiome = cavern.getCustomBiome();
|
||||
IrisBiome biome = customBiome.isEmpty()
|
||||
? resolveCaveBiome(caveBiomeCache, worldX, yy, worldZ, resolverState)
|
||||
? resolveCaveBiome(caveBiomeCache, worldX, yy, worldZ)
|
||||
: resolveCustomBiome(customBiomeCache, customBiome);
|
||||
|
||||
if (biome != null) {
|
||||
PlatformBlockState data = biome.getWall().get(rng, worldX, yy, worldZ, engine.getData());
|
||||
PlatformBlockState data = layers.wall(biome).get(rng, worldX, yy, worldZ);
|
||||
int columnIndex = PowerOfTwoCoordinates.packLocal16(rx, rz);
|
||||
|
||||
if (data != null && B.isSolid(output.getRaw(rx, yy, rz)) && yy < surfaceHeights[columnIndex]) {
|
||||
@@ -188,14 +192,14 @@ public class CaveApplying {
|
||||
});
|
||||
|
||||
for (int columnIndex = 0; columnIndex < 256; columnIndex++) {
|
||||
processColumnFromMask(output, mantleChunk, mantle, columnMasks[columnIndex], columnIndex, x, z, resolverState, caveBiomeCache, customBiomeCache);
|
||||
processColumnFromMask(output, mantleChunk, mantle, columnMasks[columnIndex], columnIndex, x, z, caveBiomeCache, customBiomeCache);
|
||||
}
|
||||
|
||||
for (int columnIndex = 0; columnIndex < 256; columnIndex++) {
|
||||
if (boundaryMasks[columnIndex].isEmpty() || !columnMasks[columnIndex].isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
processBoundaryColumnFromMask(output, boundaryMasks[columnIndex], walls, columnIndex, x, z, resolverState, caveBiomeCache, customBiomeCache);
|
||||
processBoundaryColumnFromMask(output, boundaryMasks[columnIndex], walls, columnIndex, x, z, caveBiomeCache, customBiomeCache);
|
||||
}
|
||||
|
||||
// Surface-break carving must not leave an ore cap suspended across the opening.
|
||||
@@ -409,7 +413,6 @@ public class CaveApplying {
|
||||
int columnIndex,
|
||||
int chunkX,
|
||||
int chunkZ,
|
||||
IrisDimensionCarvingResolver.State resolverState,
|
||||
Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache,
|
||||
Map<String, IrisBiome> customBiomeCache
|
||||
) {
|
||||
@@ -438,7 +441,7 @@ public class CaveApplying {
|
||||
zone.ceiling = buf;
|
||||
} else {
|
||||
if (zone.isValid(engine)) {
|
||||
processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, resolverState, caveBiomeCache, customBiomeCache);
|
||||
processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, caveBiomeCache, customBiomeCache);
|
||||
}
|
||||
zone = new CaveZone();
|
||||
zone.setFloor(y);
|
||||
@@ -450,7 +453,7 @@ public class CaveApplying {
|
||||
}
|
||||
|
||||
if (zone.isValid(engine)) {
|
||||
processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, resolverState, caveBiomeCache, customBiomeCache);
|
||||
processZone(output, mc, mantle, zone, rx, rz, worldX, worldZ, caveBiomeCache, customBiomeCache);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +464,6 @@ public class CaveApplying {
|
||||
int columnIndex,
|
||||
int chunkX,
|
||||
int chunkZ,
|
||||
IrisDimensionCarvingResolver.State resolverState,
|
||||
Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache,
|
||||
Map<String, IrisBiome> customBiomeCache
|
||||
) {
|
||||
@@ -482,14 +484,14 @@ public class CaveApplying {
|
||||
if (y == zoneCeiling + 1) {
|
||||
zoneCeiling = y;
|
||||
} else {
|
||||
paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, resolverState, caveBiomeCache, customBiomeCache);
|
||||
paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, caveBiomeCache, customBiomeCache);
|
||||
zoneFloor = y;
|
||||
zoneCeiling = y;
|
||||
}
|
||||
y = boundaryMask.nextSetBit(y + 1);
|
||||
}
|
||||
|
||||
paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, resolverState, caveBiomeCache, customBiomeCache);
|
||||
paintBoundaryZone(output, walls, rx, rz, worldX, worldZ, zoneFloor, zoneCeiling, caveBiomeCache, customBiomeCache);
|
||||
}
|
||||
|
||||
private void paintBoundaryZone(
|
||||
@@ -501,22 +503,21 @@ public class CaveApplying {
|
||||
int worldZ,
|
||||
int zoneFloor,
|
||||
int zoneCeiling,
|
||||
IrisDimensionCarvingResolver.State resolverState,
|
||||
Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache,
|
||||
Map<String, IrisBiome> customBiomeCache
|
||||
) {
|
||||
IrisBiome floorBiome = resolveCaveBoundaryBiome(
|
||||
walls.get(rx, zoneFloor, rz), worldX, zoneFloor, worldZ,
|
||||
resolverState, caveBiomeCache, customBiomeCache);
|
||||
caveBiomeCache, customBiomeCache);
|
||||
IrisBiome ceilingBiome = resolveCaveBoundaryBiome(
|
||||
walls.get(rx, zoneCeiling, rz), worldX, zoneCeiling, worldZ,
|
||||
resolverState, caveBiomeCache, customBiomeCache);
|
||||
caveBiomeCache, customBiomeCache);
|
||||
if (floorBiome == null && ceilingBiome == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (floorBiome != null) {
|
||||
KList<PlatformBlockState> floorLayers = floorBiome.generateLayers(
|
||||
KList<PlatformBlockState> floorLayers = layers.generateLayers(floorBiome,
|
||||
engine.getDimension(), worldX, worldZ, rng, 3, zoneFloor, engine.getData(), engine.getComplex());
|
||||
for (int i = 0; i < zoneFloor - 1; i++) {
|
||||
if (!floorLayers.hasIndex(i)) {
|
||||
@@ -541,7 +542,7 @@ public class CaveApplying {
|
||||
|
||||
if (ceilingBiome != null) {
|
||||
int worldMaxY = engine.getWorld().maxHeight() - engine.getWorld().minHeight();
|
||||
KList<PlatformBlockState> ceilingLayers = ceilingBiome.generateCeilingLayers(
|
||||
KList<PlatformBlockState> ceilingLayers = layers.generateCeilingLayers(ceilingBiome,
|
||||
engine.getDimension(), worldX, worldZ, rng, 3, zoneCeiling, engine.getData(), engine.getComplex());
|
||||
for (int i = 0; i < ceilingLayers.size(); i++) {
|
||||
int ceilingY = zoneCeiling + i + 1;
|
||||
@@ -574,7 +575,7 @@ public class CaveApplying {
|
||||
return (h & 15L) == 0L;
|
||||
}
|
||||
|
||||
private void processZone(Hunk<PlatformBlockState> output, MantleChunk<Matter> mc, Mantle<Matter> mantle, CaveZone zone, int rx, int rz, int xx, int zz, IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, Map<String, IrisBiome> customBiomeCache) {
|
||||
private void processZone(Hunk<PlatformBlockState> output, MantleChunk<Matter> mc, Mantle<Matter> mantle, CaveZone zone, int rx, int rz, int xx, int zz, Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, Map<String, IrisBiome> customBiomeCache) {
|
||||
int maxY = output.getHeight();
|
||||
|
||||
if (zone.ceiling + 1 < maxY && B.isDecorant(output.getRaw(rx, zone.ceiling + 1, rz))) {
|
||||
@@ -596,14 +597,14 @@ public class CaveApplying {
|
||||
mantle.set(xx, zone.floor, zz, MarkerMatter.CAVE_FLOOR);
|
||||
}
|
||||
|
||||
IrisBiome floorBiome = resolveCaveBoundaryBiome(mc, rx, zone.floor, rz, xx, zz, resolverState, caveBiomeCache, customBiomeCache);
|
||||
IrisBiome ceilingBiome = resolveCaveBoundaryBiome(mc, rx, zone.ceiling, rz, xx, zz, resolverState, caveBiomeCache, customBiomeCache);
|
||||
IrisBiome floorBiome = resolveCaveBoundaryBiome(mc, rx, zone.floor, rz, xx, zz, caveBiomeCache, customBiomeCache);
|
||||
IrisBiome ceilingBiome = resolveCaveBoundaryBiome(mc, rx, zone.ceiling, rz, xx, zz, caveBiomeCache, customBiomeCache);
|
||||
if (floorBiome == null && ceilingBiome == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (floorBiome != null) {
|
||||
KList<PlatformBlockState> floorBlocks = floorBiome.generateLayers(engine.getDimension(), xx, zz, rng, 3, zone.floor, engine.getData(), engine.getComplex());
|
||||
KList<PlatformBlockState> floorBlocks = layers.generateLayers(floorBiome, engine.getDimension(), xx, zz, rng, 3, zone.floor, engine.getData(), engine.getComplex());
|
||||
for (int i = 0; i < zone.floor - 1; i++) {
|
||||
if (!floorBlocks.hasIndex(i)) {
|
||||
break;
|
||||
@@ -623,7 +624,7 @@ public class CaveApplying {
|
||||
}
|
||||
|
||||
if (ceilingBiome != null) {
|
||||
KList<PlatformBlockState> ceilingBlocks = ceilingBiome.generateCeilingLayers(engine.getDimension(), xx, zz, rng, 3, zone.ceiling, engine.getData(), engine.getComplex());
|
||||
KList<PlatformBlockState> ceilingBlocks = layers.generateCeilingLayers(ceilingBiome, engine.getDimension(), xx, zz, rng, 3, zone.ceiling, engine.getData(), engine.getComplex());
|
||||
for (int i = 0; i < ceilingBlocks.size(); i++) {
|
||||
int cy = zone.ceiling + i + 1;
|
||||
if (cy >= maxY) {
|
||||
@@ -651,10 +652,10 @@ public class CaveApplying {
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome resolveCaveBoundaryBiome(MantleChunk<Matter> mantleChunk, int x, int y, int z, int worldX, int worldZ, IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, Map<String, IrisBiome> customBiomeCache) {
|
||||
IrisBiome resolveCaveBoundaryBiome(MantleChunk<Matter> mantleChunk, int x, int y, int z, int worldX, int worldZ, Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, Map<String, IrisBiome> customBiomeCache) {
|
||||
MatterCavern cavern = dataIfPresent(mantleChunk, x, y, z, MatterCavern.class);
|
||||
return resolveCaveBoundaryBiome(
|
||||
cavern, worldX, y, worldZ, resolverState, caveBiomeCache, customBiomeCache);
|
||||
cavern, worldX, y, worldZ, caveBiomeCache, customBiomeCache);
|
||||
}
|
||||
|
||||
private static <T> T dataIfPresent(MantleChunk<Matter> mantleChunk, int x, int y, int z, Class<T> type) {
|
||||
@@ -669,11 +670,11 @@ public class CaveApplying {
|
||||
return matter.<T>getSlice(type).get(x & 15, y & 15, z & 15);
|
||||
}
|
||||
|
||||
IrisBiome resolveCaveBoundaryBiome(MatterCavern cavern, int worldX, int y, int worldZ, IrisDimensionCarvingResolver.State resolverState, Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, Map<String, IrisBiome> customBiomeCache) {
|
||||
IrisBiome resolveCaveBoundaryBiome(MatterCavern cavern, int worldX, int y, int worldZ, Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, Map<String, IrisBiome> customBiomeCache) {
|
||||
if (cavern != null && !cavern.getCustomBiome().isEmpty()) {
|
||||
return resolveCustomBiome(customBiomeCache, cavern.getCustomBiome());
|
||||
}
|
||||
return resolveCaveBiome(caveBiomeCache, worldX, y, worldZ, resolverState);
|
||||
return resolveCaveBiome(caveBiomeCache, worldX, y, worldZ);
|
||||
}
|
||||
|
||||
static boolean canReplaceCaveFloorLayer(Hunk<PlatformBlockState> output, int x, int y, int z, PlatformBlockState layer) {
|
||||
@@ -695,16 +696,16 @@ public class CaveApplying {
|
||||
return state != null && state.hasGravity();
|
||||
}
|
||||
|
||||
private IrisBiome resolveCaveBiome(Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, int x, int y, int z, IrisDimensionCarvingResolver.State resolverState) {
|
||||
IrisBiome center = sampleCaveBiome(caveBiomeCache, x, y, z, resolverState);
|
||||
private IrisBiome resolveCaveBiome(Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, int x, int y, int z) {
|
||||
IrisBiome center = sampleCaveBiome(caveBiomeCache, x, y, z);
|
||||
if (center == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IrisBiome xPos = sampleCaveBiome(caveBiomeCache, x + CAVE_BIOME_BLEND_RADIUS, y, z, resolverState);
|
||||
IrisBiome xNeg = sampleCaveBiome(caveBiomeCache, x - CAVE_BIOME_BLEND_RADIUS, y, z, resolverState);
|
||||
IrisBiome zPos = sampleCaveBiome(caveBiomeCache, x, y, z + CAVE_BIOME_BLEND_RADIUS, resolverState);
|
||||
IrisBiome zNeg = sampleCaveBiome(caveBiomeCache, x, y, z - CAVE_BIOME_BLEND_RADIUS, resolverState);
|
||||
IrisBiome xPos = sampleCaveBiome(caveBiomeCache, x + CAVE_BIOME_BLEND_RADIUS, y, z);
|
||||
IrisBiome xNeg = sampleCaveBiome(caveBiomeCache, x - CAVE_BIOME_BLEND_RADIUS, y, z);
|
||||
IrisBiome zPos = sampleCaveBiome(caveBiomeCache, x, y, z + CAVE_BIOME_BLEND_RADIUS);
|
||||
IrisBiome zNeg = sampleCaveBiome(caveBiomeCache, x, y, z - CAVE_BIOME_BLEND_RADIUS);
|
||||
|
||||
if (xPos == center && xNeg == center && zPos == center && zNeg == center) {
|
||||
return center;
|
||||
@@ -727,14 +728,14 @@ public class CaveApplying {
|
||||
return zNeg != null ? zNeg : center;
|
||||
}
|
||||
|
||||
private IrisBiome sampleCaveBiome(Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, int x, int y, int z, IrisDimensionCarvingResolver.State resolverState) {
|
||||
private IrisBiome sampleCaveBiome(Long2ObjectOpenHashMap<IrisBiome> caveBiomeCache, int x, int y, int z) {
|
||||
long key = BlockPosition.toLong(x, y, z);
|
||||
IrisBiome cachedBiome = caveBiomeCache.get(key);
|
||||
if (cachedBiome != null) {
|
||||
return cachedBiome;
|
||||
}
|
||||
|
||||
IrisBiome resolvedBiome = engine.getCaveBiome(x, y, z, resolverState);
|
||||
IrisBiome resolvedBiome = engine.getCaveBiome(x, y, z);
|
||||
if (resolvedBiome != null) {
|
||||
caveBiomeCache.put(key, resolvedBiome);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.carve.CaveDepthSettings;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingResolver;
|
||||
import art.arcane.iris.engine.object.terrain.carving.ResolvedCarvingEntry;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.volmit.service.CaveBiomes;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What the carve module tells the host about cave biomes ({@link CaveBiomes}): the biome of the dimension's carving band at a
|
||||
* position, and how far below the surface a biome's caves begin.
|
||||
*/
|
||||
public final class CaveBiomeBands implements CaveBiomes {
|
||||
@Override
|
||||
public Optional<String> overriddenBiome(PackWorld world, int x, int y, int z) {
|
||||
Engine engine = IrisPackWorld.of(world).engine();
|
||||
ResolvedCarvingEntry rootEntry = CarvingResolver.resolveRootEntry(engine, y + engine.getWorld().minHeight(), null);
|
||||
if (rootEntry == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ResolvedCarvingEntry entry = CarvingResolver.resolveFromRoot(engine, rootEntry, x, z, null);
|
||||
if (CarvingResolver.resolveEntryBiome(engine, entry, null) == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(entry.biomeKey().trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minDepthBelowSurface(PackWorld world, String biomeKey) {
|
||||
IrisBiome biome = IrisPackWorld.of(world).engine().getData().getBiomeLoader().load(biomeKey);
|
||||
return biome == null ? 0 : minDepthBelowSurface(biome);
|
||||
}
|
||||
|
||||
/** How many blocks below the surface {@code biome}'s caves begin, as its {@code caveMinDepthBelowSurface} says; 0 where it says none. */
|
||||
public static int minDepthBelowSurface(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(CaveDepthSettings.class).map(CaveDepthSettings::depth).orElse(0);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,11 @@ package art.arcane.iris.engine.modifier;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import art.arcane.iris.builtin.deposit.DepositVariantSettings;
|
||||
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
|
||||
import art.arcane.iris.builtin.deposit.OreSizeSettings;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
@@ -48,6 +52,13 @@ public final class DepositModule implements IrisModule {
|
||||
return ModuleInfo.of("iris:deposit", "Deposits", VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(DepositVariantSettings.class);
|
||||
registry.registerSettings(OreFrequencySettings.class);
|
||||
registry.registerSettings(OreSizeSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(IrisStages.Deposit.ORES)
|
||||
|
||||
@@ -21,12 +21,15 @@ package art.arcane.iris.engine.modifier;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.builtin.deposit.DepositHeightDistribution;
|
||||
import art.arcane.iris.builtin.deposit.DepositPlacementScope;
|
||||
import art.arcane.iris.builtin.deposit.DepositVariant;
|
||||
import art.arcane.iris.builtin.deposit.DepositVariantSettings;
|
||||
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
|
||||
import art.arcane.iris.builtin.deposit.OreSizeSettings;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineAssignedComponent;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
@@ -52,7 +55,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class DepositPlacer extends EngineAssignedComponent {
|
||||
private final RNG rng;
|
||||
private static final double UNCHANGED_ORE_MULTIPLIER = 1D;
|
||||
|
||||
private final Map<DepositGenerator, ResolvedDeposit> resolved = new ConcurrentHashMap<>();
|
||||
private final Map<DepositVariant, ResolvedDepositVariant> variants = new ConcurrentHashMap<>();
|
||||
|
||||
public DepositPlacer(Engine engine) {
|
||||
super(engine, "Deposit");
|
||||
@@ -95,7 +101,6 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
}
|
||||
|
||||
public void generate(DepositGenerator k, MantleChunk chunk, Hunk<PlatformBlockState> data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) {
|
||||
IrisDimensionCarvingResolver.State carvingState = new IrisDimensionCarvingResolver.State();
|
||||
ResolvedDeposit deposit = resolved(k);
|
||||
if (k.spawnChance() < rng.d())
|
||||
return;
|
||||
@@ -141,8 +146,7 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
boolean oreDeposit = deposit.isOre();
|
||||
IrisBiome surfaceBiome = context.getBiome().get(x, z);
|
||||
IrisBiome depositBiome = oreDeposit || k.usesCaveBiomeFilter()
|
||||
? getEngine().getCaveBiome(
|
||||
(cx << 4) + x, biomeY, (cz << 4) + z, carvingState)
|
||||
? getEngine().getCaveBiome((cx << 4) + x, biomeY, (cz << 4) + z)
|
||||
: null;
|
||||
if (!deposit.matchesBiome(surfaceBiome, depositBiome)) {
|
||||
continue;
|
||||
@@ -150,13 +154,13 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
|
||||
if (oreDeposit) {
|
||||
if (depositBiome != null) {
|
||||
double frequencyMultiplier = depositBiome.getOreDepositFrequencyMultiplier();
|
||||
double frequencyMultiplier = oreFrequencyMultiplier(depositBiome);
|
||||
if (frequencyMultiplier < 1D
|
||||
&& !passesOreFrequency(frequencyMultiplier, rng.d())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double sizeMultiplier = depositBiome.getOreDepositSizeMultiplier();
|
||||
double sizeMultiplier = oreSizeMultiplier(depositBiome);
|
||||
if (sizeMultiplier != 1D) {
|
||||
IrisObject scaledClump = deposit.clump(rng, sizeMultiplier);
|
||||
int scaledDimension = scaledClump.getW();
|
||||
@@ -204,7 +208,7 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
if (chunk.get(nx, ny, nz, MatterCavern.class) == null) {
|
||||
PlatformBlockState ore = clump.getBlocks().get(j);
|
||||
PlatformBlockState remapped = resolveDepositVariant(
|
||||
cx, cz, nx, ny, nz, ore, dimension, context, carvingState);
|
||||
cx, cz, nx, ny, nz, ore, dimension, context);
|
||||
PlatformBlockState finalBlock = remapped != null
|
||||
? remapped
|
||||
: B.toDeepSlateOre(current, ore);
|
||||
@@ -310,14 +314,14 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
return Math.max(minimum, Math.min(center, maximum));
|
||||
}
|
||||
|
||||
private PlatformBlockState resolveDepositVariant(int cx, int cz, int nx, int localY, int nz, PlatformBlockState ore, IrisDimension dimension, ChunkContext context, IrisDimensionCarvingResolver.State carvingState) {
|
||||
private PlatformBlockState resolveDepositVariant(int cx, int cz, int nx, int localY, int nz, PlatformBlockState ore, IrisDimension dimension, ChunkContext context) {
|
||||
int worldX = (cx << 4) + nx;
|
||||
int worldZ = (cz << 4) + nz;
|
||||
int worldY = absoluteWorldY(getEngine().getMinHeight(), localY);
|
||||
|
||||
IrisBiome biome = getEngine().getCaveBiome(worldX, localY, worldZ, carvingState);
|
||||
IrisBiome biome = getEngine().getCaveBiome(worldX, localY, worldZ);
|
||||
if (biome != null) {
|
||||
PlatformBlockState match = matchDepositVariant(biome.getDepositVariants(), ore, worldY);
|
||||
PlatformBlockState match = matchDepositVariant(biome, ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
@@ -325,14 +329,14 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
|
||||
IrisRegion region = context.getRegion().get(nx, nz);
|
||||
if (region != null) {
|
||||
PlatformBlockState match = matchDepositVariant(region.getDepositVariants(), ore, worldY);
|
||||
PlatformBlockState match = matchDepositVariant(region, ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
if (dimension != null) {
|
||||
PlatformBlockState match = matchDepositVariant(dimension.getDepositVariants(), ore, worldY);
|
||||
PlatformBlockState match = matchDepositVariant(dimension, ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
@@ -341,17 +345,14 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
private PlatformBlockState matchDepositVariant(java.util.List<IrisDepositVariant> variants, PlatformBlockState ore, int y) {
|
||||
if (variants == null || variants.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (IrisDepositVariant variant : variants) {
|
||||
if (y < variant.getMinHeight() || y > variant.getMaxHeight()) {
|
||||
private PlatformBlockState matchDepositVariant(IrisRegistrant owner, PlatformBlockState ore, int y) {
|
||||
for (DepositVariant declared : variantsOf(owner)) {
|
||||
ResolvedDepositVariant variant = variants.computeIfAbsent(declared, ResolvedDepositVariant::new);
|
||||
if (!variant.appliesAt(y)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlatformBlockState swapped = variant.remapOrNull(ore, getData());
|
||||
PlatformBlockState swapped = variant.remapOrNull(ore);
|
||||
if (swapped != null) {
|
||||
return swapped;
|
||||
}
|
||||
@@ -359,4 +360,16 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<DepositVariant> variantsOf(IrisRegistrant owner) {
|
||||
return owner.getModuleSettings().find(DepositVariantSettings.class).map(DepositVariantSettings::variants).orElse(List.of());
|
||||
}
|
||||
|
||||
private static double oreFrequencyMultiplier(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(OreFrequencySettings.class).map(OreFrequencySettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
|
||||
}
|
||||
|
||||
private static double oreSizeMultiplier(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(OreSizeSettings.class).map(OreSizeSettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,11 @@
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingChildren;
|
||||
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
|
||||
import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
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;
|
||||
@@ -32,7 +34,8 @@ 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;
|
||||
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.terrain.ResolvedLayer;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
@@ -64,15 +67,16 @@ public class FloatingIslands {
|
||||
private final Engine engine;
|
||||
private final RNG rng;
|
||||
private final EngineDecorator seaSurfaceDecorator;
|
||||
private final BiomeLayers biomeLayers;
|
||||
|
||||
private static KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
|
||||
private KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
|
||||
if (entry == null || entry.settings().bottomPaletteMode() != FloatingBottomPaletteMode.CUSTOM || entry.settings().bottomPalette() == null || entry.settings().bottomPalette().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return generatePaletteLayers(dimension, new KList<>(entry.settings().bottomPalette()), wx, wz, random.nextParallelRNG(0xB0770B), paletteDepth, data, complex);
|
||||
}
|
||||
|
||||
private static KList<PlatformBlockState> generatePaletteLayers(IrisDimension dimension, KList<IrisBiomePaletteLayer> layers, double wx, double wz, RNG random, int maxDepth, IrisData data, IrisComplex complex) {
|
||||
private KList<PlatformBlockState> generatePaletteLayers(IrisDimension dimension, KList<PaletteLayer> layers, double wx, double wz, RNG random, int maxDepth, IrisData data, IrisComplex complex) {
|
||||
KList<PlatformBlockState> generated = new KList<>();
|
||||
if (layers == null || layers.isEmpty() || maxDepth <= 0) {
|
||||
return generated;
|
||||
@@ -80,13 +84,13 @@ public class FloatingIslands {
|
||||
|
||||
int generatorSeed = 7235;
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
IrisBiomePaletteLayer layer = layers.get(i);
|
||||
CNG heightGenerator = layer.getHeightGenerator(random.nextParallelRNG((generatorSeed++) * generatorSeed * generatorSeed * generatorSeed), data);
|
||||
ResolvedLayer layer = biomeLayers.resolve(layers.get(i));
|
||||
CNG heightGenerator = layer.heightNoise(random.nextParallelRNG((generatorSeed++) * generatorSeed * generatorSeed * generatorSeed));
|
||||
if (heightGenerator == null) {
|
||||
continue;
|
||||
}
|
||||
double layerDepth = heightGenerator.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / layer.getZoom(), wz / layer.getZoom());
|
||||
SlopeClip slopeClip = layer.getSlopeCondition();
|
||||
double layerDepth = heightGenerator.fit(layer.minHeight(), layer.maxHeight(), wx / layer.zoom(), wz / layer.zoom());
|
||||
SlopeClip slopeClip = layer.slopeCondition();
|
||||
|
||||
if (slopeClip != null && !slopeClip.isDefault() && complex != null && !slopeClip.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
layerDepth = 0;
|
||||
@@ -102,7 +106,7 @@ public class FloatingIslands {
|
||||
}
|
||||
|
||||
try {
|
||||
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.getZoom(), j, (wz - j) / layer.getZoom(), data));
|
||||
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom()));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
@@ -183,9 +187,9 @@ public class FloatingIslands {
|
||||
IrisBiome target = entry == null ? parent : entry.getRealBiome(parent, data);
|
||||
int entrySeed = entry == null || entry.settings().biome() == null ? 0 : entry.settings().biome().hashCode();
|
||||
RNG layerRng = rng.nextParallelRNG((int) (colSeed ^ 0x7A4E ^ entrySeed));
|
||||
KList<PlatformBlockState> topBlocks = target == null ? null : target.generateLayers(dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
|
||||
KList<PlatformBlockState> topBlocks = target == null ? null : biomeLayers.generateLayers(target, dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
|
||||
if (topBlocks == null || topBlocks.isEmpty()) {
|
||||
topBlocks = parent.generateLayers(dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
|
||||
topBlocks = biomeLayers.generateLayers(parent, dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
|
||||
}
|
||||
KList<PlatformBlockState> bottomBlocks = generateBottomPaletteLayers(entry, dimension, wx, wz, layerRng, paletteDepth, data, complex);
|
||||
return new PaletteContext(topBlocks, bottomBlocks, B.getState("minecraft:stone"));
|
||||
@@ -207,6 +211,7 @@ public class FloatingIslands {
|
||||
this.engine = engine;
|
||||
rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL);
|
||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
|
||||
biomeLayers = BiomeLayers.of(engine);
|
||||
}
|
||||
|
||||
/** Fills the islands' solids into the chunk whose first block is {@code x}, {@code z}. */
|
||||
@@ -225,7 +230,7 @@ public class FloatingIslands {
|
||||
int wx = x + xf;
|
||||
int wz = z + zf;
|
||||
IrisBiome parent = boundarySampler.parent(wx, wz);
|
||||
if (parent == null || parent.getFloatingChildBiomes() == null || parent.getFloatingChildBiomes().isEmpty()) {
|
||||
if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler);
|
||||
@@ -310,7 +315,7 @@ public class FloatingIslands {
|
||||
int wx = x + xf;
|
||||
int wz = z + zf;
|
||||
IrisBiome parent = boundarySampler.parent(wx, wz);
|
||||
if (parent == null || parent.getFloatingChildBiomes() == null || parent.getFloatingChildBiomes().isEmpty()) {
|
||||
if (parent == null || FloatingChildren.declaredBy(parent).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
FloatingIslandSample sample = FloatingIslandSample.sampleMemoized(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler);
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildSettings;
|
||||
import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
@@ -50,7 +51,8 @@ public final class FloatingModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerHeldType(FloatingChildBiome.class);
|
||||
registry.registerSettings(FloatingChildSettings.class);
|
||||
registry.registerSettings(MergeFloatingChildrenSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.PendingSettings;
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
@@ -44,6 +44,7 @@ import java.util.Map;
|
||||
public final class PerfectionModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
private static final String HALF = "half";
|
||||
private static final int CENTER = 7;
|
||||
private static final BlockState AIR = new BlockState("minecraft:air");
|
||||
private static final Map<ResourceId, BlockState> ORE_BASES = oreBases();
|
||||
|
||||
@@ -59,7 +60,7 @@ public final class PerfectionModule implements IrisModule {
|
||||
|
||||
private static void perfect(ChunkStageContext context) {
|
||||
Hunk<BlockState> blocks = context.hunk(BlockState.class);
|
||||
if (PendingSettings.of(context.world()).hidesOres()) {
|
||||
if (hidesOres(context)) {
|
||||
hideOres(blocks, new IdentityHashMap<>());
|
||||
}
|
||||
Surfaces surfaces = new Surfaces(blocks, context.resources().blocks(), new IdentityHashMap<>());
|
||||
@@ -69,6 +70,12 @@ public final class PerfectionModule implements IrisModule {
|
||||
} while (removed);
|
||||
}
|
||||
|
||||
/** The dimension's {@code hideOresForHiddenOre}, which every column of the chunk shares. */
|
||||
private static boolean hidesOres(ChunkStageContext context) {
|
||||
return context.settings().at(HideOresSettings.class, context.originX() + CENTER, context.originZ() + CENTER).stream()
|
||||
.anyMatch(entry -> entry.value().hide());
|
||||
}
|
||||
|
||||
/** {@code hidden} remembers per state instance what it is hidden as, itself for a block that is no ore. */
|
||||
private static void hideOres(Hunk<BlockState> blocks, Map<BlockState, BlockState> hidden) {
|
||||
for (int x = 0; x < blocks.getWidth(); x++) {
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.post.PostProcessingSettings;
|
||||
import art.arcane.iris.builtin.post.PostProcessingSlabsSettings;
|
||||
import art.arcane.iris.builtin.post.PostProcessingWallsSettings;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.stage.StageGraph;
|
||||
@@ -32,6 +36,13 @@ public final class PostModule implements IrisModule {
|
||||
return ModuleInfo.of("iris:post", "Post-processing", VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(PostProcessingSettings.class);
|
||||
registry.registerSettings(PostProcessingSlabsSettings.class);
|
||||
registry.registerSettings(PostProcessingWallsSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(IrisStages.Post.SMOOTH).requires(IrisStages.Carve.APPLY).run(SurfaceSmoothing::smooth);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.deposit.DepositVariant;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* One {@link DepositVariant} made ready: its source and replacement block ids resolved to the platform's blocks, built once on
|
||||
* first use. A rule whose source or replacement the platform does not know remaps nothing.
|
||||
*/
|
||||
final class ResolvedDepositVariant {
|
||||
private final DepositVariant settings;
|
||||
private final AtomicCache<Map<String, PlatformBlockState>> remapped = new AtomicCache<>();
|
||||
|
||||
ResolvedDepositVariant(DepositVariant settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
boolean appliesAt(int worldY) {
|
||||
return worldY >= settings.minHeight() && worldY <= settings.maxHeight();
|
||||
}
|
||||
|
||||
/** The block {@code ore} is rewritten to, or null when the rule does not remap its material. */
|
||||
PlatformBlockState remapOrNull(PlatformBlockState ore) {
|
||||
if (ore == null || settings.remap().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return remapped.aquire(this::resolveRemap).get(IrisProceduralBlocks.materialKey(ore));
|
||||
}
|
||||
|
||||
private Map<String, PlatformBlockState> resolveRemap() {
|
||||
Map<String, PlatformBlockState> resolved = new HashMap<>();
|
||||
for (Map.Entry<String, String> entry : settings.remap().entrySet()) {
|
||||
PlatformBlockState source = B.getStateOrNull(entry.getKey(), false);
|
||||
PlatformBlockState target = B.getStateOrNull(entry.getValue(), true);
|
||||
if (source == null || target == null) {
|
||||
continue;
|
||||
}
|
||||
resolved.put(IrisProceduralBlocks.materialKey(source), target);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
@@ -18,18 +18,27 @@
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.PendingSettings;
|
||||
import art.arcane.iris.builtin.PendingSettings.BiomeLayer;
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.post.PostProcessingSlabsSettings;
|
||||
import art.arcane.iris.builtin.post.PostProcessingWallsSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayerBlocks;
|
||||
import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.iris.builtin.terrain.SlabSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Smooths the carved surface of one chunk for {@link PostModule}: floating nibs, single-block bumps and potholes,
|
||||
@@ -45,6 +54,11 @@ final class SurfaceSmoothing {
|
||||
private static final String SLAB_SUFFIX = "_slab";
|
||||
private static final String WATERLOGGED = "waterlogged";
|
||||
private static final String TRUE = "true";
|
||||
private static final int CENTER = 7;
|
||||
/** A biome without a wall or slab picks no block. */
|
||||
private static final PaletteLayer NO_LAYER = PaletteLayer.withoutBlocks();
|
||||
/** Walls and slabs are picked once per column: the first signature of a layer's noise. */
|
||||
private static final int COLUMN_SIGNATURE = 0;
|
||||
/** The face properties of a connecting block, such as a vine's, each with the neighbour it faces. */
|
||||
private static final List<Face> FACES = List.of(new Face("north", 0, 0, -1), new Face("east", 1, 0, 0),
|
||||
new Face("south", 0, 0, 1), new Face("west", -1, 0, 0), new Face("up", 0, 1, 0), new Face("down", 0, -1, 0));
|
||||
@@ -52,7 +66,9 @@ final class SurfaceSmoothing {
|
||||
private final Hunk<BlockState> blocks;
|
||||
private final BlockRegistry registry;
|
||||
private final TerrainSampler terrain;
|
||||
private final PendingSettings settings;
|
||||
private final FeatureSettings settings;
|
||||
private final LayerBlocks layerBlocks;
|
||||
private final RNG postRandom;
|
||||
private final int originX;
|
||||
private final int originZ;
|
||||
private final int planeWidth;
|
||||
@@ -65,13 +81,15 @@ final class SurfaceSmoothing {
|
||||
this.blocks = context.hunk(BlockState.class);
|
||||
this.registry = context.resources().blocks();
|
||||
this.terrain = context.terrain();
|
||||
this.settings = PendingSettings.of(context.world());
|
||||
this.settings = context.settings();
|
||||
this.layerBlocks = LayerBlocks.of(context.world());
|
||||
this.postRandom = new RNG(IrisSeed.POST.of(context.world()));
|
||||
this.originX = context.originX();
|
||||
this.originZ = context.originZ();
|
||||
this.planeWidth = blocks.getWidth() + 2;
|
||||
this.heights = heightPlane();
|
||||
this.walls = settings.postProcessingWalls();
|
||||
this.slabs = settings.postProcessingSlabs();
|
||||
this.walls = enabled(PostProcessingWallsSettings.class, PostProcessingWallsSettings::enabled, PostProcessingWallsSettings.DEFAULT_ENABLED);
|
||||
this.slabs = enabled(PostProcessingSlabsSettings.class, PostProcessingSlabsSettings::enabled, PostProcessingSlabsSettings.DEFAULT_ENABLED);
|
||||
this.fluidHeight = terrain.fluidHeight();
|
||||
}
|
||||
|
||||
@@ -93,6 +111,24 @@ final class SurfaceSmoothing {
|
||||
* resolve the same height up to five times. Resolve the padded plane once instead. The four diagonal
|
||||
* corners are never read, so they are left unresolved.
|
||||
*/
|
||||
/** A switch of the dimension, which every column of the chunk shares. */
|
||||
private <S extends IrisFeature> boolean enabled(Class<S> type, Function<S, Boolean> enabled, boolean byDefault) {
|
||||
List<Entry<S>> entries = settings.at(type, originX + CENTER, originZ + CENTER);
|
||||
return entries.isEmpty() ? byDefault : enabled.apply(entries.getFirst().value());
|
||||
}
|
||||
|
||||
/** The biome layer of the column's surface biome that {@code type} holds, or none. */
|
||||
private <S extends IrisFeature> PaletteLayer biomeLayer(Class<S> type, Function<S, PaletteLayer> layer, int x, int z) {
|
||||
List<Entry<S>> entries = settings.at(type, x, z);
|
||||
return entries.isEmpty() ? NO_LAYER : layer.apply(entries.getLast().value());
|
||||
}
|
||||
|
||||
/** The layer's block at the position, picked with the world's post-processing random, or null when it has none. */
|
||||
private BlockState pick(PaletteLayer layer, double x, double y, double z) {
|
||||
int index = layerBlocks.pick(layer, postRandom, COLUMN_SIGNATURE, x, y, z);
|
||||
return index == LayerBlocks.NONE ? null : layerBlocks.blocks(layer).get(index);
|
||||
}
|
||||
|
||||
private int[] heightPlane() {
|
||||
int width = blocks.getWidth();
|
||||
int depth = blocks.getDepth();
|
||||
@@ -180,15 +216,15 @@ final class SurfaceSmoothing {
|
||||
if (ha >= h - 2 && hb >= h - 2 && hc >= h - 2 && hd >= h - 2) {
|
||||
return;
|
||||
}
|
||||
Optional<BiomeLayer> wall = settings.wall(x, z);
|
||||
if (wall.isEmpty()) {
|
||||
PaletteLayer wall = biomeLayer(WallSettings.class, WallSettings::layer, x, z);
|
||||
if (wall.palette().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
boolean brokeGround = false;
|
||||
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
|
||||
for (int i = h; i > h - max; i--) {
|
||||
Optional<BlockState> block = wall.get().at(x + i, i + h, z + i);
|
||||
if (block.isEmpty()) {
|
||||
BlockState block = pick(wall, x + i, i + h, z + i);
|
||||
if (block == null) {
|
||||
continue;
|
||||
}
|
||||
if (isAirOrWater(x, i, z)) {
|
||||
@@ -197,7 +233,7 @@ final class SurfaceSmoothing {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
set(x, i, z, block.get());
|
||||
set(x, i, z, block);
|
||||
brokeGround = true;
|
||||
}
|
||||
}
|
||||
@@ -210,15 +246,14 @@ final class SurfaceSmoothing {
|
||||
if (!step) {
|
||||
return h;
|
||||
}
|
||||
BiomeLayer slab = settings.slab(x, z);
|
||||
if (!slab.allowsSlope(terrain.column(x, z).slope())) {
|
||||
PaletteLayer slab = biomeLayer(SlabSettings.class, SlabSettings::layer, x, z);
|
||||
if (!slab.slopeCondition().isValid(terrain.column(x, z).slope())) {
|
||||
return h;
|
||||
}
|
||||
Optional<BlockState> picked = slab.at(x, h, z);
|
||||
if (picked.isEmpty()) {
|
||||
BlockState block = pick(slab, x, h, z);
|
||||
if (block == null) {
|
||||
return h;
|
||||
}
|
||||
BlockState block = picked.get();
|
||||
boolean cancel = has(block, BlockTrait.AIR)
|
||||
|| block.material().equals(SNOW_ID) && h + 1 <= fluidHeight
|
||||
|| isSnowLayer(x, h, z);
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.annotations;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@@ -31,5 +29,6 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListResource {
|
||||
Class<? extends IrisRegistrant> value();
|
||||
/** The class pack resources of the kind are read into: an Iris resource or the class of a module resource kind. */
|
||||
Class<?> value();
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
@Snippet("attribute-modifier")
|
||||
@Accessors(chain = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents an attribute modifier for an item or an entity. This allows you to create modifications to basic game attributes such as MAX_HEALTH or ARMOR_VALUE.")
|
||||
@Data
|
||||
public class IrisAttributeModifier {
|
||||
@Required
|
||||
@Desc("The Attribute type key such as max_health or minecraft:armor. This type is pulled from the game attributes. Zombie & Horse attributes will not work on non-zombie/horse entities.\nUsing an attribute on an item will have affects when held, or worn. There is no way to specify further granularity as the game picks this depending on the item type.")
|
||||
private String attribute = null;
|
||||
|
||||
@MinNumber(2)
|
||||
@Required
|
||||
@Desc("The Attribute Name is used internally only for the game. This value should be unique to all other attributes applied to this item/entity. It is not shown in game.")
|
||||
private String name = "";
|
||||
|
||||
@Desc("The application operation: ADD_NUMBER (default), ADD_SCALAR or MULTIPLY_SCALAR_1. Add Number adds to the default value. \nAdd scalar_1 will multiply by 1 for example if the health is 20 and you multiply_scalar_1 by 0.5, the health will result in 30, not 10. Use negative values to achieve that.")
|
||||
private String operation = "ADD_NUMBER";
|
||||
|
||||
@Desc("Minimum amount for this modifier. Iris randomly chooses an amount, this is the minimum it can choose randomly for this attribute.")
|
||||
private double minAmount = 1;
|
||||
|
||||
@Desc("Maximum amount for this modifier Iris randomly chooses an amount, this is the maximum it can choose randomly for this attribute.")
|
||||
private double maxAmount = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance that this attribute is applied (0 to 1). If the chance is 0.5 (50%), then Iris will only apply this attribute 50% of the time.")
|
||||
private double chance = 1;
|
||||
|
||||
public double getAmount(RNG rng) {
|
||||
return rng.d(getMinAmount(), getMaxAmount());
|
||||
}
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity;
|
||||
|
||||
import art.arcane.iris.engine.object.marker.IrisCommandRegistry;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.annotations.DependsOn;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListPotionEffect;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
||||
import art.arcane.iris.util.common.data.registry.RegistryUtil;
|
||||
import art.arcane.iris.util.common.scheduling.J;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@Snippet("effect")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("An iris effect")
|
||||
@Data
|
||||
public class IrisEffect {
|
||||
private final transient AtomicCache<PotionEffectType> pt = new AtomicCache<>();
|
||||
private final transient AtomicCache<ChronoLatch> latch = new AtomicCache<>();
|
||||
private final transient AtomicCache<Particle> particleEffectResolved = new AtomicCache<>();
|
||||
private final transient AtomicCache<Sound> soundResolved = new AtomicCache<>();
|
||||
@RegistryListPotionEffect
|
||||
@Desc("The potion effect to apply in this area")
|
||||
private String potionEffect = "";
|
||||
@Desc("The particle effect to apply in the area")
|
||||
private String particleEffect = null;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(-32)
|
||||
@MaxNumber(32)
|
||||
@Desc("Randomly offset from the surface to this surface+value")
|
||||
private int particleOffset = 0;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt x, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltX = 0;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt y, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltY = 0;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt z, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltZ = 0;
|
||||
@DependsOn({"particleEffect"})
|
||||
@Desc("Randomize the altX by -altX to altX")
|
||||
private boolean randomAltX = true;
|
||||
@DependsOn({"particleEffect"})
|
||||
@Desc("Randomize the altY by -altY to altY")
|
||||
private boolean randomAltY = false;
|
||||
@DependsOn({"particleEffect"})
|
||||
@Desc("Randomize the altZ by -altZ to altZ")
|
||||
private boolean randomAltZ = true;
|
||||
@Desc("The sound to play")
|
||||
private String sound = null;
|
||||
@DependsOn({"sound"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(512)
|
||||
@Desc("The max distance from the player the sound will play")
|
||||
private int soundDistance = 12;
|
||||
@DependsOn({"sound", "maxPitch"})
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(1.99)
|
||||
@Desc("The minimum sound pitch")
|
||||
private double minPitch = 0.5D;
|
||||
@DependsOn({"sound", "minVolume"})
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(1.99)
|
||||
@Desc("The max sound pitch")
|
||||
private double maxPitch = 1.5D;
|
||||
@DependsOn({"sound"})
|
||||
@MinNumber(0.001)
|
||||
@MaxNumber(512)
|
||||
@Desc("The sound volume.")
|
||||
private double volume = 1.5D;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(512)
|
||||
@Desc("The particle count. Try setting to zero for using the alt xyz to a motion value instead of an offset")
|
||||
private int particleCount = 0;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(64)
|
||||
@Desc("How far away from the player particles can play")
|
||||
private int particleDistance = 20;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(128)
|
||||
@Desc("How wide the particles can play (player's view left and right) RADIUS")
|
||||
private int particleDistanceWidth = 24;
|
||||
@DependsOn({"particleEffect"})
|
||||
@Desc("An extra value for some particles... Which bukkit doesn't even document.")
|
||||
private double extra = 0;
|
||||
@DependsOn({"potionEffect"})
|
||||
@MinNumber(-1)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The Potion Strength or -1 to disable")
|
||||
private int potionStrength = -1;
|
||||
@DependsOn({"potionEffect", "potionTicksMin"})
|
||||
@MinNumber(1)
|
||||
@Desc("The max time the potion will last for")
|
||||
private int potionTicksMax = 155;
|
||||
@DependsOn({"potionEffect", "potionTicksMax"})
|
||||
@MinNumber(1)
|
||||
@Desc("The min time the potion will last for")
|
||||
private int potionTicksMin = 75;
|
||||
@Required
|
||||
@MinNumber(0)
|
||||
@Desc("The effect interval in milliseconds")
|
||||
private int interval = 150;
|
||||
@DependsOn({"particleEffect"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Desc("The effect distance start away")
|
||||
private int particleAway = 5;
|
||||
@Required
|
||||
@MinNumber(1)
|
||||
@Desc("The chance is 1 in CHANCE per interval")
|
||||
private int chance = 50;
|
||||
@Desc("Run commands, with configurable location parameters")
|
||||
private IrisCommandRegistry commandRegistry = null;
|
||||
|
||||
|
||||
public boolean canTick() {
|
||||
return latch.aquire(() -> new ChronoLatch(interval)).flip();
|
||||
}
|
||||
|
||||
public boolean shouldApplyNow() {
|
||||
return canTick() && RNG.r.nextInt(chance) == 0;
|
||||
}
|
||||
|
||||
public String getParticleEffectKey() {
|
||||
return particleEffect;
|
||||
}
|
||||
|
||||
public String getSoundKey() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public Particle getParticleEffect() {
|
||||
if (particleEffect == null) {
|
||||
return null;
|
||||
}
|
||||
return particleEffectResolved.aquire(() -> resolveKeyed(Particle.class, particleEffect));
|
||||
}
|
||||
|
||||
public Sound getSound() {
|
||||
if (sound == null) {
|
||||
return null;
|
||||
}
|
||||
return soundResolved.aquire(() -> resolveKeyed(Sound.class, sound));
|
||||
}
|
||||
|
||||
private static <T> T resolveKeyed(Class<T> type, String key) {
|
||||
NamespacedKey namespacedKey = NamespacedKey.fromString(key);
|
||||
return namespacedKey == null ? null : RegistryUtil.lookup(type).get(namespacedKey);
|
||||
}
|
||||
|
||||
public PotionEffectType getRealType() {
|
||||
return pt.aquire(() ->
|
||||
{
|
||||
if (getPotionEffect() == null || getPotionEffect().isEmpty()) {
|
||||
return PotionEffectType.LUCK;
|
||||
}
|
||||
|
||||
try {
|
||||
PotionEffectType resolved = PotionEffectTypes.resolve(getPotionEffect());
|
||||
if (resolved != null) {
|
||||
return resolved;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
|
||||
if (PotionEffectTypes.shouldWarn(getPotionEffect())) {
|
||||
IrisLogging.warn("Unknown Potion Effect Type: \"" + getPotionEffect() + "\". Valid types: " + PotionEffectTypes.knownTypesList());
|
||||
}
|
||||
|
||||
return PotionEffectType.LUCK;
|
||||
});
|
||||
}
|
||||
|
||||
private static final class BukkitFx {
|
||||
private static void run(Player p, Runnable r) {
|
||||
J.runEntity(p, r);
|
||||
}
|
||||
}
|
||||
|
||||
public void apply(Player p, Engine g) {
|
||||
if (!shouldApplyNow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitFx.run(p, () -> {
|
||||
Sound soundType = getSound();
|
||||
Particle particleType = getParticleEffect();
|
||||
if (soundType != null) {
|
||||
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
|
||||
p.playSound(part, soundType, (float) volume, (float) RNG.r.d(minPitch, maxPitch));
|
||||
}
|
||||
|
||||
if (particleType != null) {
|
||||
Location part = p.getLocation().clone().add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway)).clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90)).multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth)));
|
||||
|
||||
part.setY(Math.round(g.getHeight(part.getBlockX(), part.getBlockZ())) + 1);
|
||||
part.add(RNG.r.d(), 0, RNG.r.d());
|
||||
int offset = p.getWorld().getMinHeight();
|
||||
if (extra != 0) {
|
||||
p.spawnParticle(particleType, part.getX(), part.getY() + offset + RNG.r.i(particleOffset),
|
||||
part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
|
||||
extra);
|
||||
} else {
|
||||
p.spawnParticle(particleType, part.getX(), part.getY() + offset + RNG.r.i(particleOffset), part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ);
|
||||
}
|
||||
}
|
||||
|
||||
if (commandRegistry != null) {
|
||||
commandRegistry.run(p);
|
||||
}
|
||||
|
||||
if (potionStrength > -1) {
|
||||
if (p.hasPotionEffect(getRealType())) {
|
||||
PotionEffect e = p.getPotionEffect(getRealType());
|
||||
if (e != null && e.getAmplifier() > getPotionStrength()) {
|
||||
return;
|
||||
}
|
||||
|
||||
p.removePotionEffect(getRealType());
|
||||
}
|
||||
|
||||
p.addPotionEffect(new PotionEffect(getRealType(),
|
||||
RNG.r.i(Math.min(potionTicksMax, potionTicksMin),
|
||||
Math.max(potionTicksMax, potionTicksMin)),
|
||||
getPotionStrength(),
|
||||
true, false, false));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity;
|
||||
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSurface;
|
||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootReference;
|
||||
import art.arcane.iris.engine.object.marker.IrisCommand;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListEntityType;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListSpecialEntity;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
|
||||
@Desc("Represents an iris entity.")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisEntity extends IrisRegistrant {
|
||||
@Required
|
||||
@RegistryListEntityType
|
||||
@Desc("The namespaced key of the entity type to spawn, such as minecraft:zombie or alexsmobs:grizzly_bear. To spawn a mob from another plugin or provider, set this type to unknown and define the special type.")
|
||||
private String type = null;
|
||||
|
||||
@Desc("The SpawnReason name to spawn the entity with, such as NATURAL or COMMAND.")
|
||||
private String reason = null;
|
||||
|
||||
@Desc("The custom name of this entity")
|
||||
private String customName = "";
|
||||
|
||||
@Desc("Should the name on this entity be visible even if you arent looking at it.")
|
||||
private boolean customNameVisible = false;
|
||||
|
||||
@Desc("If this entity type is a mob, should it be aware of it's surroundings & interact with the world.")
|
||||
private boolean aware = true;
|
||||
|
||||
@Desc("If this entity type is a creature, should it have ai goals.")
|
||||
private boolean ai = true;
|
||||
|
||||
@Desc("Should this entity be glowing")
|
||||
private boolean glowing = false;
|
||||
|
||||
@Desc("Should gravity apply to this entity")
|
||||
private boolean gravity = true;
|
||||
|
||||
@Desc("When an entity is invulnerable it can only be damaged by players increative mode.")
|
||||
private boolean invulnerable = false;
|
||||
|
||||
@Desc("When an entity is silent it will not produce any sound.")
|
||||
private boolean silent = false;
|
||||
|
||||
@Desc("Should this entity be allowed to pickup items")
|
||||
private boolean pickupItems = false;
|
||||
|
||||
@Desc("Should this entity be removed when far away")
|
||||
private boolean removable = false;
|
||||
|
||||
@Desc("Entity helmet equipment")
|
||||
private IrisLoot helmet = null;
|
||||
|
||||
@Desc("Entity chestplate equipment")
|
||||
private IrisLoot chestplate = null;
|
||||
|
||||
@Desc("Entity boots equipment")
|
||||
private IrisLoot boots = null;
|
||||
|
||||
@Desc("Entity leggings equipment")
|
||||
private IrisLoot leggings = null;
|
||||
|
||||
@Desc("Entity main hand equipment")
|
||||
private IrisLoot mainHand = null;
|
||||
|
||||
@Desc("Entity off hand equipment")
|
||||
private IrisLoot offHand = null;
|
||||
|
||||
@Desc("Make other entities ride this entity")
|
||||
@ArrayType(min = 1, type = IrisEntity.class)
|
||||
private KList<IrisEntity> passengers = new KList<>();
|
||||
|
||||
@Desc("Attribute modifiers for this entity")
|
||||
@ArrayType(min = 1, type = IrisAttributeModifier.class)
|
||||
private KList<IrisAttributeModifier> attributes = new KList<>();
|
||||
|
||||
@Desc("Loot tables for drops. Only the tables list is honored for entities; mode and multiplier are ignored, and the tables replace vanilla drops entirely.")
|
||||
private IrisLootReference loot = new IrisLootReference();
|
||||
|
||||
@Desc("If specified, this entity will be leashed by this entity. I.e. THIS ENTITY Leashed by SPECIFIED. This has no effect on EnderDragons, Withers, Players, or Bats.Non-living entities excluding leashes will not persist as leashholders.")
|
||||
private IrisEntity leashHolder = null;
|
||||
|
||||
@Desc("If specified, this entity will spawn with an effect")
|
||||
private IrisEffect spawnEffect = null;
|
||||
|
||||
@Desc("Simply moves the entity from below the surface slowly out of the ground as a spawn-in effect")
|
||||
private boolean spawnEffectRiseOutOfGround = false;
|
||||
|
||||
@Desc("The main gene for a panda if the entity type is a panda. One of NORMAL, LAZY, WORRIED, PLAYFUL, BROWN, WEAK or AGGRESSIVE.")
|
||||
private String pandaMainGene = null;
|
||||
|
||||
@Desc("The hidden gene for a panda if the entity type is a panda. One of NORMAL, LAZY, WORRIED, PLAYFUL, BROWN, WEAK or AGGRESSIVE.")
|
||||
private String pandaHiddenGene = null;
|
||||
|
||||
@Desc("The this entity is ageable, set it's baby status")
|
||||
private boolean baby = false;
|
||||
|
||||
@Desc("If the entity should never be culled.")
|
||||
private boolean keepEntity = false;
|
||||
|
||||
@Desc("The surface type to spawn this mob on")
|
||||
private IrisSurface surface = IrisSurface.LAND;
|
||||
|
||||
@RegistryListSpecialEntity
|
||||
@Desc("Create a mob from another plugin, such as Mythic Mobs. Should be in the format of a namespace of PluginName:MobName")
|
||||
private String specialType = "";
|
||||
|
||||
@Desc("Set to true if you want to apply all of the settings here to the mob, even though an external plugin has already done so.")
|
||||
private boolean applySettingsToCustomMobAnyways = false;
|
||||
|
||||
@ArrayType(min = 1, type = IrisCommand.class)
|
||||
@Desc("Run raw commands when this entity is spawned. Use {x}, {y}, and {z} for location. /summon pig {x} {y} {z}")
|
||||
private KList<IrisCommand> rawCommands = new KList<>();
|
||||
|
||||
public boolean isSpecialType() {
|
||||
return specialType != null && !specialType.equals("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "entities";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Entity";
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity;
|
||||
|
||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("entity-spawn")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents an entity spawn during initial chunk generation")
|
||||
@Data
|
||||
public class IrisEntitySpawn implements IRare {
|
||||
private final transient AtomicCache<RNG> rng = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisEntity> ent = new AtomicCache<>();
|
||||
@RegistryListResource(IrisEntity.class)
|
||||
@Required
|
||||
@Desc("The entity")
|
||||
private String entity = "";
|
||||
@MinNumber(1)
|
||||
@Desc("The 1 in RARITY chance for this entity to spawn")
|
||||
private int rarity = 1;
|
||||
@MinNumber(1)
|
||||
@Desc("The minumum of this entity to spawn")
|
||||
private int minSpawns = 1;
|
||||
@MinNumber(1)
|
||||
@Desc("The max of this entity to spawn")
|
||||
private int maxSpawns = 1;
|
||||
private transient IrisSpawner referenceSpawner;
|
||||
private transient IrisMarker referenceMarker;
|
||||
|
||||
public IrisEntity getRealEntity(Engine g) {
|
||||
return ent.aquire(() -> SpawnResources.entity(g.getData(), getEntity()));
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity;
|
||||
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListPotionEffect;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
@Snippet("potion-effect")
|
||||
@Desc("An iris potion effect")
|
||||
@Data
|
||||
public class IrisPotionEffect {
|
||||
private final transient AtomicCache<PotionEffectType> pt = new AtomicCache<>();
|
||||
@Required
|
||||
@RegistryListPotionEffect
|
||||
@Desc("The potion effect to apply in this area")
|
||||
private String potionEffect = "";
|
||||
@Required
|
||||
@MinNumber(-1)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The Potion Strength or -1 to disable")
|
||||
private int strength = -1;
|
||||
@Required
|
||||
@MinNumber(1)
|
||||
@Desc("The time the potion will last for")
|
||||
private int ticks = 200;
|
||||
@Desc("Is the effect ambient")
|
||||
private boolean ambient = false;
|
||||
@Desc("Is the effect showing particles")
|
||||
private boolean particles = true;
|
||||
|
||||
public PotionEffectType getRealType() {
|
||||
return pt.aquire(() ->
|
||||
{
|
||||
if (getPotionEffect() == null || getPotionEffect().isEmpty()) {
|
||||
return PotionEffectType.LUCK;
|
||||
}
|
||||
|
||||
try {
|
||||
PotionEffectType resolved = PotionEffectTypes.resolve(getPotionEffect());
|
||||
if (resolved != null) {
|
||||
return resolved;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
|
||||
if (PotionEffectTypes.shouldWarn(getPotionEffect())) {
|
||||
IrisLogging.warn("Unknown Potion Effect Type: \"" + getPotionEffect() + "\". Valid types: " + PotionEffectTypes.knownTypesList());
|
||||
}
|
||||
|
||||
return PotionEffectType.LUCK;
|
||||
});
|
||||
}
|
||||
|
||||
public void apply(LivingEntity p) {
|
||||
if (strength > -1) {
|
||||
if (p.hasPotionEffect(getRealType())) {
|
||||
PotionEffect e = p.getPotionEffect(getRealType());
|
||||
if (e.getAmplifier() > strength) {
|
||||
return;
|
||||
}
|
||||
|
||||
p.removePotionEffect(getRealType());
|
||||
}
|
||||
|
||||
p.addPotionEffect(new PotionEffect(getRealType(), ticks, strength, ambient, particles, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity;
|
||||
|
||||
import art.arcane.iris.util.common.reflect.KeyedType;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public final class PotionEffectTypes {
|
||||
private static final Map<String, String> LEGACY_ALIASES;
|
||||
private static final Set<String> MISSING_WARNED = ConcurrentHashMap.newKeySet();
|
||||
|
||||
static {
|
||||
Map<String, String> m = new HashMap<>();
|
||||
m.put("SLOW", "SLOWNESS");
|
||||
m.put("FAST_DIGGING", "HASTE");
|
||||
m.put("SLOW_DIGGING", "MINING_FATIGUE");
|
||||
m.put("INCREASE_DAMAGE", "STRENGTH");
|
||||
m.put("HEAL", "INSTANT_HEALTH");
|
||||
m.put("HARM", "INSTANT_DAMAGE");
|
||||
m.put("JUMP", "JUMP_BOOST");
|
||||
m.put("CONFUSION", "NAUSEA");
|
||||
m.put("DAMAGE_RESISTANCE", "RESISTANCE");
|
||||
LEGACY_ALIASES = Collections.unmodifiableMap(m);
|
||||
}
|
||||
|
||||
private PotionEffectTypes() {
|
||||
}
|
||||
|
||||
public static String normalize(String input) {
|
||||
if (input == null) {
|
||||
return "";
|
||||
}
|
||||
String upper = input.trim().toUpperCase(Locale.ROOT).replace(' ', '_');
|
||||
if (upper.contains(":")) {
|
||||
upper = upper.substring(upper.indexOf(':') + 1);
|
||||
}
|
||||
return LEGACY_ALIASES.getOrDefault(upper, upper);
|
||||
}
|
||||
|
||||
public static PotionEffectType resolve(String rawName) {
|
||||
if (rawName == null || rawName.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String wanted = normalize(rawName);
|
||||
for (PotionEffectType i : Registry.EFFECT) {
|
||||
NamespacedKey key = KeyedType.getKey(i);
|
||||
if (key == null) {
|
||||
continue;
|
||||
}
|
||||
String candidate = key.getKey().toUpperCase(Locale.ROOT).replace(' ', '_');
|
||||
if (candidate.equals(wanted)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String knownTypesList() {
|
||||
TreeSet<String> names = new TreeSet<>();
|
||||
for (PotionEffectType i : Registry.EFFECT) {
|
||||
NamespacedKey key = KeyedType.getKey(i);
|
||||
if (key != null) {
|
||||
names.add(key.getKey().toUpperCase(Locale.ROOT).replace(' ', '_'));
|
||||
}
|
||||
}
|
||||
return String.join(", ", names);
|
||||
}
|
||||
|
||||
public static boolean shouldWarn(String rawName) {
|
||||
return MISSING_WARNED.add(normalize(rawName));
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -18,8 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.entity.spawn;
|
||||
|
||||
import art.arcane.iris.engine.object.value.IrisRate;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.volmlib.util.math.M;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -28,11 +26,11 @@ public class IrisEngineSpawnerCooldown {
|
||||
private long lastSpawn = 0;
|
||||
private String spawner;
|
||||
|
||||
public void spawn(Engine engine) {
|
||||
public void spawn() {
|
||||
lastSpawn = M.ms();
|
||||
}
|
||||
|
||||
public boolean canSpawn(IrisRate s) {
|
||||
return M.ms() - lastSpawn > s.getInterval();
|
||||
public boolean canSpawn(long intervalMilliseconds) {
|
||||
return M.ms() - lastSpawn > intervalMilliseconds;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity.spawn;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Terrain modes are used to decide the generator type currently used")
|
||||
public enum IrisSpawnGroup {
|
||||
@Desc("Spawns on the terrain surface")
|
||||
NORMAL,
|
||||
|
||||
@Desc("Spawns in cave-air and low light level areas")
|
||||
CAVE,
|
||||
|
||||
@Desc("Spawns underwater")
|
||||
UNDERWATER,
|
||||
|
||||
@Desc("Spawns in beaches")
|
||||
BEACH
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity.spawn;
|
||||
|
||||
import art.arcane.iris.engine.object.entity.IrisEntitySpawn;
|
||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.engine.object.value.IrisRate;
|
||||
import art.arcane.iris.engine.object.world.IrisTimeBlock;
|
||||
import art.arcane.iris.engine.object.world.IrisWeather;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents an entity spawn during initial chunk generation")
|
||||
@Data
|
||||
public class IrisSpawner extends IrisRegistrant {
|
||||
|
||||
private transient IrisMarker referenceMarker;
|
||||
|
||||
@ArrayType(min = 1, type = IrisEntitySpawn.class)
|
||||
@Desc("The entity spawns to add")
|
||||
private KList<IrisEntitySpawn> spawns = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisEntitySpawn.class)
|
||||
@Desc("The entity spawns to add initially. EXECUTES PER CHUNK!")
|
||||
private KList<IrisEntitySpawn> initialSpawns = new KList<>();
|
||||
|
||||
@Desc("This spawner will not spawn in a given chunk if that chunk has more than the defined amount of living entities.")
|
||||
private int maxEntitiesPerChunk = 1;
|
||||
|
||||
@Desc("The block of 24 hour time to contain this spawn in.")
|
||||
private IrisTimeBlock timeBlock = new IrisTimeBlock();
|
||||
|
||||
@Desc("The weather condition required for this spawner to fire.")
|
||||
private IrisWeather weather = IrisWeather.ANY;
|
||||
|
||||
@Desc("The maximum rate this spawner can fire")
|
||||
private IrisRate maximumRate = new IrisRate();
|
||||
|
||||
@Desc("The maximum rate this spawner can fire on a specific chunk")
|
||||
private IrisRate maximumRatePerChunk = new IrisRate();
|
||||
|
||||
@Desc("The light levels this spawn is allowed to run in (0-15 inclusive)")
|
||||
private IrisRange allowedLightLevels = new IrisRange(0, 15);
|
||||
|
||||
@Desc("Where should these spawns be placed")
|
||||
private IrisSpawnGroup group = IrisSpawnGroup.NORMAL;
|
||||
|
||||
public boolean isValid(IrisBiome biome) {
|
||||
return switch (group) {
|
||||
case NORMAL -> switch (biome.getInferredType()) {
|
||||
case SHORE, SEA, CAVE -> false;
|
||||
case LAND -> true;
|
||||
};
|
||||
case CAVE -> true;
|
||||
case UNDERWATER -> switch (biome.getInferredType()) {
|
||||
case SHORE, LAND, CAVE -> false;
|
||||
case SEA -> true;
|
||||
};
|
||||
case BEACH -> switch (biome.getInferredType()) {
|
||||
case SHORE -> true;
|
||||
case LAND, CAVE, SEA -> false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isValid(PlatformWorld world) {
|
||||
return timeBlock.isWithin(world) && weather.is(world);
|
||||
}
|
||||
|
||||
public boolean canSpawn(Engine engine) {
|
||||
PlatformWorld world = engine.getWorld().platformWorld();
|
||||
if (world == null || !isValid(world))
|
||||
return false;
|
||||
|
||||
IrisRate rate = getMaximumRate();
|
||||
return rate.isInfinite() || engine.getEngineData().getCooldown(this).canSpawn(rate);
|
||||
}
|
||||
|
||||
public boolean canSpawn(Engine engine, int x, int z) {
|
||||
if (!canSpawn(engine))
|
||||
return false;
|
||||
|
||||
IrisRate rate = getMaximumRatePerChunk();
|
||||
return rate.isInfinite() || engine.getEngineData().getChunk(x, z).getCooldown(this).canSpawn(rate);
|
||||
}
|
||||
|
||||
public void spawn(Engine engine) {
|
||||
if (getMaximumRate().isInfinite())
|
||||
return;
|
||||
|
||||
engine.getEngineData().getCooldown(this).spawn(engine);
|
||||
}
|
||||
|
||||
public void spawn(Engine engine, int x, int z) {
|
||||
spawn(engine);
|
||||
if (getMaximumRatePerChunk().isInfinite())
|
||||
return;
|
||||
|
||||
engine.getEngineData().getChunk(x, z).getCooldown(this).spawn(engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "spawners";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Spawner";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.engine.object.entity.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
@@ -10,10 +11,6 @@ import lombok.NonNull;
|
||||
public class IrisSpawnerCooldowns {
|
||||
private final KMap<String, IrisEngineSpawnerCooldown> cooldowns = new KMap<>();
|
||||
|
||||
public IrisEngineSpawnerCooldown getCooldown(@NonNull IrisSpawner spawner) {
|
||||
return getCooldown(spawner.getLoadKey());
|
||||
}
|
||||
|
||||
public IrisEngineSpawnerCooldown getCooldown(@NonNull String loadKey) {
|
||||
return cooldowns.computeIfAbsent(loadKey, k -> {
|
||||
IrisEngineSpawnerCooldown cd = new IrisEngineSpawnerCooldown();
|
||||
@@ -24,8 +21,8 @@ public class IrisSpawnerCooldowns {
|
||||
|
||||
public void cleanup(Engine engine) {
|
||||
cooldowns.values().removeIf(cd -> {
|
||||
IrisSpawner sp = SpawnResources.spawner(engine.getData(), cd.getSpawner());
|
||||
return sp == null || cd.canSpawn(sp.getMaximumRate());
|
||||
Spawner spawner = SpawnResources.spawner(engine.getData(), cd.getSpawner());
|
||||
return spawner == null || cd.canSpawn(spawner.maximumRate().interval());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.entity.spawn;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("The type of surface entities should spawn on")
|
||||
public enum IrisSurface {
|
||||
|
||||
@Desc("Land surfaces")
|
||||
LAND,
|
||||
|
||||
@Desc("Any surfaces animals can spawn on, such as dirt, grass and podzol")
|
||||
ANIMAL,
|
||||
|
||||
@Desc("Within the water")
|
||||
WATER,
|
||||
|
||||
@Desc("On land or on water")
|
||||
OVERWORLD,
|
||||
|
||||
@Desc("Within lava")
|
||||
LAVA;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.loot;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("An inventory slot type is used to represent a type of slot for items to fit into in any given inventory.")
|
||||
public enum InventorySlotType {
|
||||
@Desc("Typically the one you want to go with. Storage represnents most slots in inventories.")
|
||||
STORAGE,
|
||||
|
||||
@Desc("Used for the fuel slot in Furnaces, Blast furnaces, smokers etc.")
|
||||
FUEL,
|
||||
|
||||
@Desc("Used for the cook slot in furnaces")
|
||||
FURNACE,
|
||||
@Desc("Used for the cook slot in blast furnaces")
|
||||
BLAST_FURNACE,
|
||||
|
||||
@Desc("Used for the cook slot in smokers")
|
||||
SMOKER,
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.loot;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.loot.LootItems;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.item.ItemDrop;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Snippet("block-drops")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents a block drop list")
|
||||
@Data
|
||||
public class IrisBlockDrops {
|
||||
private final transient AtomicCache<KList<PlatformBlockState>> data = new AtomicCache<>();
|
||||
@Required
|
||||
@ArrayType(min = 1, type = IrisBlockData.class)
|
||||
@Desc("The blocks that drop loot")
|
||||
private KList<IrisBlockData> blocks = new KList<>();
|
||||
@Desc("If exact blocks is set to true, minecraft:barrel[axis=x] will only drop for that axis. When exact is false (default) any barrel will drop the defined drops.")
|
||||
private boolean exactBlocks = false;
|
||||
@Desc("Add in specific items to drop")
|
||||
@ArrayType(min = 1, type = IrisLoot.class)
|
||||
private KList<IrisLoot> drops = new KList<>();
|
||||
@Desc("If this is in a biome, setting skipParents to true will ignore the drops in the region and dimension for this block type. The default (false) will allow all three nodes to fire and add to a list of drops.")
|
||||
private boolean skipParents = false;
|
||||
@Desc("Removes the default vanilla block drops and only drops the given items & any parent loot tables specified for this block type.")
|
||||
private boolean replaceVanillaDrops = false;
|
||||
|
||||
public boolean shouldDropFor(PlatformBlockState broken, IrisData rdata) {
|
||||
KList<PlatformBlockState> list = this.data.aquire(() -> {
|
||||
KList<PlatformBlockState> b = new KList<>();
|
||||
|
||||
for (IrisBlockData i : getBlocks()) {
|
||||
PlatformBlockState state = i.getBlockData(rdata);
|
||||
|
||||
if (state != null) {
|
||||
b.add(state);
|
||||
}
|
||||
}
|
||||
|
||||
return b.removeDuplicates();
|
||||
});
|
||||
|
||||
for (PlatformBlockState i : list) {
|
||||
if (exactBlocks ? i.key().equals(broken.key()) : materialOf(i).equals(materialOf(broken))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Adds the items of the drops that pass their rarity to {@code d}. */
|
||||
public void fillDrops(LootItems items, List<ItemDrop> d) {
|
||||
for (IrisLoot i : getDrops()) {
|
||||
if (!LootResolver.oneIn(RNG.r, i.getRarity())) {
|
||||
continue;
|
||||
}
|
||||
ItemDrop drop = items.give(i, RNG.r);
|
||||
if (drop != null) {
|
||||
d.add(drop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String materialOf(PlatformBlockState state) {
|
||||
String key = state.key();
|
||||
int properties = key.indexOf('[');
|
||||
return properties < 0 ? key : key.substring(0, properties);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.loot;
|
||||
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListEnchantment;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
|
||||
@Snippet("enchantment")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents an enchantment & level")
|
||||
@Data
|
||||
public class IrisEnchantment {
|
||||
@Required
|
||||
@RegistryListEnchantment
|
||||
@Desc("The enchantment")
|
||||
private String enchantment;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum amount of this loot")
|
||||
private int minLevel = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum amount of this loot")
|
||||
private int maxLevel = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance that this enchantment is applied (0 to 1)")
|
||||
private double chance = 1;
|
||||
|
||||
public int getLevel(RNG rng) {
|
||||
return LootResolver.inclusive(rng, getMinLevel(), getMaxLevel());
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.loot;
|
||||
|
||||
import art.arcane.iris.engine.object.entity.IrisAttributeModifier;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListItemType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("loot")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents a loot entry")
|
||||
@Data
|
||||
@EqualsAndHashCode(doNotUseGetters = true)
|
||||
@ToString(doNotUseGetters = true)
|
||||
public class IrisLoot {
|
||||
public static final int MAX_AMOUNT = 64;
|
||||
|
||||
@Desc("The target inventory slot types to fill this loot with. World generation only ever fills STORAGE; the other values are inert during worldgen.")
|
||||
private InventorySlotType slotTypes = InventorySlotType.STORAGE;
|
||||
@MinNumber(1)
|
||||
@Desc("The sub rarity of this loot. Calculated after this loot table has been picked.")
|
||||
private int rarity = 1;
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_AMOUNT)
|
||||
@Desc("Minimum amount of this loot, from 1 to 64")
|
||||
private int minAmount = 1;
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_AMOUNT)
|
||||
@Desc("Maximum amount of this loot, from 1 to 64")
|
||||
private int maxAmount = 1;
|
||||
@MinNumber(1)
|
||||
@Desc("The display name of this item")
|
||||
private String displayName = null;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Minimum durability percent")
|
||||
private double minDurability = 0;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Maximum durability percent")
|
||||
private double maxDurability = 1;
|
||||
@Desc("Define a custom model identifier 1.14+ only")
|
||||
private Integer customModel = null;
|
||||
@Desc("Set this to true to prevent it from being broken")
|
||||
private boolean unbreakable = false;
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("The item flags to add")
|
||||
private KList<String> itemFlags = new KList<>();
|
||||
@Desc("Apply enchantments to this item")
|
||||
@ArrayType(min = 1, type = IrisEnchantment.class)
|
||||
private KList<IrisEnchantment> enchantments = new KList<>();
|
||||
@Desc("Apply attribute modifiers to this item")
|
||||
@ArrayType(min = 1, type = IrisAttributeModifier.class)
|
||||
private KList<IrisAttributeModifier> attributes = new KList<>();
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Add lore to this item")
|
||||
private KList<String> lore = new KList<>();
|
||||
@RegistryListItemType
|
||||
@Required
|
||||
@Desc("This is the item or block type. Does not accept minecraft:*, only materials such as DIAMOND_SWORD or DIRT. The exception are modded materials, as they require a namespace.")
|
||||
private String type = "";
|
||||
@Desc("The dye color")
|
||||
private String dyeColor = null;
|
||||
@Desc("The leather armor color")
|
||||
private String leatherColor = null;
|
||||
@Desc("Defines a custom NBT Tag for the item.")
|
||||
private KMap<String, Object> customNbt;
|
||||
|
||||
/**
|
||||
* The authored item key, exactly as written in the pack. Each platform resolves it against its own item registry.
|
||||
*/
|
||||
public String getTypeKey() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The authored dye colour name, or null when unset.
|
||||
*/
|
||||
public String getDyeColorKey() {
|
||||
return dyeColor;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.loot;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("A loot mode is used to describe what to do with the existing loot layers before adding this loot. ADD appends to the building list of tables (dimension tables, then region tables, then biome tables). REPLACE swaps the parent tables for this reference's tables. CLEAR suppresses loot entirely at this point.")
|
||||
public enum IrisLootMode {
|
||||
@Desc("Add to the existing parent loot tables")
|
||||
ADD,
|
||||
@Desc("Clear all parent loot tables and contribute nothing at this level. Any tables listed here are ignored.")
|
||||
CLEAR,
|
||||
@Desc("Replace all parent loot tables with this reference's tables")
|
||||
REPLACE,
|
||||
@Desc("Only use when there was no loot table defined by an object")
|
||||
FALLBACK
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.loot;
|
||||
|
||||
import art.arcane.iris.engine.loot.LootResources;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.util.common.data.DataProvider;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("loot-registry")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents a loot entry")
|
||||
@Data
|
||||
public class IrisLootReference {
|
||||
public static final double MAX_MULTIPLIER = 16D;
|
||||
|
||||
private final transient AtomicCache<KList<IrisLootTable>> tt = new AtomicCache<>();
|
||||
@Desc("ADD = add on top of parent tables. REPLACE = clear parent tables, then add these. CLEAR = clear parent tables and add nothing, even if tables are listed. FALLBACK = only used when nothing else defined a table.")
|
||||
private IrisLootMode mode = IrisLootMode.ADD;
|
||||
@RegistryListResource(IrisLootTable.class)
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Add loot table registries here")
|
||||
private KList<String> tables = new KList<>();
|
||||
@MinNumber(0)
|
||||
@MaxNumber(MAX_MULTIPLIER)
|
||||
@Desc("Scale loot sources in this area from 0 to 16 times their normal count")
|
||||
private double multiplier = 1D;
|
||||
|
||||
public KList<IrisLootTable> getLootTables(DataProvider g) {
|
||||
return tt.aquire(() ->
|
||||
{
|
||||
KList<IrisLootTable> t = new KList<>();
|
||||
|
||||
for (String i : tables) {
|
||||
t.add(LootResources.table(g.getData(), i));
|
||||
}
|
||||
|
||||
return t;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.loot;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents a loot table. Biomes, Regions & Objects can add or replace the virtual table with these loot tables")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisLootTable extends IrisRegistrant {
|
||||
public static final int MAX_PICKED = 64;
|
||||
public static final int MAX_TRIES = 256;
|
||||
|
||||
@Required
|
||||
@Desc("The name of this loot table")
|
||||
@MinNumber(2)
|
||||
private String name = "";
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The rarity as in 1 in X chance")
|
||||
private int rarity = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_PICKED)
|
||||
@Desc("The maximum amount of loot that can be picked in this table at a time, from 1 to 64")
|
||||
private int maxPicked = 5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(MAX_PICKED)
|
||||
@Desc("The minimum amount of loot that can be picked in this table at a time, from 0 to 64")
|
||||
private int minPicked = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_TRIES)
|
||||
@Desc("The maximum amount of tries to generate loot, from 1 to 256")
|
||||
private int maxTries = 10;
|
||||
|
||||
@Desc("The loot in this table")
|
||||
@ArrayType(min = 1, type = IrisLoot.class)
|
||||
private KList<IrisLoot> loot = new KList<>();
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "loot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Loot";
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
@@ -50,7 +51,7 @@ public class IrisObjectLoot implements IObjectLoot {
|
||||
private boolean exact = false;
|
||||
@Desc("The loot table name")
|
||||
@Required
|
||||
@RegistryListResource(IrisLootTable.class)
|
||||
@RegistryListResource(LootTable.class)
|
||||
private String name;
|
||||
@Desc("The weight of this loot table being chosen")
|
||||
@MinNumber(1)
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package art.arcane.iris.engine.object.loot;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisVanillaLootTable extends IrisLootTable {
|
||||
/**
|
||||
* The vanilla loot table key ("minecraft:chests/simple_dungeon"), not the LootTable itself. A
|
||||
* raw org.bukkit.loot.LootTable field - and the constructor lombok would generate for it - makes
|
||||
* every reflective walk over the IrisLootTable hierarchy (Gson, schema generation, the purity
|
||||
* gate) resolve a Bukkit class. The host resolves the table when it pulls loot from it. The key text is
|
||||
* identical to what {@code LootTable.getKey().toString()} produced before, so
|
||||
* {@code LootTables.identity} (which falls back to
|
||||
* {@link #getName()}) yields the same loot seed.
|
||||
*/
|
||||
private final String lootTableKey;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Vanilla " + lootTableKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRarity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPicked() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinPicked() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxTries() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<IrisLoot> getLoot() {
|
||||
return new KList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
throw new UnsupportedOperationException("VanillaLootTables do not have a folder name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
throw new UnsupportedOperationException("VanillaLootTables do not have a type name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLoadFile() {
|
||||
throw new UnsupportedOperationException("VanillaLootTables do not have a load file");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisData getLoader() {
|
||||
throw new UnsupportedOperationException("VanillaLootTables do not have a loader");
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.marker;
|
||||
|
||||
import art.arcane.iris.engine.object.world.IrisTimeBlock;
|
||||
import art.arcane.iris.engine.object.world.IrisWeather;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import art.arcane.iris.util.common.scheduling.ConsoleCommands;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("command")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents a set of Iris commands")
|
||||
@Data
|
||||
public class IrisCommand {
|
||||
|
||||
@Required
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("List of commands. Iris replaces {x} {y} and {z} with the location of the entity spawn")
|
||||
private KList<String> commands = new KList<>();
|
||||
|
||||
@Desc("The delay for running the command. Instant by default")
|
||||
private long delay = 0;
|
||||
|
||||
@Desc("If this should be repeated (indefinitely, cannot be cancelled). This does not persist with server-restarts, so it only repeats when the chunk is generated.")
|
||||
private boolean repeat = false;
|
||||
|
||||
@Desc("The delay between repeats, in server ticks (by default 100, so 5 seconds)")
|
||||
private long repeatDelay = 100;
|
||||
|
||||
@Desc("The block of 24 hour time in which the command should execute.")
|
||||
private IrisTimeBlock timeBlock = new IrisTimeBlock();
|
||||
|
||||
@Desc("The weather that is required for the command to execute.")
|
||||
private IrisWeather weather = IrisWeather.ANY;
|
||||
|
||||
public boolean isValid(PlatformWorld world) {
|
||||
return timeBlock.isWithin(world) && weather.is(world);
|
||||
}
|
||||
|
||||
public void run(PlatformWorld world, int x, int y, int z) {
|
||||
if (!isValid(world)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConsoleCommands.run(commands, delay, repeat, repeatDelay, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.marker;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.DependsOn;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.platform.bukkit.BukkitWorld;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Snippet("command-registry")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents a casting location for a command")
|
||||
@Data
|
||||
public class IrisCommandRegistry {
|
||||
@Required
|
||||
@ArrayType(min = 1, type = IrisCommand.class)
|
||||
@Desc("Run commands, at the exact location of the player")
|
||||
private KList<IrisCommand> rawCommands = new KList<>();
|
||||
@DependsOn({"rawCommands"})
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt x, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double commandOffsetX = 0;
|
||||
@DependsOn({"rawCommands"})
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt y, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double commandOffsetY = 0;
|
||||
@DependsOn({"rawCommands"})
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt z, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double commandOffsetZ = 0;
|
||||
@DependsOn({"rawCommands"})
|
||||
@Desc("Randomize the altX from -altX to altX")
|
||||
private boolean commandRandomAltX = true;
|
||||
@DependsOn({"rawCommands"})
|
||||
@Desc("Randomize the altY from -altY to altY")
|
||||
private boolean commandRandomAltY = false;
|
||||
@DependsOn({"rawCommands"})
|
||||
@Desc("Randomize the altZ from -altZ to altZ")
|
||||
private boolean commandRandomAltZ = true;
|
||||
@DependsOn({"rawCommands"})
|
||||
@Desc("Randomize location for all separate commands (true), or run all on the same location (false)")
|
||||
private boolean commandAllRandomLocations = true;
|
||||
|
||||
public void run(Player p) {
|
||||
if (rawCommands.isNotEmpty()) {
|
||||
PlatformWorld world = new BukkitWorld(p.getWorld());
|
||||
Location part = p.getLocation().clone().add(
|
||||
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
|
||||
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
|
||||
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
|
||||
for (IrisCommand rawCommand : rawCommands) {
|
||||
rawCommand.run(world, part.getBlockX(), part.getBlockY(), part.getBlockZ());
|
||||
if (commandAllRandomLocations) {
|
||||
part = p.getLocation().clone().add(
|
||||
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
|
||||
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
|
||||
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.marker;
|
||||
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents a marker")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisMarker extends IrisRegistrant {
|
||||
@Desc("A list of spawners to add to anywhere this marker is.")
|
||||
@RegistryListResource(IrisSpawner.class)
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
private KList<String> spawners = new KList<>();
|
||||
|
||||
@Desc("Remove this marker when the block it's assigned to is changed.")
|
||||
private boolean removeOnChange = true;
|
||||
|
||||
@Desc("If true, markers will only be placed here if there is 2 air blocks above it.")
|
||||
private boolean emptyAbove = true;
|
||||
|
||||
@Desc("If this marker is used, what is the chance it removes itself. For example 25% (0.25) would mean that on average 4 uses will remove a specific marker. Set this below 0 (-1) to never exhaust & set this to 1 or higher to always exhaust on first use.")
|
||||
private double exhaustionChance = 0;
|
||||
|
||||
public boolean shouldExhaust() {
|
||||
return exhaustionChance > RNG.r.nextDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "markers";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Marker";
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.marker;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
@@ -54,7 +55,7 @@ public class IrisObjectMarker {
|
||||
@Desc("If true, markers will only be placed if the block matches the mark list perfectly.")
|
||||
private boolean exact = false;
|
||||
@Required
|
||||
@RegistryListResource(IrisMarker.class)
|
||||
@RegistryListResource(SpawnMarker.class)
|
||||
@Desc("The marker to add")
|
||||
private String marker;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import art.arcane.iris.builtin.blocks.ObjectMarkers;
|
||||
import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.core.modules.BlockEntities;
|
||||
import art.arcane.iris.core.modules.IrisPlacement;
|
||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.engine.object.marker.IrisObjectMarker;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectShaping;
|
||||
@@ -205,7 +205,7 @@ public final class BlocksModule implements IrisModule {
|
||||
RNG markerRandom = new RNG(context.random().nextLong());
|
||||
int salt = 0;
|
||||
for (IrisObjectMarker markerConfig : config.getMarkers()) {
|
||||
IrisMarker marker = SpawnResources.marker(placement.object().getLoader(), markerConfig.getMarker());
|
||||
SpawnMarker marker = SpawnResources.marker(placement.object().getLoader(), markerConfig.getMarker());
|
||||
int markerSalt = salt++;
|
||||
if (marker == null) {
|
||||
continue;
|
||||
@@ -216,7 +216,7 @@ public final class BlocksModule implements IrisModule {
|
||||
if (remaining <= 0) {
|
||||
break;
|
||||
}
|
||||
if (!marker.isEmptyAbove() || hasAirAbove(world, position)) {
|
||||
if (!marker.emptyAbove() || hasAirAbove(world, position)) {
|
||||
context.access().marker(ObjectMarkers.of(position, markerConfig.getMarker()));
|
||||
remaining--;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.engine.loot.LootResources;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
@@ -28,11 +27,8 @@ import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.core.modules.ModuleSettings;
|
||||
import art.arcane.iris.engine.object.loot.IObjectLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
import art.arcane.iris.engine.object.loot.IrisObjectLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisObjectVanillaLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisVanillaLootTable;
|
||||
import art.arcane.iris.engine.object.marker.IrisObjectMarker;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.IrisNoiseGenerator;
|
||||
@@ -42,13 +38,10 @@ import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectScale;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.volmlib.util.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
@@ -56,10 +49,7 @@ import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import art.arcane.iris.util.common.data.DataProvider;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
@@ -73,14 +63,9 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Snippet("object-placer")
|
||||
@EqualsAndHashCode()
|
||||
@@ -204,7 +189,6 @@ public class IrisObjectPlacement {
|
||||
@Desc("Ignore any placement restrictions for this object")
|
||||
@SerializedName(value = "forcePlace", alternate = {"force"})
|
||||
private boolean forcePlace = false;
|
||||
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
|
||||
/** The pack modules' settings this placement declares, decoded with it. */
|
||||
private transient ModuleSettings moduleSettings = ModuleSettings.NONE;
|
||||
|
||||
@@ -313,96 +297,6 @@ public class IrisObjectPlacement {
|
||||
return (int) Math.round(densityStyle.get(rng, x, z, data));
|
||||
}
|
||||
|
||||
private TableCache getCache(IrisData manager) {
|
||||
return cache.aquire(() -> {
|
||||
TableCache cache = new TableCache();
|
||||
|
||||
cache.merge(getCache(manager, getVanillaLoot(), IrisObjectPlacement::getVanillaTable));
|
||||
cache.merge(getCache(manager, getLoot(), key -> LootResources.table(manager, key)));
|
||||
|
||||
return cache;
|
||||
});
|
||||
}
|
||||
|
||||
private TableCache getCache(IrisData manager, KList<? extends IObjectLoot> list, Function<String, IrisLootTable> loader) {
|
||||
TableCache tc = new TableCache();
|
||||
|
||||
for (IObjectLoot loot : list) {
|
||||
if (loot == null || loot.getWeight() <= 0)
|
||||
continue;
|
||||
IrisLootTable table = loader.apply(loot.getName());
|
||||
if (table == null) {
|
||||
IrisLogging.warn("Couldn't find loot table " + loot.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (loot.getFilter().isEmpty()) //Table applies to all containers
|
||||
{
|
||||
tc.global.put(table, loot.getWeight());
|
||||
} else if (!loot.isExact()) //Table is meant to be by type
|
||||
{
|
||||
for (PlatformBlockState filterState : loot.getFilter(manager)) {
|
||||
BlockData filterData = (BlockData) filterState.nativeHandle();
|
||||
if (!tc.basic.containsKey(filterData.getMaterial())) {
|
||||
tc.basic.put(filterData.getMaterial(), new WeightedTables());
|
||||
}
|
||||
|
||||
tc.basic.get(filterData.getMaterial()).put(table, loot.getWeight());
|
||||
}
|
||||
} else //Filter is exact
|
||||
{
|
||||
for (PlatformBlockState filterState : loot.getFilter(manager)) {
|
||||
BlockData filterData = (BlockData) filterState.nativeHandle();
|
||||
if (!tc.exact.containsKey(filterData.getMaterial())) {
|
||||
tc.exact.put(filterData.getMaterial(), new KMap<>());
|
||||
}
|
||||
|
||||
if (!tc.exact.get(filterData.getMaterial()).containsKey(filterData)) {
|
||||
tc.exact.get(filterData.getMaterial()).put(filterData, new WeightedTables());
|
||||
}
|
||||
|
||||
tc.exact.get(filterData.getMaterial()).get(filterData).put(table, loot.getWeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static IrisVanillaLootTable getVanillaTable(String name) {
|
||||
return Optional.ofNullable(NamespacedKey.fromString(name))
|
||||
.map(Bukkit::getLootTable)
|
||||
// Hand over the key, not the LootTable: IrisVanillaLootTable holds no Bukkit fields.
|
||||
.map(table -> new IrisVanillaLootTable(String.valueOf(table.getKey())))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loot table that should be used for the block
|
||||
*
|
||||
* @param state The block state of the block
|
||||
* @param dataManager Iris Data Manager
|
||||
* @return The loot table it should use.
|
||||
*/
|
||||
public IrisLootTable getTable(PlatformBlockState state, IrisData dataManager, RNG rng) {
|
||||
TableCache cache = getCache(dataManager);
|
||||
BlockData data = (BlockData) state.nativeHandle();
|
||||
if (BukkitBlockResolution.isStorageChest(data)) {
|
||||
IrisLootTable picked = null;
|
||||
if (cache.exact.containsKey(data.getMaterial()) && cache.exact.get(data.getMaterial()).containsKey(data)) {
|
||||
picked = cache.exact.get(data.getMaterial()).get(data).pullRandom(rng);
|
||||
} else if (cache.basic.containsKey(data.getMaterial())) {
|
||||
picked = cache.basic.get(data.getMaterial()).pullRandom(rng);
|
||||
} else if (!cache.global.isEmpty()) {
|
||||
picked = cache.global.pullRandom(rng);
|
||||
}
|
||||
|
||||
return picked;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final class SurfaceWarpCacheKey {
|
||||
private final IrisData data;
|
||||
private final Engine engine;
|
||||
@@ -432,41 +326,4 @@ public class IrisObjectPlacement {
|
||||
return 31 * result + Long.hashCode(seed);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TableCache {
|
||||
final transient WeightedTables global = new WeightedTables();
|
||||
final transient KMap<Material, WeightedTables> basic = new KMap<>();
|
||||
final transient KMap<Material, KMap<BlockData, WeightedTables>> exact = new KMap<>();
|
||||
|
||||
private void merge(TableCache other) {
|
||||
global.merge(other.global);
|
||||
basic.merge(other.basic, WeightedTables::merge);
|
||||
exact.merge(other.exact, (a, b) -> a.merge(b, WeightedTables::merge));
|
||||
}
|
||||
}
|
||||
|
||||
private static final class WeightedTables {
|
||||
private final KList<WeightedTable> tables = new KList<>();
|
||||
|
||||
private void put(IrisLootTable table, int weight) {
|
||||
tables.add(new WeightedTable(table, weight));
|
||||
}
|
||||
|
||||
private IrisLootTable pullRandom(RNG rng) {
|
||||
WeightedTable picked = LootResolver.pickWeighted(tables, WeightedTable::weight, rng);
|
||||
return picked == null ? null : picked.table();
|
||||
}
|
||||
|
||||
private boolean isEmpty() {
|
||||
return tables.isEmpty();
|
||||
}
|
||||
|
||||
private WeightedTables merge(WeightedTables other) {
|
||||
tables.addAll(other.tables);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private record WeightedTable(IrisLootTable table, int weight) {
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.core.modules.IrisPlacement;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.noise.SimplexNoise;
|
||||
@@ -82,7 +82,7 @@ public final class VacuumModule implements IrisModule {
|
||||
private final IrisPlacement placement;
|
||||
private final PreparedPlacement prepared;
|
||||
private final PlacementWorld world;
|
||||
private final IrisComplex complex;
|
||||
private final TerrainPalettes palettes;
|
||||
private final int radius;
|
||||
private final int step;
|
||||
private final double falloff;
|
||||
@@ -98,7 +98,7 @@ public final class VacuumModule implements IrisModule {
|
||||
this.placement = IrisPlacement.current();
|
||||
this.prepared = prepared;
|
||||
this.world = new PlacementWorld(context.access(), placement.states());
|
||||
this.complex = engine.getComplex();
|
||||
this.palettes = engine.getComplex() == null ? null : TerrainPalettes.of(engine);
|
||||
VacuumSettings settings = prepared.config().getVacuumSettings();
|
||||
this.radius = IrisObjectVacuum.resolveRadius(vacuum, settings);
|
||||
this.step = vacuum.columnStepBlocks();
|
||||
@@ -161,7 +161,7 @@ public final class VacuumModule implements IrisModule {
|
||||
}
|
||||
|
||||
private void raise(int x, int z, int fromY, int toY) {
|
||||
PlatformBlockState fill = complex != null ? complex.getRockStream().get(x, z) : null;
|
||||
PlatformBlockState fill = palettes != null ? palettes.rockAt(x, z) : null;
|
||||
if (B.isAir(fill)) {
|
||||
fill = IrisObject.States.STONE;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package art.arcane.iris.engine.object.structure;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.engine.object.loot.IrisObjectLoot;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||
@@ -102,7 +102,7 @@ public class IrisStructure extends IrisRegistrant {
|
||||
private KList<ObjectReplace> edit = new KList<>();
|
||||
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
@RegistryListResource(IrisLootTable.class)
|
||||
@RegistryListResource(LootTable.class)
|
||||
@Desc("Loot tables applied to containers placed by this structure's pieces.")
|
||||
private KList<String> loot = new KList<>();
|
||||
|
||||
|
||||
@@ -1,360 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* Layer (block palette) generation for {@link IrisBiome}. IrisBiome is Gson deserialized from pack
|
||||
* JSON, so its fields stay put and only the behavior lives here.
|
||||
*/
|
||||
public final class IrisBiomeLayerGenerator {
|
||||
private static final class States {
|
||||
private static final PlatformBlockState BARRIER = B.getState("BARRIER");
|
||||
}
|
||||
|
||||
private IrisBiomeLayerGenerator() {
|
||||
}
|
||||
|
||||
public static KList<PlatformBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
if (biome.isLockLayers()) {
|
||||
return generateLockedLayers(biome, wx, wz, random, maxDepth, height, rdata, complex);
|
||||
}
|
||||
|
||||
KList<PlatformBlockState> data = new KList<>();
|
||||
|
||||
if (maxDepth <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
|
||||
int layerCount = layers.size();
|
||||
|
||||
if (layerCount <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
|
||||
|
||||
for (int i = 0; i < layerCount; i++) {
|
||||
IrisBiomePaletteLayer layer = layers.get(i);
|
||||
double zoom = layer.getZoom();
|
||||
CNG hgen = heightGenerators.get(i);
|
||||
double d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
|
||||
|
||||
SlopeClip sc = layer.getSlopeCondition();
|
||||
|
||||
if (!sc.isDefault()) {
|
||||
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (d <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (dim.isExplodeBiomePalettes()) {
|
||||
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||
data.add(States.BARRIER);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static KList<PlatformBlockState> generateCeilingLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
KList<PlatformBlockState> data = new KList<>();
|
||||
|
||||
if (maxDepth <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<IrisBiomePaletteLayer> ceilingLayers = biome.getCaveCeilingLayers();
|
||||
int layerCount = ceilingLayers.size();
|
||||
|
||||
if (layerCount <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
|
||||
// Ceiling layers reuse the surface-layer height generators, so entries beyond layers.size() have no generator; skip them.
|
||||
int usableLayers = Math.min(layerCount, heightGenerators.size());
|
||||
|
||||
for (int i = 0; i < usableLayers; i++) {
|
||||
IrisBiomePaletteLayer layer = ceilingLayers.get(i);
|
||||
double zoom = layer.getZoom();
|
||||
CNG hgen = heightGenerators.get(i);
|
||||
double d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
|
||||
|
||||
if (d <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (dim.isExplodeBiomePalettes()) {
|
||||
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||
data.add(States.BARRIER);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static KList<PlatformBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex) {
|
||||
KList<PlatformBlockState> data = new KList<>();
|
||||
KList<PlatformBlockState> real = new KList<>();
|
||||
int maxDepth = Math.min(maxDepthf, biome.getLockLayersMax());
|
||||
if (maxDepth <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
|
||||
int layerCount = layers.size();
|
||||
|
||||
if (layerCount > 0) {
|
||||
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
|
||||
|
||||
for (int i = 0; i < layerCount; i++) {
|
||||
IrisBiomePaletteLayer layer = layers.get(i);
|
||||
double zoom = layer.getZoom();
|
||||
CNG hgen = heightGenerators.get(i);
|
||||
double d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
|
||||
|
||||
SlopeClip sc = layer.getSlopeCondition();
|
||||
|
||||
if (!sc.isDefault()) {
|
||||
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (d <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
try {
|
||||
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.isEmpty()) {
|
||||
return real;
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxDepth; i++) {
|
||||
int offset = (512 - height) - i;
|
||||
int index = offset % data.size();
|
||||
real.add(data.get(Math.max(index, 0)));
|
||||
}
|
||||
|
||||
return real;
|
||||
}
|
||||
|
||||
public static KList<PlatformBlockState> generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
|
||||
KList<PlatformBlockState> data = new KList<>();
|
||||
|
||||
KList<IrisBiomePaletteLayer> seaLayers = biome.getSeaLayers();
|
||||
int layerCount = seaLayers.size();
|
||||
|
||||
if (layerCount <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<CNG> heightGenerators = getLayerSeaHeightGenerators(biome, random, rdata);
|
||||
|
||||
for (int i = 0; i < layerCount; i++) {
|
||||
IrisBiomePaletteLayer layer = seaLayers.get(i);
|
||||
double zoom = layer.getZoom();
|
||||
CNG hgen = heightGenerators.get(i);
|
||||
int d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
|
||||
|
||||
if (d < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static KList<CNG> getLayerHeightGenerators(IrisBiome biome, RNG rng, IrisData rdata) {
|
||||
AtomicCache<KList<CNG>> cache = biome.getLayerHeightGenerators();
|
||||
KList<CNG> cached = cache.getIfPresent();
|
||||
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return cache.aquire(() ->
|
||||
{
|
||||
KList<CNG> layerHeightGenerators = new KList<>();
|
||||
|
||||
int m = 7235;
|
||||
|
||||
for (IrisBiomePaletteLayer i : biome.getLayers()) {
|
||||
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), rdata));
|
||||
}
|
||||
|
||||
return layerHeightGenerators;
|
||||
});
|
||||
}
|
||||
|
||||
public static KList<CNG> getLayerSeaHeightGenerators(IrisBiome biome, RNG rng, IrisData data) {
|
||||
AtomicCache<KList<CNG>> cache = biome.getLayerSeaHeightGenerators();
|
||||
KList<CNG> cached = cache.getIfPresent();
|
||||
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return cache.aquire(() ->
|
||||
{
|
||||
KList<CNG> layerSeaHeightGenerators = new KList<>();
|
||||
|
||||
int m = 7735;
|
||||
|
||||
for (IrisBiomePaletteLayer i : biome.getSeaLayers()) {
|
||||
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), data));
|
||||
}
|
||||
|
||||
return layerSeaHeightGenerators;
|
||||
});
|
||||
}
|
||||
|
||||
public static PlatformBlockState getSurfaceBlock(IrisBiome biome, int x, int z, RNG rng, IrisData idm) {
|
||||
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
|
||||
|
||||
if (layers.isEmpty()) {
|
||||
return B.getState("AIR");
|
||||
}
|
||||
|
||||
return layers.get(0).get(rng, x, 0, z, idm);
|
||||
}
|
||||
|
||||
public static int getMaxHeight(IrisBiome biome, Engine engine) {
|
||||
return biome.getMaxHeight().aquire(() ->
|
||||
{
|
||||
int maxHeight = 0;
|
||||
|
||||
for (IrisBiomeGeneratorLink i : biome.getGenerators()) {
|
||||
maxHeight += i.getMax();
|
||||
}
|
||||
|
||||
return maxHeight;
|
||||
});
|
||||
}
|
||||
|
||||
public static int getMaxWithObjectHeight(IrisBiome biome, IrisData data, Engine engine) {
|
||||
return biome.getMaxWithObjectHeight().aquire(() ->
|
||||
{
|
||||
int maxHeight = 0;
|
||||
|
||||
for (IrisBiomeGeneratorLink i : biome.getGenerators()) {
|
||||
maxHeight += i.getMax();
|
||||
}
|
||||
|
||||
int gg = 0;
|
||||
|
||||
for (IrisObjectPlacement i : biome.getObjects()) {
|
||||
for (IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) {
|
||||
gg = Math.max(gg, j.getH());
|
||||
}
|
||||
}
|
||||
|
||||
return maxHeight + gg + 3;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.DependsOn;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("biome-palette")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A layer of surface / subsurface material in biomes")
|
||||
@Data
|
||||
public class IrisBiomePaletteLayer {
|
||||
private final transient AtomicCache<KList<PlatformBlockState>> blockData = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> layerGenerator = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
|
||||
@Desc("The style of noise")
|
||||
private IrisGeneratorStyle style = NoiseStyle.STATIC.style();
|
||||
@DependsOn({"minHeight", "maxHeight"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(2032)
|
||||
|
||||
@Desc("The min thickness of this layer")
|
||||
private int minHeight = 1;
|
||||
@DependsOn({"minHeight", "maxHeight"})
|
||||
@MinNumber(1)
|
||||
@MaxNumber(2032)
|
||||
|
||||
@Desc("The max thickness of this layer")
|
||||
private int maxHeight = 1;
|
||||
@Desc("If set, this layer only shows where the terrain slope is within these bounds; outside them the layer is skipped entirely. Thickness is not scaled by slope.")
|
||||
private SlopeClip slopeCondition = new SlopeClip();
|
||||
@MinNumber(0.0001)
|
||||
@Desc("The terrain zoom mostly for zooming in on a wispy palette")
|
||||
private double zoom = 5;
|
||||
@Required
|
||||
@ArrayType(min = 1, type = IrisBlockData.class)
|
||||
@Desc("The palette of blocks to be used in this layer")
|
||||
private KList<IrisBlockData> palette = new KList<IrisBlockData>().qadd(new IrisBlockData("GRASS_BLOCK"));
|
||||
|
||||
public CNG getHeightGenerator(RNG rng, IrisData data) {
|
||||
CNG cached = heightGenerator.getIfPresent();
|
||||
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return heightGenerator.aquire(() -> CNG.signature(rng.nextParallelRNG(minHeight * maxHeight + getBlockData(data).size())));
|
||||
}
|
||||
|
||||
public PlatformBlockState get(RNG rng, double x, double y, double z, IrisData data) {
|
||||
return get(rng, 0, x, y, z, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a block for this layer without allocating a child RNG per call. The child RNG is
|
||||
* only built inside the lazy layer generator initializer, using the exact same seed derivation
|
||||
* as {@code parent.nextParallelRNG(signature)} followed by the generator signature.
|
||||
*/
|
||||
public PlatformBlockState get(RNG parent, int signature, double x, double y, double z, IrisData data) {
|
||||
KList<PlatformBlockState> localBlockData = getBlockData(data);
|
||||
|
||||
if (localBlockData.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (localBlockData.size() == 1) {
|
||||
return localBlockData.get(0);
|
||||
}
|
||||
|
||||
double localZoom = zoom;
|
||||
double scaledX = x / localZoom;
|
||||
double scaledY = y / localZoom;
|
||||
double scaledZ = z / localZoom;
|
||||
return getLayerGenerator(parent, signature, data).fit(localBlockData, scaledX, scaledY, scaledZ);
|
||||
}
|
||||
|
||||
public CNG getLayerGenerator(RNG rng, IrisData data) {
|
||||
return getLayerGenerator(rng, 0, data);
|
||||
}
|
||||
|
||||
public CNG getLayerGenerator(RNG parent, int signature, IrisData data) {
|
||||
CNG cached = layerGenerator.getIfPresent();
|
||||
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return layerGenerator.aquire(() ->
|
||||
{
|
||||
RNG rngx = parent.nextParallelRNG(signature).nextParallelRNG(minHeight + maxHeight + getBlockData(data).size());
|
||||
return style.create(rngx, data);
|
||||
});
|
||||
}
|
||||
|
||||
public KList<IrisBlockData> add(String b) {
|
||||
palette.add(new IrisBlockData(b));
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
public KList<PlatformBlockState> getBlockData(IrisData data) {
|
||||
KList<PlatformBlockState> cached = blockData.getIfPresent();
|
||||
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return blockData.aquire(() ->
|
||||
{
|
||||
KList<PlatformBlockState> blockData = new KList<>();
|
||||
for (IrisBlockData ix : palette) {
|
||||
PlatformBlockState bx = ix.getBlockData(data);
|
||||
if (bx != null) {
|
||||
for (int i = 0; i < ix.getWeight(); i++) {
|
||||
blockData.add(bx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return blockData;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisBiomePaletteLayer zero() {
|
||||
palette.clear();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingEntry;
|
||||
import art.arcane.iris.builtin.carve.CarvingSettings;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* What the carve module keeps for one world: the cave biome bands its dimension declares ({@link CarvingSettings}) made ready
|
||||
* ({@link ResolvedCarvingEntry}), in the order the dimension lists them, and by id.
|
||||
*/
|
||||
public final class CarvingBands {
|
||||
private final List<ResolvedCarvingEntry> entries;
|
||||
private final Map<String, ResolvedCarvingEntry> index;
|
||||
|
||||
CarvingBands(List<CarvingEntry> declared) {
|
||||
this.entries = declared.stream().filter(Objects::nonNull).map(ResolvedCarvingEntry::new).toList();
|
||||
this.index = indexById(entries);
|
||||
}
|
||||
|
||||
CarvingBands(Engine engine) {
|
||||
this(engine.getDimension().getModuleSettings().find(CarvingSettings.class).map(CarvingSettings::entries).orElse(List.of()));
|
||||
}
|
||||
|
||||
/** The bands of the world {@code engine} generates now. */
|
||||
public static CarvingBands of(Engine engine) {
|
||||
return engine.getGeneration().state(CarvingBands.class, CarvingBands::new);
|
||||
}
|
||||
|
||||
/** Every declared entry, enabled or not. */
|
||||
public List<ResolvedCarvingEntry> entries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
/** The entries by their trimmed ids; entries without an id are not in it, and the last of several with one id is. */
|
||||
public Map<String, ResolvedCarvingEntry> index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
private static Map<String, ResolvedCarvingEntry> indexById(List<ResolvedCarvingEntry> entries) {
|
||||
Map<String, ResolvedCarvingEntry> index = new HashMap<>();
|
||||
for (ResolvedCarvingEntry entry : entries) {
|
||||
if (!entry.id().isBlank()) {
|
||||
index.put(entry.id().trim(), entry);
|
||||
}
|
||||
}
|
||||
return Map.copyOf(index);
|
||||
}
|
||||
}
|
||||
+59
-67
@@ -1,14 +1,13 @@
|
||||
package art.arcane.iris.engine.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.util.project.interpolation.IrisInterpolation;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import com.volmit.config.Range;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
@@ -17,36 +16,40 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class IrisDimensionCarvingResolver {
|
||||
/**
|
||||
* Picks the dimension's carving entry for a position: the last enabled root entry whose world Y band holds the height,
|
||||
* then, through the entries' children, the one a noise pattern selects at the column. The state a caller passes (or, when
|
||||
* it passes none, the thread's) keeps the picks and the entries' biomes, so a caller resolving many positions reuses them.
|
||||
*/
|
||||
public final class CarvingResolver {
|
||||
private static final int MAX_CHILD_DEPTH = 32;
|
||||
private static final long CHILD_SEED_SALT = 0x9E3779B97F4A7C15L;
|
||||
private static final ThreadLocal<WeakReference<State>> THREAD_STATE =
|
||||
ThreadLocal.withInitial(() -> new WeakReference<>(null));
|
||||
|
||||
private IrisDimensionCarvingResolver() {
|
||||
private CarvingResolver() {
|
||||
|
||||
}
|
||||
|
||||
public static IrisDimensionCarvingEntry resolveRootEntry(Engine engine, int worldY) {
|
||||
public static ResolvedCarvingEntry resolveRootEntry(Engine engine, int worldY) {
|
||||
return resolveRootEntry(engine, worldY, threadState());
|
||||
}
|
||||
|
||||
public static IrisDimensionCarvingEntry resolveRootEntry(Engine engine, int worldY, State state) {
|
||||
public static ResolvedCarvingEntry resolveRootEntry(Engine engine, int worldY, State state) {
|
||||
State resolvedState = state == null ? threadState() : state;
|
||||
resolvedState.bind(engine);
|
||||
if (resolvedState.rootEntriesByWorldY.containsKey(worldY)) {
|
||||
return resolvedState.rootEntriesByWorldY.get(worldY);
|
||||
}
|
||||
|
||||
IrisDimension dimension = engine.getDimension();
|
||||
List<IrisDimensionCarvingEntry> entries = dimension.getCarving();
|
||||
if (entries == null || entries.isEmpty()) {
|
||||
List<ResolvedCarvingEntry> entries = resolvedState.bands.entries();
|
||||
if (entries.isEmpty()) {
|
||||
resolvedState.rootEntriesByWorldY.put(worldY, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
IrisDimensionCarvingEntry resolved = null;
|
||||
for (IrisDimensionCarvingEntry entry : entries) {
|
||||
ResolvedCarvingEntry resolved = null;
|
||||
for (ResolvedCarvingEntry entry : entries) {
|
||||
if (!isRootCandidate(engine, entry, worldY, resolvedState)) {
|
||||
continue;
|
||||
}
|
||||
@@ -58,11 +61,11 @@ public final class IrisDimensionCarvingResolver {
|
||||
return resolved;
|
||||
}
|
||||
|
||||
public static IrisDimensionCarvingEntry resolveFromRoot(Engine engine, IrisDimensionCarvingEntry rootEntry, int worldX, int worldZ) {
|
||||
public static ResolvedCarvingEntry resolveFromRoot(Engine engine, ResolvedCarvingEntry rootEntry, int worldX, int worldZ) {
|
||||
return resolveFromRoot(engine, rootEntry, worldX, worldZ, threadState());
|
||||
}
|
||||
|
||||
public static IrisDimensionCarvingEntry resolveFromRoot(Engine engine, IrisDimensionCarvingEntry rootEntry, int worldX, int worldZ, State state) {
|
||||
public static ResolvedCarvingEntry resolveFromRoot(Engine engine, ResolvedCarvingEntry rootEntry, int worldX, int worldZ, State state) {
|
||||
State resolvedState = state == null ? threadState() : state;
|
||||
resolvedState.bind(engine);
|
||||
if (rootEntry == null) {
|
||||
@@ -74,22 +77,22 @@ public final class IrisDimensionCarvingResolver {
|
||||
return null;
|
||||
}
|
||||
|
||||
int remainingDepth = clampDepth(rootEntry.getChildRecursionDepth());
|
||||
int remainingDepth = clampDepth(rootEntry.childRecursionDepth());
|
||||
if (remainingDepth <= 0) {
|
||||
return rootEntry;
|
||||
}
|
||||
|
||||
Map<String, IrisDimensionCarvingEntry> entryIndex = resolveEntryIndex(engine, resolvedState);
|
||||
IrisDimensionCarvingEntry current = rootEntry;
|
||||
Map<String, ResolvedCarvingEntry> entryIndex = resolvedState.bands.index();
|
||||
ResolvedCarvingEntry current = rootEntry;
|
||||
int depth = remainingDepth;
|
||||
while (depth > 0) {
|
||||
IrisDimensionCarvingEntry selected = selectChild(engine, current, worldX, worldZ, entryIndex, resolvedState);
|
||||
ResolvedCarvingEntry selected = selectChild(engine, current, worldX, worldZ, entryIndex, resolvedState);
|
||||
if (selected == null || selected == current) {
|
||||
break;
|
||||
}
|
||||
|
||||
depth--;
|
||||
int childDepthLimit = clampDepth(selected.getChildRecursionDepth());
|
||||
int childDepthLimit = clampDepth(selected.childRecursionDepth());
|
||||
if (childDepthLimit < depth) {
|
||||
depth = childDepthLimit;
|
||||
}
|
||||
@@ -99,17 +102,17 @@ public final class IrisDimensionCarvingResolver {
|
||||
return current;
|
||||
}
|
||||
|
||||
public static IrisBiome resolveEntryBiome(Engine engine, IrisDimensionCarvingEntry entry) {
|
||||
public static IrisBiome resolveEntryBiome(Engine engine, ResolvedCarvingEntry entry) {
|
||||
return resolveEntryBiome(engine, entry, null);
|
||||
}
|
||||
|
||||
public static IrisBiome resolveEntryBiome(Engine engine, IrisDimensionCarvingEntry entry, State state) {
|
||||
public static IrisBiome resolveEntryBiome(Engine engine, ResolvedCarvingEntry entry, State state) {
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state == null) {
|
||||
return entry.getRealBiome(engine.getData());
|
||||
return entry.realBiome(engine.getData());
|
||||
}
|
||||
|
||||
state.bind(engine);
|
||||
@@ -117,17 +120,17 @@ public final class IrisDimensionCarvingResolver {
|
||||
return state.biomeCache.get(entry);
|
||||
}
|
||||
|
||||
IrisBiome biome = entry.getRealBiome(engine.getData());
|
||||
IrisBiome biome = entry.realBiome(engine.getData());
|
||||
state.biomeCache.put(entry, biome);
|
||||
return biome;
|
||||
}
|
||||
|
||||
private static boolean isRootCandidate(Engine engine, IrisDimensionCarvingEntry entry, int worldY, State state) {
|
||||
if (entry == null || !entry.isEnabled()) {
|
||||
private static boolean isRootCandidate(Engine engine, ResolvedCarvingEntry entry, int worldY, State state) {
|
||||
if (entry == null || !entry.enabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IrisRange worldYRange = entry.getWorldYRange();
|
||||
Range worldYRange = entry.worldYRange();
|
||||
if (worldYRange != null && !worldYRange.contains(worldY)) {
|
||||
return false;
|
||||
}
|
||||
@@ -135,16 +138,16 @@ public final class IrisDimensionCarvingResolver {
|
||||
return resolveEntryBiome(engine, entry, state) != null;
|
||||
}
|
||||
|
||||
private static IrisDimensionCarvingEntry selectChild(
|
||||
private static ResolvedCarvingEntry selectChild(
|
||||
Engine engine,
|
||||
IrisDimensionCarvingEntry parent,
|
||||
ResolvedCarvingEntry parent,
|
||||
int worldX,
|
||||
int worldZ,
|
||||
Map<String, IrisDimensionCarvingEntry> entryIndex,
|
||||
Map<String, ResolvedCarvingEntry> entryIndex,
|
||||
State state
|
||||
) {
|
||||
KList<String> children = parent.getChildren();
|
||||
if (children == null || children.isEmpty()) {
|
||||
List<String> children = parent.children();
|
||||
if (children.isEmpty()) {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -164,7 +167,7 @@ public final class IrisDimensionCarvingResolver {
|
||||
}
|
||||
|
||||
long seed = resolveChildSeed(engine, state);
|
||||
CNG childGenerator = parent.getChildrenGenerator(seed, engine.getData());
|
||||
CNG childGenerator = parent.childrenGenerator(seed, engine.getData());
|
||||
double sample = childGenerator.noiseFast2D(worldX, worldZ);
|
||||
int selectedIndex = (int) Math.round(IrisInterpolation.lerp(0, selectionPlan.maxIndex, sample));
|
||||
CarvingChoice selected = selectionPlan.get(selectedIndex);
|
||||
@@ -177,31 +180,28 @@ public final class IrisDimensionCarvingResolver {
|
||||
|
||||
private static ParentSelectionPlan buildSelectionPlan(
|
||||
Engine engine,
|
||||
IrisDimensionCarvingEntry parent,
|
||||
ResolvedCarvingEntry parent,
|
||||
IrisBiome parentBiome,
|
||||
Map<String, IrisDimensionCarvingEntry> entryIndex,
|
||||
Map<String, ResolvedCarvingEntry> entryIndex,
|
||||
State state
|
||||
) {
|
||||
List<CarvingChoice> options = new ArrayList<>();
|
||||
KList<String> children = parent.getChildren();
|
||||
if (children != null) {
|
||||
for (String childId : children) {
|
||||
if (childId == null || childId.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IrisDimensionCarvingEntry child = entryIndex.get(childId.trim());
|
||||
if (child == null || !child.isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IrisBiome childBiome = resolveEntryBiome(engine, child, state);
|
||||
if (childBiome == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
options.add(new CarvingChoice(child, rarity(childBiome)));
|
||||
for (String childId : parent.children()) {
|
||||
if (childId == null || childId.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ResolvedCarvingEntry child = entryIndex.get(childId.trim());
|
||||
if (child == null || !child.enabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IrisBiome childBiome = resolveEntryBiome(engine, child, state);
|
||||
if (childBiome == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
options.add(new CarvingChoice(child, rarity(childBiome)));
|
||||
}
|
||||
|
||||
options.add(new CarvingChoice(parent, rarity(parentBiome)));
|
||||
@@ -260,14 +260,6 @@ public final class IrisDimensionCarvingResolver {
|
||||
return Math.min(depth, MAX_CHILD_DEPTH);
|
||||
}
|
||||
|
||||
private static Map<String, IrisDimensionCarvingEntry> resolveEntryIndex(Engine engine, State state) {
|
||||
if (state.entryIndex == null) {
|
||||
state.entryIndex = engine.getDimension().getCarvingEntryIndex();
|
||||
}
|
||||
|
||||
return state.entryIndex;
|
||||
}
|
||||
|
||||
private static long resolveChildSeed(Engine engine, State state) {
|
||||
if (state.childSeed == null) {
|
||||
state.childSeed = engine.getSeedManager().getCarve() ^ CHILD_SEED_SALT;
|
||||
@@ -288,13 +280,13 @@ public final class IrisDimensionCarvingResolver {
|
||||
}
|
||||
|
||||
public static final class State {
|
||||
private final Map<Integer, IrisDimensionCarvingEntry> rootEntriesByWorldY = new HashMap<>();
|
||||
private final Map<IrisDimensionCarvingEntry, ParentSelectionPlan> selectionPlans = new IdentityHashMap<>();
|
||||
private final Map<IrisDimensionCarvingEntry, IrisBiome> biomeCache = new IdentityHashMap<>();
|
||||
private final Map<Integer, ResolvedCarvingEntry> rootEntriesByWorldY = new HashMap<>();
|
||||
private final Map<ResolvedCarvingEntry, ParentSelectionPlan> selectionPlans = new IdentityHashMap<>();
|
||||
private final Map<ResolvedCarvingEntry, IrisBiome> biomeCache = new IdentityHashMap<>();
|
||||
private WeakReference<Engine> engineIdentity;
|
||||
private WeakReference<IrisDimension> dimensionIdentity;
|
||||
private WeakReference<IrisData> dataIdentity;
|
||||
private Map<String, IrisDimensionCarvingEntry> entryIndex;
|
||||
private CarvingBands bands;
|
||||
private Long childSeed;
|
||||
|
||||
private void bind(Engine engine) {
|
||||
@@ -308,10 +300,10 @@ public final class IrisDimensionCarvingResolver {
|
||||
engineIdentity = new WeakReference<>(engine);
|
||||
dimensionIdentity = new WeakReference<>(dimension);
|
||||
dataIdentity = new WeakReference<>(data);
|
||||
bands = CarvingBands.of(engine);
|
||||
rootEntriesByWorldY.clear();
|
||||
selectionPlans.clear();
|
||||
biomeCache.clear();
|
||||
entryIndex = null;
|
||||
childSeed = null;
|
||||
}
|
||||
|
||||
@@ -359,10 +351,10 @@ public final class IrisDimensionCarvingResolver {
|
||||
}
|
||||
|
||||
private static final class CarvingChoice implements IRare {
|
||||
private final IrisDimensionCarvingEntry entry;
|
||||
private final ResolvedCarvingEntry entry;
|
||||
private final int rarity;
|
||||
|
||||
private CarvingChoice(IrisDimensionCarvingEntry entry, int rarity) {
|
||||
private CarvingChoice(ResolvedCarvingEntry entry, int rarity) {
|
||||
this.entry = entry;
|
||||
this.rarity = rarity;
|
||||
}
|
||||
@@ -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.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
|
||||
/** The cave profiles dimensions, regions and biomes declare ({@code caveProfile}). */
|
||||
public final class CaveProfiles {
|
||||
private CaveProfiles() {
|
||||
}
|
||||
|
||||
/** The profile {@code owner}, a dimension, region or biome, declares; null when it declares none, which is as good as one that is not enabled. */
|
||||
public static CaveProfile declaredBy(IrisRegistrant owner) {
|
||||
return owner.getModuleSettings().find(CaveProfile.class).orElse(null);
|
||||
}
|
||||
}
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
package art.arcane.iris.engine.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.DependsOn;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Snippet("dimension-carving-entry")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Dimension-level cave biome override with absolute world Y bounds.")
|
||||
@Data
|
||||
public class IrisDimensionCarvingEntry {
|
||||
private final transient AtomicCache<IrisBiome> realBiome = new AtomicCache<>(true);
|
||||
private final transient Map<Long, CNG> childGenerators = new ConcurrentHashMap<>();
|
||||
|
||||
@Desc("Stable id for this carving entry")
|
||||
private String id = "";
|
||||
|
||||
@Desc("Enable or disable this carving entry")
|
||||
private boolean enabled = true;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Cave biome to apply when world Y falls within worldYRange")
|
||||
private String biome = "";
|
||||
|
||||
@Desc("Absolute world Y bounds where this carving entry applies")
|
||||
private IrisRange worldYRange = new IrisRange(-64, 320);
|
||||
|
||||
@DependsOn({"children"})
|
||||
@Desc("If this carving entry has child carving entries, this controls how small those child carving patches are.")
|
||||
private double childShrinkFactor = 1.5;
|
||||
|
||||
@DependsOn({"children"})
|
||||
@Desc("If this carving entry has child carving entries, this controls the shape pattern used to pick them.")
|
||||
private IrisGeneratorStyle childStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Child carving entry ids. Child ids can point back to parent ids to create cycles; recursion is bounded by childRecursionDepth.")
|
||||
private KList<String> children = new KList<>();
|
||||
|
||||
@Desc("Maximum recursion depth when resolving child carving entries from this entry.")
|
||||
private int childRecursionDepth = 3;
|
||||
|
||||
public IrisBiome getRealBiome(IrisData data) {
|
||||
return realBiome.aquire(() -> {
|
||||
String biomeKey = getBiome();
|
||||
if (biomeKey == null || biomeKey.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data.getBiomeLoader().load(biomeKey.trim());
|
||||
});
|
||||
}
|
||||
|
||||
public CNG getChildrenGenerator(long seed, IrisData data) {
|
||||
String entryId = getId();
|
||||
long idHash = entryId == null ? 0L : entryId.trim().hashCode();
|
||||
long generatorSeed = seed ^ (idHash << 32) ^ 2137L;
|
||||
return childGenerators.computeIfAbsent(generatorSeed, key -> {
|
||||
double scale = Math.max(0.0001D, getChildShrinkFactor());
|
||||
RNG random = new RNG(key);
|
||||
return getChildStyle().create(random.nextParallelRNG(2137), data).bake().scale(scale).bake();
|
||||
});
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingEntry;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisValues;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Range;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* One {@link CarvingEntry} made ready for one world: the biome it names, loaded from the pack when first asked for, and the
|
||||
* noise that splits it into child entries, built once per seed. What the entry describes stays in the settings.
|
||||
*/
|
||||
public final class ResolvedCarvingEntry {
|
||||
private static final long CHILD_GENERATOR_SALT = 2137L;
|
||||
private static final int CHILD_GENERATOR_SIGNATURE = 2137;
|
||||
private static final double MIN_CHILD_SCALE = 0.0001D;
|
||||
|
||||
private final CarvingEntry settings;
|
||||
private final IrisGeneratorStyle childStyle;
|
||||
private final AtomicCache<IrisBiome> realBiome = new AtomicCache<>(true);
|
||||
private final Map<Long, CNG> childGenerators = new ConcurrentHashMap<>();
|
||||
|
||||
ResolvedCarvingEntry(CarvingEntry settings) {
|
||||
this.settings = settings;
|
||||
this.childStyle = IrisValues.generatorStyle(settings.childStyle());
|
||||
}
|
||||
|
||||
public String id() {
|
||||
return settings.id();
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return settings.enabled();
|
||||
}
|
||||
|
||||
/** The biome key the entry names, as the pack wrote it. */
|
||||
public String biomeKey() {
|
||||
return settings.biome();
|
||||
}
|
||||
|
||||
public Range worldYRange() {
|
||||
return settings.worldYRange();
|
||||
}
|
||||
|
||||
public List<String> children() {
|
||||
return settings.children();
|
||||
}
|
||||
|
||||
public int childRecursionDepth() {
|
||||
return settings.childRecursionDepth();
|
||||
}
|
||||
|
||||
/** The pack biome the entry names; null when it names none or the pack has no such biome. */
|
||||
public IrisBiome realBiome(IrisData data) {
|
||||
return realBiome.aquire(() -> {
|
||||
String biomeKey = settings.biome();
|
||||
if (biomeKey.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data.getBiomeLoader().load(biomeKey.trim());
|
||||
});
|
||||
}
|
||||
|
||||
/** The noise that picks between the entry and its children, seeded by {@code seed} and the entry's id. */
|
||||
public CNG childrenGenerator(long seed, IrisData data) {
|
||||
long idHash = settings.id().trim().hashCode();
|
||||
long generatorSeed = seed ^ (idHash << 32) ^ CHILD_GENERATOR_SALT;
|
||||
return childGenerators.computeIfAbsent(generatorSeed, key -> {
|
||||
double scale = Math.max(MIN_CHILD_SCALE, settings.childShrinkFactor());
|
||||
RNG random = new RNG(key);
|
||||
return childStyle.create(random.nextParallelRNG(CHILD_GENERATOR_SIGNATURE), data).bake().scale(scale).bake();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.terrain.deposit;
|
||||
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* Ore generation for {@link IrisBiome}. IrisBiome is Gson deserialized from pack JSON, so its
|
||||
* fields stay put and only the behavior lives here. Note that {@code IrisBiome.setOres(KList)}
|
||||
* stays on IrisBiome: it is a hand written Lombok setter override that resets these caches.
|
||||
*/
|
||||
public final class IrisBiomeOres {
|
||||
private IrisBiomeOres() {
|
||||
}
|
||||
|
||||
public static PlatformBlockState generateOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
KList<IrisOreGenerator> localOres = surface ? getSurfaceOres(biome) : getUndergroundOres(biome);
|
||||
return generateOres(localOres, x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public static PlatformBlockState generateSurfaceOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getSurfaceOres(biome), x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public static PlatformBlockState generateUndergroundOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getUndergroundOres(biome), x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public static boolean hasSurfaceOres(IrisBiome biome) {
|
||||
return !getSurfaceOres(biome).isEmpty();
|
||||
}
|
||||
|
||||
public static boolean hasUndergroundOres(IrisBiome biome) {
|
||||
return !getUndergroundOres(biome).isEmpty();
|
||||
}
|
||||
|
||||
public static KList<IrisOreGenerator> getSurfaceOreGenerators(IrisBiome biome) {
|
||||
return getOres(biome, true);
|
||||
}
|
||||
|
||||
public static KList<IrisOreGenerator> getUndergroundOreGenerators(IrisBiome biome) {
|
||||
return getOres(biome, false);
|
||||
}
|
||||
|
||||
public static IrisOreGeneratorBounds getSurfaceOreGeneratorBounds(IrisBiome biome) {
|
||||
// getIfPresent fast path: aquire allocates a capturing lambda even on a hit, and this
|
||||
// runs per column on the terrain hot path.
|
||||
IrisOreGeneratorBounds cached = biome.getSurfaceOreBoundsCache().getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
return biome.getSurfaceOreBoundsCache().aquire(() -> IrisOreGeneratorBounds.of(getSurfaceOres(biome)));
|
||||
}
|
||||
|
||||
public static IrisOreGeneratorBounds getUndergroundOreGeneratorBounds(IrisBiome biome) {
|
||||
IrisOreGeneratorBounds cached = biome.getUndergroundOreBoundsCache().getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
return biome.getUndergroundOreBoundsCache().aquire(() -> IrisOreGeneratorBounds.of(getUndergroundOres(biome)));
|
||||
}
|
||||
|
||||
private static KList<IrisOreGenerator> getSurfaceOres(IrisBiome biome) {
|
||||
return getOres(biome, true);
|
||||
}
|
||||
|
||||
private static KList<IrisOreGenerator> getUndergroundOres(IrisBiome biome) {
|
||||
return getOres(biome, false);
|
||||
}
|
||||
|
||||
private static KList<IrisOreGenerator> getOres(IrisBiome biome, boolean surface) {
|
||||
AtomicCache<KList<IrisOreGenerator>> oreCache = surface ? biome.getSurfaceOreCache() : biome.getUndergroundOreCache();
|
||||
KList<IrisOreGenerator> cached = oreCache.getIfPresent();
|
||||
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return oreCache.aquire(() -> {
|
||||
KList<IrisOreGenerator> filtered = new KList<>();
|
||||
KList<IrisOreGenerator> localOres = biome.getOres();
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
if (oreGenerator.isGenerateSurface() == surface) {
|
||||
filtered.add(oreGenerator);
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
});
|
||||
}
|
||||
|
||||
private static PlatformBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, IrisData data) {
|
||||
if (localOres.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.terrain.deposit;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("deposit-variant")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Remaps ore block ids to alternate block ids within a vertical band. Ores declared at dimension, region, and biome scope can be rewritten at placement time (for example, iron_ore -> deepslate_iron_ore inside a deep carving band, or yourmod:iron -> yourmod:moon_iron inside a lunar biome).")
|
||||
@Data
|
||||
public class IrisDepositVariant {
|
||||
private final transient AtomicCache<KMap<String, PlatformBlockState>> resolved = new AtomicCache<>();
|
||||
|
||||
@Required
|
||||
@MinNumber(-2048)
|
||||
@MaxNumber(8192)
|
||||
@Desc("Inclusive minimum world Y this variant applies at.")
|
||||
private int minHeight = 0;
|
||||
|
||||
@Required
|
||||
@MinNumber(-2048)
|
||||
@MaxNumber(8192)
|
||||
@Desc("Inclusive maximum world Y this variant applies at.")
|
||||
private int maxHeight = 0;
|
||||
|
||||
@Required
|
||||
@Desc("Source block id (for example `minecraft:iron_ore`) -> replacement block id (for example `minecraft:deepslate_iron_ore`). Any block id the data loader resolves is accepted, including external/mod blocks. Source match is by material only, so block properties on the source key are ignored.")
|
||||
private KMap<String, String> remap = new KMap<>();
|
||||
|
||||
public PlatformBlockState remapOrNull(PlatformBlockState ore, IrisData rdata) {
|
||||
if (ore == null || remap == null || remap.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
KMap<String, PlatformBlockState> map = resolved.aquire(() -> buildResolved(rdata));
|
||||
return map.get(IrisProceduralBlocks.materialKey(ore));
|
||||
}
|
||||
|
||||
private KMap<String, PlatformBlockState> buildResolved(IrisData rdata) {
|
||||
KMap<String, PlatformBlockState> out = new KMap<>();
|
||||
|
||||
for (java.util.Map.Entry<String, String> entry : remap.entrySet()) {
|
||||
PlatformBlockState source = B.getStateOrNull(entry.getKey(), false);
|
||||
PlatformBlockState target = B.getStateOrNull(entry.getValue(), true);
|
||||
|
||||
if (source == null || target == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
out.put(IrisProceduralBlocks.materialKey(source), target);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.terrain.deposit;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Scatters single ore blocks through terrain by sampling a noise field at every block in a vertical band. Defined on dimensions, regions, or biomes; the most specific level wins.")
|
||||
@Data
|
||||
public class IrisOreGenerator {
|
||||
@Desc("The ore blocks to place. An empty palette generates nothing, so this must be set for the generator to have any effect.")
|
||||
private IrisMaterialPalette palette = new IrisMaterialPalette().qclear();
|
||||
@Desc("The noise style sampled per block to decide where ore appears. STATIC gives independent random speckle; smoother styles give veiny clusters.")
|
||||
private IrisGeneratorStyle chanceStyle = new IrisGeneratorStyle(NoiseStyle.STATIC);
|
||||
@Desc("When true this generator also replaces surface-layer blocks (it runs before layers and fluid); when false it only replaces underground rock.")
|
||||
private boolean generateSurface = false;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Noise cutoff: a block becomes ore when the sampled noise is at or below this value, so higher means more ore. 0 disables, 1 replaces everything in range.")
|
||||
private double threshold = 0.5;
|
||||
@Desc("Vertical band (min, max) this ore can generate in, in engine-local Y where 0 is the bottom of the dimension, not world Y.")
|
||||
private IrisRange range = new IrisRange(30, 80);
|
||||
|
||||
private transient AtomicCache<CNG> chanceCache = new AtomicCache<>();
|
||||
|
||||
public void warm(RNG rng, IrisData data) {
|
||||
chanceCache.aquire(() -> chanceStyle.create(rng, data));
|
||||
palette.getLayerGenerator(rng, data);
|
||||
}
|
||||
|
||||
public PlatformBlockState generate(int x, int y, int z, RNG rng, IrisData data) {
|
||||
if (!range.contains(y)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (palette.getPalette().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CNG chance = chanceCache.aquire(() -> chanceStyle.create(rng, data));
|
||||
|
||||
if (chance.noise(x, y, z) > threshold) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return palette.get(rng, x, y, z, data);
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package art.arcane.iris.engine.object.terrain.deposit;
|
||||
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
public final class IrisOreGeneratorBounds {
|
||||
public static final IrisOreGeneratorBounds EMPTY = new IrisOreGeneratorBounds(false, 0D, 0D);
|
||||
|
||||
private final boolean hasOres;
|
||||
private final double min;
|
||||
private final double max;
|
||||
|
||||
private IrisOreGeneratorBounds(boolean hasOres, double min, double max) {
|
||||
this.hasOres = hasOres;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public static IrisOreGeneratorBounds of(KList<IrisOreGenerator> ores) {
|
||||
if (ores == null || ores.isEmpty()) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
double min = Double.POSITIVE_INFINITY;
|
||||
double max = Double.NEGATIVE_INFINITY;
|
||||
int oreCount = ores.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = ores.get(oreIndex);
|
||||
IrisRange range = oreGenerator.getRange();
|
||||
min = Math.min(min, range.getMin());
|
||||
max = Math.max(max, range.getMax());
|
||||
}
|
||||
|
||||
return new IrisOreGeneratorBounds(true, min, max);
|
||||
}
|
||||
|
||||
public boolean hasOres() {
|
||||
return hasOres;
|
||||
}
|
||||
|
||||
public boolean contains(int y) {
|
||||
return hasOres && y >= min && y <= max;
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,11 @@
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildSettings;
|
||||
import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -46,6 +49,16 @@ public final class FloatingChildren {
|
||||
return engine.getGeneration().state(FloatingChildren.class, FloatingChildren::new);
|
||||
}
|
||||
|
||||
/** The floating children {@code biome} declares, in the order it lists them; none when it declares none. */
|
||||
public static List<FloatingChildBiome> declaredBy(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(FloatingChildSettings.class).map(FloatingChildSettings::children).orElse(List.of());
|
||||
}
|
||||
|
||||
/** Whether {@code biome} samples every floating child on its own and unions their islands instead of picking one per column. */
|
||||
public static boolean merges(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(MergeFloatingChildrenSettings.class).map(MergeFloatingChildrenSettings::merge).orElse(false);
|
||||
}
|
||||
|
||||
public ResolvedFloatingChild of(FloatingChildBiome settings) {
|
||||
return resolved.computeIfAbsent(settings, ResolvedFloatingChild::new);
|
||||
}
|
||||
|
||||
+3
-3
@@ -196,8 +196,8 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
|
||||
public static FloatingIslandSample sample(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler) {
|
||||
List<FloatingChildBiome> settings = parent.getFloatingChildBiomes();
|
||||
if (settings == null || settings.isEmpty()) {
|
||||
List<FloatingChildBiome> settings = FloatingChildren.declaredBy(parent);
|
||||
if (settings.isEmpty()) {
|
||||
return reject(REJECT_NO_ENTRIES);
|
||||
}
|
||||
KList<ResolvedFloatingChild> entries = new KList<>(FloatingChildren.of(data).of(settings));
|
||||
@@ -208,7 +208,7 @@ public final class FloatingIslandSample {
|
||||
int boundaryFieldWidth = maximumEdgeFieldWidth(entries, baseSeed, data, parent);
|
||||
int parentBoundaryDistance = boundarySampler.edgeDistance(parent, wx, wz, boundaryFieldWidth);
|
||||
|
||||
if (parent.isMergeFloatingChildBiomes()) {
|
||||
if (FloatingChildren.merges(parent)) {
|
||||
return sampleMerged(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler,
|
||||
parentBoundaryDistance, boundaryFieldWidth);
|
||||
}
|
||||
|
||||
+11
-11
@@ -18,20 +18,22 @@
|
||||
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisValues;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CaveProfiles;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectScale;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
|
||||
import art.arcane.iris.engine.object.terrain.carving.ResolvedCarvingEntry;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingBands;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingResolver;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfileSampler;
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -137,11 +139,12 @@ public final class ResolvedFloatingChild implements IRare {
|
||||
|
||||
return carvingProfileSamplerCache.aquire(() -> {
|
||||
IrisBiome resolved = resolveCarvingBiome(settings.carving(), engine, data);
|
||||
if (resolved == null || resolved.getCaveProfile() == null || !resolved.getCaveProfile().enabled()) {
|
||||
CaveProfile profile = resolved == null ? null : CaveProfiles.declaredBy(resolved);
|
||||
if (profile == null || !profile.enabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new IrisCaveProfileSampler(engine, resolved.getCaveProfile());
|
||||
return new IrisCaveProfileSampler(engine, profile);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -155,12 +158,9 @@ public final class ResolvedFloatingChild implements IRare {
|
||||
return null;
|
||||
}
|
||||
|
||||
IrisDimension dimension = engine.getDimension();
|
||||
if (dimension != null && dimension.getCarvingEntryIndex() != null) {
|
||||
IrisDimensionCarvingEntry entry = dimension.getCarvingEntryIndex().get(carving);
|
||||
if (entry != null) {
|
||||
return IrisDimensionCarvingResolver.resolveEntryBiome(engine, entry);
|
||||
}
|
||||
ResolvedCarvingEntry entry = CarvingBands.of(engine).index().get(carving);
|
||||
if (entry != null) {
|
||||
return CarvingResolver.resolveEntryBiome(engine, entry);
|
||||
}
|
||||
|
||||
if (data.getBiomeLoader() == null) {
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.value;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Snippet("duration")
|
||||
@Data
|
||||
@Desc("Represents a combined duration. Fill each property to add time into a single duration")
|
||||
public class IrisDuration {
|
||||
@Desc("Milliseconds (1000ms = 1 second)")
|
||||
private int milliseconds = 0;
|
||||
|
||||
@Desc("Minecraft Ticks (20 minecraft ticks = 1 second)")
|
||||
private int minecraftTicks = 0;
|
||||
|
||||
@Desc("Seconds (60 seconds = 1 minute)")
|
||||
private int seconds = 0;
|
||||
|
||||
@Desc("Minutes (60 minutes = 1 hour)")
|
||||
private int minutes = 0;
|
||||
|
||||
@Desc("Minecraft Hours (about 50 real seconds)")
|
||||
private int minecraftHours = 0;
|
||||
|
||||
@Desc("Hours (24 hours = 1 day)")
|
||||
private int hours = 0;
|
||||
|
||||
@Desc("Minecraft Days (1 minecraft day = 20 real minutes)")
|
||||
private int minecraftDays = 0;
|
||||
|
||||
@Desc("Minecraft Weeks (7 minecraft days = 2 real hours and 20 real minutes)")
|
||||
private int minecraftWeeks = 0;
|
||||
|
||||
@Desc("Minecraft Lunar Cycles (8 minecraft days = 2 real hours and 40 real minutes)")
|
||||
private int minecraftLunarCycles = 0;
|
||||
|
||||
@Desc("REAL (not minecraft) Days")
|
||||
private int days = 0;
|
||||
|
||||
public String toString() {
|
||||
return Form.duration((double) toMilliseconds(), 2);
|
||||
}
|
||||
|
||||
public long toMilliseconds() {
|
||||
return getMilliseconds()
|
||||
+ TimeUnit.SECONDS.toMillis(getSeconds())
|
||||
+ TimeUnit.MINUTES.toMillis(getMinutes())
|
||||
+ TimeUnit.HOURS.toMillis(getHours())
|
||||
+ TimeUnit.DAYS.toMillis(getDays())
|
||||
+ (getMinecraftTicks() * 50L)
|
||||
+ (getMinecraftHours() * 50000L)
|
||||
+ (getMinecraftDays() * 1_200_000L)
|
||||
+ (getMinecraftWeeks() * 8_400_000L)
|
||||
+ (getMinecraftLunarCycles() * 9_600_000L);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.value;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Snippet("rate")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Desc("Represents a count of something per time duration")
|
||||
public class IrisRate {
|
||||
@Desc("The amount of things. Leave 0 for infinite (meaning always spawn whenever)")
|
||||
private int amount = 0;
|
||||
|
||||
@Desc("The time interval. Leave blank for infinite 0 (meaning always spawn all the time)")
|
||||
private IrisDuration per = new IrisDuration();
|
||||
|
||||
public String toString() {
|
||||
return Form.f(amount) + "/" + per;
|
||||
}
|
||||
|
||||
public long getInterval() {
|
||||
long t = per.toMilliseconds() / (amount == 0 ? 1 : amount);
|
||||
return Math.abs(t <= 0 ? 1 : t);
|
||||
}
|
||||
|
||||
public ChronoLatch toChronoLatch() {
|
||||
return new ChronoLatch(getInterval());
|
||||
}
|
||||
|
||||
public boolean isInfinite() {
|
||||
return per.toMilliseconds() == 0;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.world;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import lombok.Data;
|
||||
|
||||
@Snippet("time-block")
|
||||
@Data
|
||||
@Desc("Represents a time of day (24h time, not 12h am/pm). Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
public class IrisTimeBlock {
|
||||
@Desc("The beginning hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
private double startHour = 0;
|
||||
|
||||
@Desc("The ending hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
private double endHour = 0;
|
||||
|
||||
public boolean isWithin(PlatformWorld world) {
|
||||
return isWithin(((world.getTime() / 1000D) + 6) % 24);
|
||||
}
|
||||
|
||||
public boolean isWithin(double hour) {
|
||||
if (startHour == endHour) {
|
||||
return endHour != -1;
|
||||
}
|
||||
|
||||
if (startHour > endHour) {
|
||||
return hour >= startHour || hour <= endHour;
|
||||
}
|
||||
|
||||
return hour >= startHour && hour <= endHour;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.object.world;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
|
||||
@Desc("Represents a weather type")
|
||||
public enum IrisWeather {
|
||||
@Desc("Represents when weather is not causing downfall")
|
||||
NONE,
|
||||
|
||||
@Desc("Represents rain or snow")
|
||||
DOWNFALL,
|
||||
|
||||
@Desc("Represents rain or snow with thunder")
|
||||
DOWNFALL_WITH_THUNDER,
|
||||
|
||||
@Desc("Any weather")
|
||||
ANY;
|
||||
|
||||
public boolean is(PlatformWorld world) {
|
||||
return switch (this) {
|
||||
case NONE -> !world.isStorming() && !world.isThundering();
|
||||
case DOWNFALL -> world.isStorming();
|
||||
case DOWNFALL_WITH_THUNDER -> world.isStorming() && world.isThundering();
|
||||
case ANY -> true;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -18,23 +18,11 @@
|
||||
|
||||
package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
||||
import art.arcane.iris.engine.object.loot.IrisBlockDrops;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootReference;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.terrain.IrisBiomeLayerGenerator;
|
||||
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisBiomeOres;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds;
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
@@ -78,7 +66,7 @@ import java.util.Objects;
|
||||
* Represents a biome in a pack. This type is Gson deserialized straight out of user pack JSON, so
|
||||
* the field block and the transient {@link AtomicCache} block below are load bearing and must not
|
||||
* move. Behavior lives in the same-package companions:
|
||||
* {@link IrisBiomeLayerGenerator}, {@link IrisBiomeDerivatives}, {@link IrisBiomeOres},
|
||||
* {@link IrisBiomeDerivatives},
|
||||
* {@link IrisBiomeColorRenderer} and {@link IrisBiomeGenLinks}.
|
||||
*/
|
||||
@Accessors(chain = true)
|
||||
@@ -106,16 +94,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private transient volatile SeededBiomeGenerator recentBiomeGenerator;
|
||||
private final transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
|
||||
private final transient AtomicCache<Integer> maxWithObjectHeight = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisBiome> realCarveBiome = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisBiome>> realChildren = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<CNG>> layerHeightGenerators = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<CNG>> layerSeaHeightGenerators = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> surfaceOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> undergroundOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisOreGeneratorBounds> surfaceOreBoundsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisOreGeneratorBounds> undergroundOreBoundsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<Biome> derivativeResolved = new AtomicCache<>();
|
||||
private final transient AtomicCache<Biome> vanillaDerivativeResolved = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<Biome>> biomeScatterResolved = new AtomicCache<>();
|
||||
@@ -127,27 +106,9 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
@ArrayType(min = 1, type = IrisBiomeCustom.class)
|
||||
@Desc("If the biome type custom is defined, specify this")
|
||||
private KList<IrisBiomeCustom> customDerivitives;
|
||||
@Desc("Spawn Entities in this area over time. Iris will continually replenish these mobs just like vanilla does.")
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@RegistryListResource(IrisSpawner.class)
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
@ArrayType(min = 1, type = IrisEffect.class)
|
||||
@Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play around the player even if where the effect was played is no longer in the biome the player is in.")
|
||||
private KList<IrisEffect> effects = new KList<>();
|
||||
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})
|
||||
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
||||
private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style();
|
||||
@ArrayType(min = 1, type = IrisBlockDrops.class)
|
||||
@Desc("Define custom block drops for this biome")
|
||||
private KList<IrisBlockDrops> blockDrops = new KList<>();
|
||||
@Desc("Reference loot tables in this area")
|
||||
private IrisLootReference loot = new IrisLootReference();
|
||||
@Desc("Layers no longer descend from the surface block, they descend from the max possible height the biome can produce (constant) creating mesa like layers.")
|
||||
private boolean lockLayers = false;
|
||||
@Desc("The max layers to iterate below the surface for locked layer biomes (mesa).")
|
||||
private int lockLayersMax = 7;
|
||||
@Desc("Profile-driven 3D cave configuration")
|
||||
private CaveProfile caveProfile = new CaveProfile();
|
||||
@MinNumber(1)
|
||||
@MaxNumber(512)
|
||||
@Desc("The rarity of this biome (integer)")
|
||||
@@ -180,27 +141,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("List any biome names (file names without.json) here as children. Portions of this biome can sometimes morph into their children. Iris supports cyclic relationships such as A > B > A > B. Iris will stop checking 4 biomes down the tree.")
|
||||
private KList<String> children = new KList<>();
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Registers the referenced biome with this pack's reachable biome set. It is NOT applied as a substitute under carvings; cave biomes come from the region's caveBiomes list.")
|
||||
private String carvingBiome = "";
|
||||
@MinNumber(0)
|
||||
@MaxNumber(256)
|
||||
@Desc("Minimum depth below terrain surface required before this cave biome can be selected.")
|
||||
private int caveMinDepthBelowSurface = 0;
|
||||
@Desc("The default slab if iris decides to place a slab in this biome. Default is no slab.")
|
||||
private IrisBiomePaletteLayer slab = new IrisBiomePaletteLayer().zero();
|
||||
@Desc("The default wall if iris decides to place a wall higher than 2 blocks (steep hills or possibly cliffs)")
|
||||
private IrisBiomePaletteLayer wall = new IrisBiomePaletteLayer().zero();
|
||||
@Required
|
||||
@ArrayType(type = IrisBiomePaletteLayer.class)
|
||||
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
|
||||
private KList<IrisBiomePaletteLayer> layers = new KList<IrisBiomePaletteLayer>().qadd(new IrisBiomePaletteLayer());
|
||||
@ArrayType(type = IrisBiomePaletteLayer.class)
|
||||
@Desc("Layers of materials placed on cave ceilings in this biome, indexed upward from the ceiling surface. Must not have more entries than layers, whose height generators it reuses. Omitting this leaves cave ceilings unchanged.")
|
||||
private KList<IrisBiomePaletteLayer> caveCeilingLayers = new KList<>();
|
||||
@ArrayType(type = IrisBiomePaletteLayer.class)
|
||||
@Desc("Layers of materials filling the water column of sea biomes, indexed downward from the water surface. Anything below the last layer is filled with the dimension fluid palette, not stone.")
|
||||
private KList<IrisBiomePaletteLayer> seaLayers = new KList<>();
|
||||
@ArrayType(min = 1, type = IrisObjectPlacement.class)
|
||||
@Desc("Objects define what schematics (iob files) iris will place in this biome")
|
||||
private KList<IrisObjectPlacement> objects = new KList<>();
|
||||
@@ -209,52 +149,13 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
@ArrayType(min = 1, type = IrisStructurePlacement.class)
|
||||
@Desc("Structures define jigsaw or vanilla/datapack structures iris will place in this biome")
|
||||
private KList<IrisStructurePlacement> structures = new KList<>();
|
||||
@ArrayType(min = 1, type = FloatingChildBiome.class)
|
||||
@Desc("Floating child biomes that procedurally generate above this biome's terrain. Each entry references a target biome whose layers, decorators, and objects drive the floating island's visual design, while the config here drives size, shape, altitude, rarity, and water level. Multiple entries are supported and selected by rarity per column unless mergeFloatingChildBiomes is enabled.")
|
||||
private KList<FloatingChildBiome> floatingChildBiomes = new KList<>();
|
||||
@Desc("When true, every floating child entry is sampled independently and their solid masks are unioned, so multiple floating islands can stack, overlap, and collide instead of the picker choosing only one child per column.")
|
||||
private boolean mergeFloatingChildBiomes = false;
|
||||
@ArrayType(min = 1, type = IrisBiomeGeneratorLink.class)
|
||||
@Desc("Generators for this biome. Multiple generators with different interpolation sizes will mix with other biomes how you would expect. This defines your biome height relative to the fluid height. Use negative for oceans.")
|
||||
private KList<IrisBiomeGeneratorLink> generators = new KList<IrisBiomeGeneratorLink>().qadd(new IrisBiomeGeneratorLink());
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Multiplier applied to the frequency of every ore deposit whose center is inside this biome. A value of 0.4 keeps 40% of ore veins while leaving non-ore deposits unchanged.")
|
||||
private double oreDepositFrequencyMultiplier = 1D;
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(16)
|
||||
@Desc("Multiplier applied to the block count of every ore deposit whose center is inside this biome. Non-ore deposits are unchanged.")
|
||||
private double oreDepositSizeMultiplier = 1D;
|
||||
@ArrayType(min = 1, type = IrisDepositVariant.class)
|
||||
@Desc("Deposit ore remap rules scoped to this biome. Each entry declares a vertical band and a source->replacement block id map. Applied before regional and dimension rules; first matching biome rule wins.")
|
||||
private KList<IrisDepositVariant> depositVariants = new KList<>();
|
||||
private transient volatile InferredType inferredType;
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient EnumMap<InferredType, IrisBiome> inferredVariants = new EnumMap<>(InferredType.class);
|
||||
@Desc("Collection of ores to be generated")
|
||||
@ArrayType(type = IrisOreGenerator.class, min = 1)
|
||||
private KList<IrisOreGenerator> ores = new KList<>();
|
||||
|
||||
public PlatformBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
return IrisBiomeOres.generateOres(this, x, y, z, rng, data, surface);
|
||||
}
|
||||
|
||||
public PlatformBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return IrisBiomeOres.generateSurfaceOres(this, x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public PlatformBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return IrisBiomeOres.generateUndergroundOres(this, x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public boolean hasSurfaceOres() {
|
||||
return IrisBiomeOres.hasSurfaceOres(this);
|
||||
}
|
||||
|
||||
public boolean hasUndergroundOres() {
|
||||
return IrisBiomeOres.hasUndergroundOres(this);
|
||||
}
|
||||
|
||||
public synchronized IrisBiome setInferredType(InferredType inferredType) {
|
||||
this.inferredType = inferredType;
|
||||
@@ -292,39 +193,12 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
variant.setLoader(data);
|
||||
variant.setLoadKey(getLoadKey());
|
||||
variant.setLoadFile(getLoadFile());
|
||||
variant.setModuleSettings(getModuleSettings());
|
||||
variant.inferredType = type;
|
||||
inferredVariants.put(type, variant);
|
||||
return variant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hand written override of the Lombok setter. It must stay here because it invalidates the ore
|
||||
* caches that {@link IrisBiomeOres} reads.
|
||||
*/
|
||||
public void setOres(KList<IrisOreGenerator> ores) {
|
||||
this.ores = ores == null ? new KList<>() : ores;
|
||||
surfaceOreCache.reset();
|
||||
undergroundOreCache.reset();
|
||||
surfaceOreBoundsCache.reset();
|
||||
undergroundOreBoundsCache.reset();
|
||||
}
|
||||
|
||||
public KList<IrisOreGenerator> getSurfaceOreGenerators() {
|
||||
return IrisBiomeOres.getSurfaceOreGenerators(this);
|
||||
}
|
||||
|
||||
public KList<IrisOreGenerator> getUndergroundOreGenerators() {
|
||||
return IrisBiomeOres.getUndergroundOreGenerators(this);
|
||||
}
|
||||
|
||||
public IrisOreGeneratorBounds getSurfaceOreGeneratorBounds() {
|
||||
return IrisBiomeOres.getSurfaceOreGeneratorBounds(this);
|
||||
}
|
||||
|
||||
public IrisOreGeneratorBounds getUndergroundOreGeneratorBounds() {
|
||||
return IrisBiomeOres.getUndergroundOreGeneratorBounds(this);
|
||||
}
|
||||
|
||||
public Biome getDerivative() {
|
||||
Biome cached = derivativeResolved.getIfPresent();
|
||||
|
||||
@@ -390,19 +264,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
return IrisBiomeGenLinks.getGenLink(this, loadKey);
|
||||
}
|
||||
|
||||
public IrisBiome getRealCarvingBiome(IrisData data) {
|
||||
return realCarveBiome.aquire(() ->
|
||||
{
|
||||
IrisBiome biome = data.getBiomeLoader().load(getCarvingBiome());
|
||||
|
||||
if (biome == null) {
|
||||
biome = this;
|
||||
}
|
||||
|
||||
return biome;
|
||||
});
|
||||
}
|
||||
|
||||
public KList<IrisObjectPlacement> getSurfaceObjects() {
|
||||
return getSurfaceObjectsCache().aquire(() ->
|
||||
{
|
||||
@@ -483,46 +344,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137), getLoader()).bake().scale(scale).bake());
|
||||
}
|
||||
|
||||
public KList<PlatformBlockState> generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateLayers(this, dim, wx, wz, random, maxDepth, height, rdata, complex);
|
||||
}
|
||||
|
||||
public KList<PlatformBlockState> generateCeilingLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateCeilingLayers(this, dim, wx, wz, random, maxDepth, height, rdata, complex);
|
||||
}
|
||||
|
||||
public KList<PlatformBlockState> generateLockedLayers(double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateLockedLayers(this, wx, wz, random, maxDepthf, height, rdata, complex);
|
||||
}
|
||||
|
||||
public KList<PlatformBlockState> generateSeaLayers(double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
|
||||
return IrisBiomeLayerGenerator.generateSeaLayers(this, wx, wz, random, maxDepth, rdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note the arity split: {@code getMaxHeight()} is the Lombok getter for the height cache field,
|
||||
* {@code getMaxHeight(Engine)} is the resolved biome height.
|
||||
*/
|
||||
public int getMaxHeight(Engine engine) {
|
||||
return IrisBiomeLayerGenerator.getMaxHeight(this, engine);
|
||||
}
|
||||
|
||||
public int getMaxWithObjectHeight(IrisData data, Engine engine) {
|
||||
return IrisBiomeLayerGenerator.getMaxWithObjectHeight(this, data, engine);
|
||||
}
|
||||
|
||||
public KList<CNG> getLayerHeightGenerators(RNG rng, IrisData rdata) {
|
||||
return IrisBiomeLayerGenerator.getLayerHeightGenerators(this, rng, rdata);
|
||||
}
|
||||
|
||||
public KList<CNG> getLayerSeaHeightGenerators(RNG rng, IrisData data) {
|
||||
return IrisBiomeLayerGenerator.getLayerSeaHeightGenerators(this, rng, data);
|
||||
}
|
||||
|
||||
public PlatformBlockState getSurfaceBlock(int x, int z, RNG rng, IrisData idm) {
|
||||
return IrisBiomeLayerGenerator.getSurfaceBlock(this, x, z, rng, idm);
|
||||
}
|
||||
|
||||
public boolean isLand() {
|
||||
if (inferredType == null) {
|
||||
return true;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.render.RenderType;
|
||||
@@ -81,7 +82,10 @@ final class IrisBiomeColorRenderer {
|
||||
});
|
||||
}
|
||||
case LAYER_LOAD -> {
|
||||
return biome.getCacheColorLayerLoad().aquire(() -> Color.getHSBColor(0.625f, (float) (biome.getLayers().size() / engine.getMaxBiomeLayerDensity()), 1f));
|
||||
return biome.getCacheColorLayerLoad().aquire(() -> {
|
||||
BiomeLayers layers = BiomeLayers.of(engine);
|
||||
return Color.getHSBColor(0.625f, (float) (BiomeLayers.layersOf(biome).size() / layers.busiestLayerCount(engine)), 1f);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,26 +18,16 @@
|
||||
|
||||
package art.arcane.iris.engine.object.world.dimension;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.engine.object.decoration.IrisImportedFeatureControl;
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
||||
import art.arcane.iris.engine.object.image.IrisImageMap;
|
||||
import art.arcane.iris.engine.object.image.IrisImageMapApplication;
|
||||
import art.arcane.iris.engine.object.image.IrisImageMapBinding;
|
||||
import art.arcane.iris.engine.object.loot.IrisBlockDrops;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootReference;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSettings;
|
||||
import art.arcane.iris.engine.object.runtime.StudioMode;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.engine.object.world.IrisEnvironment;
|
||||
import art.arcane.iris.engine.object.world.IrisWorldBoundary;
|
||||
@@ -48,7 +38,6 @@ import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.core.IrisDatapackCompiler.DimensionHeight;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.core.nms.datapack.DataVersion;
|
||||
import art.arcane.iris.core.nms.datapack.IDataFixer;
|
||||
@@ -87,7 +76,6 @@ import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Locale;
|
||||
@@ -113,11 +101,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private final transient AtomicCache<Double> cosr = new AtomicCache<>();
|
||||
private final transient AtomicCache<Double> rad = new AtomicCache<>();
|
||||
private final transient AtomicCache<Boolean> featuresUsed = new AtomicCache<>();
|
||||
private final transient AtomicCache<Map<String, IrisDimensionCarvingEntry>> carvingEntryIndex = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> surfaceOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> undergroundOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisOreGeneratorBounds> surfaceOreBoundsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisOreGeneratorBounds> undergroundOreBoundsCache = new AtomicCache<>();
|
||||
@MinNumber(2)
|
||||
@Required
|
||||
@Desc("The human readable name of this dimension")
|
||||
@@ -142,18 +125,9 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private int debugCrossSectionsMod = 3;
|
||||
@Desc("Tree growth override settings")
|
||||
private IrisTreeSettings treeSettings = new IrisTreeSettings();
|
||||
@Desc("Spawn Entities in this dimension over time. Iris will continually replenish these mobs just like vanilla does.")
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@RegistryListResource(IrisSpawner.class)
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
@Desc("Reference loot tables in this area")
|
||||
private IrisLootReference loot = new IrisLootReference();
|
||||
@MinNumber(0)
|
||||
@Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).")
|
||||
private int version = 1;
|
||||
@ArrayType(min = 1, type = IrisBlockDrops.class)
|
||||
@Desc("Define custom block drops for this dimension")
|
||||
private KList<IrisBlockDrops> blockDrops = new KList<>();
|
||||
@Desc("Should bedrock be generated or not.")
|
||||
private boolean bedrock = true;
|
||||
@MinNumber(0)
|
||||
@@ -176,21 +150,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private boolean debugSmartBore = false;
|
||||
@Desc("Generate decorations or not")
|
||||
private boolean decorate = true;
|
||||
@Desc("When true, every ore block the generator would place (terrain ores, deposits, ores inside objects) is replaced with its base material such as stone, deepslate or netherrack, so drop-control plugins like HiddenOre can manage ore rewards themselves")
|
||||
private boolean hideOresForHiddenOre = false;
|
||||
@Desc("Use post processing or not")
|
||||
private boolean postProcessing = true;
|
||||
@Desc("Add slabs in post processing")
|
||||
private boolean postProcessingSlabs = true;
|
||||
@Desc("Add painted walls in post processing")
|
||||
private boolean postProcessingWalls = true;
|
||||
@Desc("Enable or disable all carving for this dimension")
|
||||
private boolean carvingEnabled = true;
|
||||
@ArrayType(type = IrisDimensionCarvingEntry.class, min = 1)
|
||||
@Desc("Dimension-level cave biome carving overrides with absolute world Y ranges")
|
||||
private KList<IrisDimensionCarvingEntry> carving = new KList<>();
|
||||
@Desc("Profile-driven 3D cave configuration")
|
||||
private CaveProfile caveProfile = new CaveProfile();
|
||||
@Desc("Refuse to place surface objects and trees over carved surface openings.")
|
||||
private boolean requireObjectSurfaceSupport = true;
|
||||
@MinNumber(0)
|
||||
@@ -275,19 +234,9 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private boolean useMantle = true;
|
||||
@Desc("Prevent Leaf decay as if placed in creative mode")
|
||||
private boolean preventLeafDecay = false;
|
||||
@ArrayType(min = 1, type = IrisDepositVariant.class)
|
||||
@Desc("Dimension-wide deposit ore remap rules. Each entry declares a vertical band and a source->replacement block id map. Applied after biome and region rules; first matching dimension rule wins.")
|
||||
private KList<IrisDepositVariant> depositVariants = new KList<>();
|
||||
@ArrayType(min = 1, type = IrisShapedGeneratorStyle.class)
|
||||
@Desc("Overlay additional noise on top of the interoplated terrain.")
|
||||
private KList<IrisShapedGeneratorStyle> overlayNoise = new KList<>();
|
||||
@Desc("The palette of blocks for 'stone'")
|
||||
private IrisMaterialPalette rockPalette = new IrisMaterialPalette().qclear().qadd("stone");
|
||||
@Desc("The dimension fluid block palette used for ocean columns and cave aquifers.")
|
||||
private IrisMaterialPalette fluidPalette = new IrisMaterialPalette().qclear().qadd("water");
|
||||
@Desc("Collection of ores to be generated")
|
||||
@ArrayType(type = IrisOreGenerator.class, min = 1)
|
||||
private KList<IrisOreGenerator> ores = new KList<>();
|
||||
@Desc("Dimension-wide Iris structure placements, independent of biome/region placements")
|
||||
@ArrayType(type = IrisStructurePlacement.class, min = 1)
|
||||
private KList<IrisStructurePlacement> structures = new KList<>();
|
||||
@@ -313,122 +262,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
return (int) getDimensionHeight().getMin();
|
||||
}
|
||||
|
||||
public Map<String, IrisDimensionCarvingEntry> getCarvingEntryIndex() {
|
||||
return carvingEntryIndex.aquire(() -> {
|
||||
Map<String, IrisDimensionCarvingEntry> index = new HashMap<>();
|
||||
KList<IrisDimensionCarvingEntry> entries = getCarving();
|
||||
if (entries == null || entries.isEmpty()) {
|
||||
return index;
|
||||
}
|
||||
|
||||
for (IrisDimensionCarvingEntry entry : entries) {
|
||||
if (entry == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryId = entry.getId();
|
||||
if (entryId == null || entryId.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
index.put(entryId.trim(), entry);
|
||||
}
|
||||
|
||||
return index;
|
||||
});
|
||||
}
|
||||
|
||||
public void setCarving(KList<IrisDimensionCarvingEntry> carving) {
|
||||
this.carving = carving == null ? new KList<>() : carving;
|
||||
carvingEntryIndex.reset();
|
||||
}
|
||||
|
||||
public PlatformBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
KList<IrisOreGenerator> localOres = surface ? getSurfaceOres() : getUndergroundOres();
|
||||
return generateOres(localOres, x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public PlatformBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getSurfaceOres(), x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public PlatformBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getUndergroundOres(), x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public boolean hasSurfaceOres() {
|
||||
return !getSurfaceOres().isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasUndergroundOres() {
|
||||
return !getUndergroundOres().isEmpty();
|
||||
}
|
||||
|
||||
private PlatformBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, IrisData data) {
|
||||
if (localOres.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setOres(KList<IrisOreGenerator> ores) {
|
||||
this.ores = ores == null ? new KList<>() : ores;
|
||||
surfaceOreCache.reset();
|
||||
undergroundOreCache.reset();
|
||||
surfaceOreBoundsCache.reset();
|
||||
undergroundOreBoundsCache.reset();
|
||||
}
|
||||
|
||||
public KList<IrisOreGenerator> getSurfaceOreGenerators() {
|
||||
return getOres(true);
|
||||
}
|
||||
|
||||
public KList<IrisOreGenerator> getUndergroundOreGenerators() {
|
||||
return getOres(false);
|
||||
}
|
||||
|
||||
public IrisOreGeneratorBounds getSurfaceOreGeneratorBounds() {
|
||||
return surfaceOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getSurfaceOres()));
|
||||
}
|
||||
|
||||
public IrisOreGeneratorBounds getUndergroundOreGeneratorBounds() {
|
||||
return undergroundOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getUndergroundOres()));
|
||||
}
|
||||
|
||||
private KList<IrisOreGenerator> getSurfaceOres() {
|
||||
return getOres(true);
|
||||
}
|
||||
|
||||
private KList<IrisOreGenerator> getUndergroundOres() {
|
||||
return getOres(false);
|
||||
}
|
||||
|
||||
private KList<IrisOreGenerator> getOres(boolean surface) {
|
||||
AtomicCache<KList<IrisOreGenerator>> oreCache = surface ? surfaceOreCache : undergroundOreCache;
|
||||
return oreCache.aquire(() -> {
|
||||
KList<IrisOreGenerator> filtered = new KList<>();
|
||||
KList<IrisOreGenerator> localOres = ores;
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
if (oreGenerator.isGenerateSurface() == surface) {
|
||||
filtered.add(oreGenerator);
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
});
|
||||
}
|
||||
|
||||
public int getFluidHeight() {
|
||||
return fluidHeight - (int) dimensionHeight.getMin();
|
||||
}
|
||||
@@ -550,17 +383,9 @@ public class IrisDimension extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
KList<IrisDimensionCarvingEntry> carvingEntries = getCarving();
|
||||
if (carvingEntries != null) {
|
||||
for (IrisDimensionCarvingEntry entry : carvingEntries) {
|
||||
if (entry != null && entry.isEnabled()) {
|
||||
addReachableBiomeKey(pending, entry.getBiome());
|
||||
}
|
||||
}
|
||||
}
|
||||
addReachableBiomeKeys(pending, getModuleSettings().usedBiomes(getModuleSettings()));
|
||||
|
||||
Set<String> visited = new HashSet<>();
|
||||
Map<String, IrisDimensionCarvingEntry> carvingEntryIndex = getCarvingEntryIndex();
|
||||
while (!pending.isEmpty()) {
|
||||
String biomeKey = pending.removeFirst();
|
||||
if (!visited.add(biomeKey)) {
|
||||
@@ -580,20 +405,8 @@ public class IrisDimension extends IrisRegistrant {
|
||||
visited.add(loadKey);
|
||||
biomes.put(loadKey, biome);
|
||||
addReachableBiomeKeys(pending, biome.getChildren());
|
||||
addReachableBiomeKey(pending, biome.getCarvingBiome());
|
||||
KList<FloatingChildBiome> floatingChildren = biome.getFloatingChildBiomes();
|
||||
if (floatingChildren == null) {
|
||||
continue;
|
||||
}
|
||||
for (FloatingChildBiome floatingChild : floatingChildren) {
|
||||
if (floatingChild != null) {
|
||||
addReachableBiomeKey(pending, floatingChild.biome());
|
||||
String carvingReference = floatingChild.carving();
|
||||
IrisDimensionCarvingEntry carvingEntry = carvingEntryIndex.get(carvingReference);
|
||||
addReachableBiomeKey(pending,
|
||||
carvingEntry == null ? carvingReference : carvingEntry.getBiome());
|
||||
}
|
||||
}
|
||||
addReachableBiomeKeys(pending, biome.getModuleSettings().treeBiomes());
|
||||
addReachableBiomeKeys(pending, biome.getModuleSettings().usedBiomes(getModuleSettings()));
|
||||
}
|
||||
|
||||
return biomes.v();
|
||||
|
||||
@@ -18,24 +18,15 @@
|
||||
|
||||
package art.arcane.iris.engine.object.world.region;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
||||
import art.arcane.iris.engine.object.loot.IrisBlockDrops;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootReference;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds;
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.framework.render.RenderType;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
@@ -77,28 +68,14 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
private final transient AtomicCache<KList<IrisBiome>> realShoreBiomes = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisBiome>> realCaveBiomes = new AtomicCache<>();
|
||||
private final transient AtomicCache<Color> cacheColor = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> surfaceOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> undergroundOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisOreGeneratorBounds> surfaceOreBoundsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisOreGeneratorBounds> undergroundOreBoundsCache = new AtomicCache<>();
|
||||
@MinNumber(2)
|
||||
@Required
|
||||
@Desc("The name of the region")
|
||||
private String name = "A Region";
|
||||
@ArrayType(min = 1, type = IrisEffect.class)
|
||||
@Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play arround the player even if where the effect was played is no longer in the biome the player is in.")
|
||||
private KList<IrisEffect> effects = new KList<>();
|
||||
@Desc("Spawn Entities in this region over time. Iris will continually replenish these mobs just like vanilla does.")
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@RegistryListResource(IrisSpawner.class)
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
@MinNumber(1)
|
||||
@MaxNumber(128)
|
||||
@Desc("The rarity of the region")
|
||||
private int rarity = 1;
|
||||
@ArrayType(min = 1, type = IrisBlockDrops.class)
|
||||
@Desc("Define custom block drops for this region")
|
||||
private KList<IrisBlockDrops> blockDrops = new KList<>();
|
||||
@ArrayType(min = 1, type = IrisObjectPlacement.class)
|
||||
@Desc("Objects define what schematics (iob files) iris will place in this region")
|
||||
private KList<IrisObjectPlacement> objects = new KList<>();
|
||||
@@ -110,8 +87,6 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
@MinNumber(0)
|
||||
@Desc("The min shore height")
|
||||
private double shoreHeightMin = 1.2;
|
||||
@Desc("Reference loot tables in this area")
|
||||
private IrisLootReference loot = new IrisLootReference();
|
||||
@MinNumber(0)
|
||||
@Desc("The the max shore height")
|
||||
private double shoreHeightMax = 3.2;
|
||||
@@ -130,8 +105,6 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
@MinNumber(0.0001)
|
||||
@Desc("How large cave biomes are in this region")
|
||||
private double caveBiomeZoom = 1;
|
||||
@Desc("Profile-driven 3D cave configuration")
|
||||
private CaveProfile caveProfile = new CaveProfile();
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Required
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@@ -149,100 +122,8 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("A list of root-level cave biomes in this region, used for carved cave interiors. Don't specify child biomes of other biomes here. Just the root parents.")
|
||||
private KList<String> caveBiomes = new KList<>();
|
||||
@ArrayType(min = 1, type = IrisDepositVariant.class)
|
||||
@Desc("Deposit ore remap rules scoped to this region. Each entry declares a vertical band and a source->replacement block id map. Applied after biome rules but before dimension rules; first matching region rule wins.")
|
||||
private KList<IrisDepositVariant> depositVariants = new KList<>();
|
||||
@Desc("A color for visualizing this region with a color. I.e. #F13AF5. This will show up on the map.")
|
||||
private String color = null;
|
||||
@Desc("Collection of ores to be generated")
|
||||
@ArrayType(type = IrisOreGenerator.class, min = 1)
|
||||
private KList<IrisOreGenerator> ores = new KList<>();
|
||||
|
||||
public PlatformBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
KList<IrisOreGenerator> localOres = surface ? getSurfaceOres() : getUndergroundOres();
|
||||
return generateOres(localOres, x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public PlatformBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getSurfaceOres(), x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public PlatformBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getUndergroundOres(), x, y, z, rng, data);
|
||||
}
|
||||
|
||||
public boolean hasSurfaceOres() {
|
||||
return !getSurfaceOres().isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasUndergroundOres() {
|
||||
return !getUndergroundOres().isEmpty();
|
||||
}
|
||||
|
||||
private PlatformBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, IrisData data) {
|
||||
if (localOres.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
PlatformBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setOres(KList<IrisOreGenerator> ores) {
|
||||
this.ores = ores == null ? new KList<>() : ores;
|
||||
surfaceOreCache.reset();
|
||||
undergroundOreCache.reset();
|
||||
surfaceOreBoundsCache.reset();
|
||||
undergroundOreBoundsCache.reset();
|
||||
}
|
||||
|
||||
public KList<IrisOreGenerator> getSurfaceOreGenerators() {
|
||||
return getOres(true);
|
||||
}
|
||||
|
||||
public KList<IrisOreGenerator> getUndergroundOreGenerators() {
|
||||
return getOres(false);
|
||||
}
|
||||
|
||||
public IrisOreGeneratorBounds getSurfaceOreGeneratorBounds() {
|
||||
return surfaceOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getSurfaceOres()));
|
||||
}
|
||||
|
||||
public IrisOreGeneratorBounds getUndergroundOreGeneratorBounds() {
|
||||
return undergroundOreBoundsCache.aquire(() -> IrisOreGeneratorBounds.of(getUndergroundOres()));
|
||||
}
|
||||
|
||||
private KList<IrisOreGenerator> getSurfaceOres() {
|
||||
return getOres(true);
|
||||
}
|
||||
|
||||
private KList<IrisOreGenerator> getUndergroundOres() {
|
||||
return getOres(false);
|
||||
}
|
||||
|
||||
private KList<IrisOreGenerator> getOres(boolean surface) {
|
||||
AtomicCache<KList<IrisOreGenerator>> oreCache = surface ? surfaceOreCache : undergroundOreCache;
|
||||
return oreCache.aquire(() -> {
|
||||
KList<IrisOreGenerator> filtered = new KList<>();
|
||||
KList<IrisOreGenerator> localOres = ores;
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
if (oreGenerator.isGenerateSurface() == surface) {
|
||||
filtered.add(oreGenerator);
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
});
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -315,7 +196,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
continue;
|
||||
}
|
||||
|
||||
names.add(biome.getCarvingBiome());
|
||||
names.addAll(biome.getModuleSettings().treeBiomes());
|
||||
b.put(biome.getLoadKey(), biome);
|
||||
names.addAll(biome.getChildren());
|
||||
}
|
||||
@@ -412,7 +293,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
continue;
|
||||
}
|
||||
|
||||
names.add(biome.getCarvingBiome());
|
||||
names.addAll(biome.getModuleSettings().treeBiomes());
|
||||
b.put(biome.getLoadKey(), biome);
|
||||
names.addAll(biome.getChildren());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.AmbientEffect;
|
||||
import art.arcane.iris.builtin.spawn.EffectCommands;
|
||||
import art.arcane.iris.builtin.spawn.EffectSettings;
|
||||
import art.arcane.iris.builtin.spawn.SpawnCommand;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.service.AmbientEffects;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* How {@code iris:spawn} plays the ambient effects of regions and biomes: the region's effects, then the biome's, each
|
||||
* when its interval and chance say, with every random choice made here so the host only carries them out.
|
||||
*/
|
||||
public final class AmbientEffecting implements AmbientEffects {
|
||||
@Override
|
||||
public List<Effect> due(PackWorld world, BlockPosition at) {
|
||||
Engine engine = IrisPackWorld.of(world).engine();
|
||||
EffectTimers timers = world.state(EffectTimers.class, ignored -> new EffectTimers());
|
||||
PlatformWorld platformWorld = engine.getWorld().platformWorld();
|
||||
|
||||
List<Effect> due = new ArrayList<>();
|
||||
addDue(due, effectsOf(engine.getRegion(at.x(), at.z())), timers, platformWorld);
|
||||
addDue(due, effectsOf(engine.getBiome(at.x(), at.y(), at.z())), timers, platformWorld);
|
||||
return due;
|
||||
}
|
||||
|
||||
private static List<AmbientEffect> effectsOf(IrisRegistrant owner) {
|
||||
return owner.getModuleSettings().find(EffectSettings.class).map(EffectSettings::effects).orElse(List.of());
|
||||
}
|
||||
|
||||
private static void addDue(List<Effect> due, List<AmbientEffect> effects, EffectTimers timers, PlatformWorld world) {
|
||||
for (AmbientEffect effect : effects) {
|
||||
if (timers.shouldPlayNow(effect)) {
|
||||
due.add(play(effect, world));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Effect play(AmbientEffect effect, PlatformWorld world) {
|
||||
Sound sound = effect.sound() == null ? null : soundOf(effect);
|
||||
Particles particles = effect.particleEffect() == null ? null : particlesOf(effect);
|
||||
return new Effect(sound, particles, commandsOf(effect.commandRegistry(), world), potionOf(effect));
|
||||
}
|
||||
|
||||
private static Sound soundOf(AmbientEffect effect) {
|
||||
int distance = effect.soundDistance();
|
||||
int offsetX = RNG.r.i(-distance, distance);
|
||||
int offsetY = RNG.r.i(-distance, distance);
|
||||
int offsetZ = RNG.r.i(-distance, distance);
|
||||
float pitch = (float) RNG.r.d(effect.minPitch(), effect.maxPitch());
|
||||
return new Sound(effect.sound(), offsetX, offsetY, offsetZ, (float) effect.volume(), pitch);
|
||||
}
|
||||
|
||||
private static Particles particlesOf(AmbientEffect effect) {
|
||||
double forward = RNG.r.i(effect.particleDistance()) + effect.particleAway();
|
||||
double sideways = RNG.r.d(-effect.particleDistanceWidth(), effect.particleDistanceWidth());
|
||||
double jitterX = RNG.r.d();
|
||||
double jitterZ = RNG.r.d();
|
||||
int lift = RNG.r.i(effect.particleOffset());
|
||||
double altX = randomized(effect.particleAltX(), effect.randomAltX());
|
||||
double altY = randomized(effect.particleAltY(), effect.randomAltY());
|
||||
double altZ = randomized(effect.particleAltZ(), effect.randomAltZ());
|
||||
return new Particles(effect.particleEffect(), forward, sideways, jitterX, jitterZ, lift, effect.particleCount(),
|
||||
altX, altY, altZ, effect.extra());
|
||||
}
|
||||
|
||||
private static List<Command> commandsOf(EffectCommands registry, PlatformWorld world) {
|
||||
List<Command> commands = new ArrayList<>();
|
||||
if (registry == null) {
|
||||
return commands;
|
||||
}
|
||||
|
||||
double offsetX = commandOffset(registry.commandOffsetX(), registry.commandRandomAltX());
|
||||
double offsetY = commandOffset(registry.commandOffsetY(), registry.commandRandomAltY());
|
||||
double offsetZ = commandOffset(registry.commandOffsetZ(), registry.commandRandomAltZ());
|
||||
for (SpawnCommand command : registry.rawCommands()) {
|
||||
if (SpawnConditions.allow(command.timeBlock(), command.weather(), world)) {
|
||||
commands.add(new Command(new EntitySpec.Command(command.commands(), command.delay(), command.repeat(),
|
||||
command.repeatDelay()), offsetX, offsetY, offsetZ));
|
||||
}
|
||||
if (registry.commandAllRandomLocations()) {
|
||||
offsetX = commandOffset(registry.commandOffsetX(), registry.commandRandomAltX());
|
||||
offsetY = commandOffset(registry.commandOffsetY(), registry.commandRandomAltY());
|
||||
offsetZ = commandOffset(registry.commandOffsetZ(), registry.commandRandomAltZ());
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
private static Potion potionOf(AmbientEffect effect) {
|
||||
if (effect.potionStrength() <= -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int shortest = Math.min(effect.potionTicksMax(), effect.potionTicksMin());
|
||||
int longest = Math.max(effect.potionTicksMax(), effect.potionTicksMin());
|
||||
return new Potion(effect.potionEffect(), effect.potionStrength(), RNG.r.i(shortest, longest));
|
||||
}
|
||||
|
||||
private static double commandOffset(double offset, boolean random) {
|
||||
return randomized(offset, random);
|
||||
}
|
||||
|
||||
private static double randomized(double value, boolean random) {
|
||||
return random ? RNG.r.d(-value, value) : value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.AmbientEffect;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* When the effects of a world play: an effect plays at most once per interval, and then only with its chance. The timers
|
||||
* are the world's, shared by every player, like the effects themselves.
|
||||
*/
|
||||
final class EffectTimers {
|
||||
private final ConcurrentMap<AmbientEffect, ChronoLatch> latches = new ConcurrentHashMap<>();
|
||||
|
||||
/** Whether {@code effect} plays now; asking starts its interval over when it has elapsed. */
|
||||
boolean shouldPlayNow(AmbientEffect effect) {
|
||||
ChronoLatch latch = latches.computeIfAbsent(effect, key -> new ChronoLatch(key.interval()));
|
||||
return latch.flip() && RNG.r.nextInt(effect.chance()) == 0;
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.loot.ItemAttributeModifier;
|
||||
import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.builtin.spawn.AmbientEffect;
|
||||
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||
import art.arcane.iris.builtin.spawn.SpawnCommand;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.loot.LootItems;
|
||||
import art.arcane.iris.engine.object.entity.IrisAttributeModifier;
|
||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
||||
import art.arcane.iris.engine.object.marker.IrisCommand;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
@@ -44,83 +44,85 @@ final class EntityResolution {
|
||||
|
||||
private final LootItems items;
|
||||
private final PlatformWorld world;
|
||||
private final EffectTimers timers;
|
||||
|
||||
/** @param world the world the entity appears in, whose time and weather decide which of its commands run */
|
||||
EntityResolution(LootItems items, PlatformWorld world) {
|
||||
EntityResolution(LootItems items, PlatformWorld world, EffectTimers timers) {
|
||||
this.items = items;
|
||||
this.world = world;
|
||||
this.timers = timers;
|
||||
}
|
||||
|
||||
EntitySpec resolve(IrisEntity entity, RNG rng) {
|
||||
EntitySpec resolve(EntityDefinition entity, RNG rng) {
|
||||
List<EntitySpec> passengers = new ArrayList<>();
|
||||
long passengerIndex = 0;
|
||||
for (IrisEntity passenger : entity.getPassengers()) {
|
||||
for (EntityDefinition passenger : entity.passengers()) {
|
||||
passengers.add(resolve(passenger, rng.nextParallelRNG(PASSENGER_STREAM_BASE + passengerIndex++)));
|
||||
}
|
||||
|
||||
List<ItemAttribute> attributes = drawAttributes(entity, rng);
|
||||
List<String> lootTables = List.copyOf(entity.getLoot().getTables());
|
||||
List<String> lootTables = List.copyOf(entity.loot().tables());
|
||||
long lootShuffleSeed = lootTables.isEmpty() ? 0L : rng.nextLong();
|
||||
EntitySpec leashHolder = entity.getLeashHolder() == null ? null : resolve(entity.getLeashHolder(), rng.nextParallelRNG(LEASH_HOLDER_STREAM));
|
||||
EntitySpec leashHolder = entity.leashHolder() == null ? null : resolve(entity.leashHolder(), rng.nextParallelRNG(LEASH_HOLDER_STREAM));
|
||||
EntitySpec.Equipment equipment = new EntitySpec.Equipment(
|
||||
equip(entity.getHelmet(), rng), equip(entity.getChestplate(), rng), equip(entity.getLeggings(), rng),
|
||||
equip(entity.getBoots(), rng), equip(entity.getMainHand(), rng), equip(entity.getOffHand(), rng));
|
||||
equip(entity.helmet(), rng), equip(entity.chestplate(), rng), equip(entity.leggings(), rng),
|
||||
equip(entity.boots(), rng), equip(entity.mainHand(), rng), equip(entity.offHand(), rng));
|
||||
|
||||
return new EntitySpec(
|
||||
entity.getType() == null ? "" : entity.getType(),
|
||||
entity.getSpecialType() == null ? "" : entity.getSpecialType(),
|
||||
entity.getReason(),
|
||||
entity.getCustomName() == null ? "" : entity.getCustomName(),
|
||||
entity.type() == null ? "" : entity.type(),
|
||||
entity.specialType() == null ? "" : entity.specialType(),
|
||||
entity.reason(),
|
||||
entity.customName() == null ? "" : entity.customName(),
|
||||
flagsOf(entity), equipment, passengers, attributes, lootTables, lootShuffleSeed, leashHolder,
|
||||
spawnEffectOf(entity), entity.isSpawnEffectRiseOutOfGround(), entity.getPandaMainGene(),
|
||||
entity.getPandaHiddenGene(), entity.isApplySettingsToCustomMobAnyways(), commandsOf(entity));
|
||||
spawnEffectOf(entity), entity.spawnEffectRiseOutOfGround(), entity.pandaMainGene(),
|
||||
entity.pandaHiddenGene(), entity.applySettingsToCustomMobAnyways(), commandsOf(entity));
|
||||
}
|
||||
|
||||
private static EntitySpec.Flags flagsOf(IrisEntity entity) {
|
||||
return new EntitySpec.Flags(entity.isCustomNameVisible(), entity.isAware(), entity.isAi(), entity.isGlowing(),
|
||||
entity.isGravity(), entity.isInvulnerable(), entity.isSilent(), entity.isPickupItems(), entity.isRemovable(),
|
||||
entity.isKeepEntity(), entity.isBaby());
|
||||
private static EntitySpec.Flags flagsOf(EntityDefinition entity) {
|
||||
return new EntitySpec.Flags(entity.customNameVisible(), entity.aware(), entity.ai(), entity.glowing(),
|
||||
entity.gravity(), entity.invulnerable(), entity.silent(), entity.pickupItems(), entity.removable(),
|
||||
entity.keepEntity(), entity.baby());
|
||||
}
|
||||
|
||||
private static List<ItemAttribute> drawAttributes(IrisEntity entity, RNG rng) {
|
||||
private static List<ItemAttribute> drawAttributes(EntityDefinition entity, RNG rng) {
|
||||
List<ItemAttribute> attributes = new ArrayList<>();
|
||||
for (IrisAttributeModifier modifier : entity.getAttributes()) {
|
||||
if (rng.nextDouble() >= modifier.getChance()) {
|
||||
for (ItemAttributeModifier modifier : entity.attributes()) {
|
||||
if (rng.nextDouble() >= modifier.chance()) {
|
||||
continue;
|
||||
}
|
||||
String attribute = modifier.getAttribute();
|
||||
String attribute = modifier.attribute();
|
||||
if (attribute == null || attribute.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
attributes.add(new ItemAttribute(attribute, modifier.getName(), modifier.getOperation(), modifier.getAmount(rng)));
|
||||
attributes.add(new ItemAttribute(attribute, modifier.name(), modifier.operation(), rng.d(modifier.minAmount(), modifier.maxAmount())));
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
private ItemDrop equip(IrisLoot piece, RNG rng) {
|
||||
if (piece == null || !LootResolver.oneIn(rng, piece.getRarity())) {
|
||||
private ItemDrop equip(LootEntry piece, RNG rng) {
|
||||
if (piece == null || !LootResolver.oneIn(rng, piece.rarity())) {
|
||||
return null;
|
||||
}
|
||||
return items.give(piece, rng);
|
||||
}
|
||||
|
||||
/** The entity's spawn effect when it shows this time: an effect only shows now and then, as its interval and chance say. */
|
||||
private static EntitySpec.SpawnEffect spawnEffectOf(IrisEntity entity) {
|
||||
IrisEffect effect = entity.getSpawnEffect();
|
||||
if (effect == null || !effect.shouldApplyNow()) {
|
||||
private EntitySpec.SpawnEffect spawnEffectOf(EntityDefinition entity) {
|
||||
AmbientEffect effect = entity.spawnEffect();
|
||||
if (effect == null || !timers.shouldPlayNow(effect)) {
|
||||
return null;
|
||||
}
|
||||
return new EntitySpec.SpawnEffect(effect.getSoundKey(), effect.getSoundDistance(), effect.getMinPitch(),
|
||||
effect.getMaxPitch(), effect.getVolume(), effect.getParticleEffectKey(), effect.getParticleOffset(),
|
||||
effect.getParticleCount(), effect.getParticleAltX(), effect.getParticleAltY(), effect.getParticleAltZ(),
|
||||
effect.isRandomAltX(), effect.isRandomAltY(), effect.isRandomAltZ(), effect.getExtra());
|
||||
return new EntitySpec.SpawnEffect(effect.sound(), effect.soundDistance(), effect.minPitch(),
|
||||
effect.maxPitch(), effect.volume(), effect.particleEffect(), effect.particleOffset(),
|
||||
effect.particleCount(), effect.particleAltX(), effect.particleAltY(), effect.particleAltZ(),
|
||||
effect.randomAltX(), effect.randomAltY(), effect.randomAltZ(), effect.extra());
|
||||
}
|
||||
|
||||
private List<EntitySpec.Command> commandsOf(IrisEntity entity) {
|
||||
private List<EntitySpec.Command> commandsOf(EntityDefinition entity) {
|
||||
List<EntitySpec.Command> commands = new ArrayList<>();
|
||||
for (IrisCommand command : entity.getRawCommands()) {
|
||||
if (command.isValid(world)) {
|
||||
commands.add(new EntitySpec.Command(command.getCommands(), command.getDelay(), command.isRepeat(), command.getRepeatDelay()));
|
||||
for (SpawnCommand command : entity.rawCommands()) {
|
||||
if (SpawnConditions.allow(command.timeBlock(), command.weather(), world)) {
|
||||
commands.add(new EntitySpec.Command(command.commands(), command.delay(), command.repeat(), command.repeatDelay()));
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
|
||||
@@ -18,26 +18,29 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||
import art.arcane.iris.builtin.spawn.EntitySpawn;
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.builtin.spawn.SpawnSurface;
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
import art.arcane.iris.builtin.spawn.SpawnerSettings;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.loot.LootItems;
|
||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
||||
import art.arcane.iris.engine.object.entity.IrisEntitySpawn;
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSurface;
|
||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.spawn.SpawnResources.KeyedSpawner;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.util.common.scheduling.J;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.PowerOfTwoCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.matter.slices.MarkerMatter;
|
||||
import com.volmit.config.Range;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.world.BlockPosition;
|
||||
@@ -76,15 +79,15 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
if (count <= 0) {
|
||||
return;
|
||||
}
|
||||
IrisSpawner spawner = SpawnResources.spawner(engine(world).getData(), plan.spawner());
|
||||
Spawner spawner = SpawnResources.spawner(engine(world).getData(), plan.spawner());
|
||||
if (spawner != null) {
|
||||
spawner.spawn(engine(world), plan.chunkX(), plan.chunkZ());
|
||||
SpawnerGate.spawned(plan.spawner(), spawner, engine(world), plan.chunkX(), plan.chunkZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EntitySpec> entity(PackWorld world, String key) {
|
||||
IrisEntity entity = SpawnResources.entity(engine(world).getData(), key);
|
||||
EntityDefinition entity = SpawnResources.entity(engine(world).getData(), key);
|
||||
if (entity == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -97,40 +100,40 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
return Optional.empty();
|
||||
}
|
||||
Engine engine = engine(world);
|
||||
IrisMarker marker = SpawnResources.marker(engine.getData(), tag);
|
||||
SpawnMarker marker = SpawnResources.marker(engine.getData(), tag);
|
||||
if (marker == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
List<String> spawners = new ArrayList<>();
|
||||
for (String key : marker.getSpawners()) {
|
||||
for (String key : marker.spawners()) {
|
||||
if (SpawnResources.spawner(engine.getData(), key) == null) {
|
||||
IrisLogging.error("Cannot load spawner: " + key + " for marker " + tag);
|
||||
continue;
|
||||
}
|
||||
spawners.add(key);
|
||||
}
|
||||
return Optional.of(new MarkerRule(spawners, marker.isEmptyAbove(), marker.isRemoveOnChange()));
|
||||
return Optional.of(new MarkerRule(spawners, marker.emptyAbove(), marker.removeOnChange()));
|
||||
}
|
||||
|
||||
private Optional<Plan> planChunk(PackWorld world, Engine engine, Chunk chunk) {
|
||||
Predicate<IrisSpawner> canSpawn = spawner -> spawner.canSpawn(engine, chunk.chunkX(), chunk.chunkZ());
|
||||
Predicate<KeyedSpawner> canSpawn = keyed -> SpawnerGate.canSpawn(keyed.key(), keyed.spawner(), engine, chunk.chunkX(), chunk.chunkZ());
|
||||
int blockX = PowerOfTwoCoordinates.chunkToBlock(chunk.chunkX());
|
||||
int blockZ = PowerOfTwoCoordinates.chunkToBlock(chunk.chunkZ());
|
||||
IrisBiome centreBiome = engine.getSurfaceBiome(blockX + BLOCKS_TO_CHUNK_CENTRE, blockZ + BLOCKS_TO_CHUNK_CENTRE);
|
||||
IrisRegion region = engine.getRegion(blockX, blockZ);
|
||||
IrisBiome biome = engine.getSurfaceBiome(blockX, blockZ);
|
||||
|
||||
List<IrisSpawner> candidates = Stream.concat(
|
||||
shuffled(engine, engine.getDimension().getEntitySpawners()).stream()
|
||||
.filter(canSpawn).filter(spawner -> spawner.isValid(centreBiome)),
|
||||
List<KeyedSpawner> candidates = Stream.concat(
|
||||
shuffled(engine, engine.getDimension()).stream()
|
||||
.filter(canSpawn).filter(keyed -> SpawnerGate.suits(keyed.spawner(), centreBiome)),
|
||||
Stream.concat(
|
||||
shuffled(engine, region.getEntitySpawners()).stream().filter(canSpawn),
|
||||
shuffled(engine, biome.getEntitySpawners()).stream().filter(canSpawn)))
|
||||
.filter(spawner -> chunk.livingEntities() < spawner.getMaxEntitiesPerChunk())
|
||||
shuffled(engine, region).stream().filter(canSpawn),
|
||||
shuffled(engine, biome).stream().filter(canSpawn)))
|
||||
.filter(keyed -> chunk.livingEntities() < keyed.spawner().maxEntitiesPerChunk())
|
||||
.toList();
|
||||
|
||||
List<Candidate> spawns = candidates.stream().flatMap(spawner -> spawnsOf(spawner, chunk.initial())).collect(Collectors.toList());
|
||||
List<Candidate> spawns = candidates.stream().flatMap(keyed -> spawnsOf(keyed, chunk.initial())).collect(Collectors.toList());
|
||||
Candidate chosen = IRare.expandWeighted(spawns).getRandom();
|
||||
if (chosen == null) {
|
||||
return Optional.empty();
|
||||
@@ -139,26 +142,25 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
}
|
||||
|
||||
private Optional<Plan> planChunkSpawn(PackWorld world, Engine engine, Chunk chunk, Candidate chosen) {
|
||||
IrisSpawner spawner = chosen.spawner();
|
||||
IrisEntitySpawn spawn = chosen.spawn();
|
||||
int count = LootResolver.inclusive(RNG.r, spawn.getMinSpawns(), spawn.getMaxSpawns());
|
||||
EntitySpawn spawn = chosen.spawn();
|
||||
int count = LootResolver.inclusive(RNG.r, spawn.minSpawns(), spawn.maxSpawns());
|
||||
List<Attempt> attempts = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
int x = (chunk.chunkX() * CHUNK_SIZE) + RNG.r.i(CHUNK_SIZE);
|
||||
int z = (chunk.chunkZ() * CHUNK_SIZE) + RNG.r.i(CHUNK_SIZE);
|
||||
BlockPosition at = spawnPosition(engine, spawner, chunk.chunkX(), chunk.chunkZ(), x, z);
|
||||
BlockPosition at = spawnPosition(engine, chosen.spawner(), chunk.chunkX(), chunk.chunkZ(), x, z);
|
||||
if (at != null) {
|
||||
addAttempt(attempts, world, engine, chosen, at, true);
|
||||
}
|
||||
}
|
||||
return attempts.isEmpty() ? Optional.empty() : Optional.of(new Plan(spawner.getLoadKey(), chunk.chunkX(), chunk.chunkZ(), false, attempts));
|
||||
return attempts.isEmpty() ? Optional.empty() : Optional.of(new Plan(chosen.key(), chunk.chunkX(), chunk.chunkZ(), false, attempts));
|
||||
}
|
||||
|
||||
/** Where a spawner of its group puts an entity at the column; null when it has no place for one. */
|
||||
private static BlockPosition spawnPosition(Engine engine, IrisSpawner spawner, int chunkX, int chunkZ, int x, int z) {
|
||||
private static BlockPosition spawnPosition(Engine engine, Spawner spawner, int chunkX, int chunkZ, int x, int z) {
|
||||
int height = engine.getHeight(x, z, true);
|
||||
int heightWithFluid = engine.getHeight(x, z, false);
|
||||
return switch (spawner.getGroup()) {
|
||||
return switch (spawner.group()) {
|
||||
case NORMAL -> new BlockPosition(x, heightWithFluid + 1, z);
|
||||
case CAVE -> caveSpawnPosition(engine, chunkX, chunkZ);
|
||||
case UNDERWATER, BEACH -> new BlockPosition(x, RNG.r.i(height + 1, heightWithFluid), z);
|
||||
@@ -175,78 +177,92 @@ public final class EntitySpawning implements EntitySpawns {
|
||||
}
|
||||
|
||||
private Optional<Plan> planMarker(PackWorld world, Engine engine, Marker marker) {
|
||||
IrisSpawner spawner = SpawnResources.spawner(engine.getData(), marker.spawner());
|
||||
IrisMarker irisMarker = SpawnResources.marker(engine.getData(), marker.marker());
|
||||
Spawner spawner = SpawnResources.spawner(engine.getData(), marker.spawner());
|
||||
SpawnMarker spawnMarker = SpawnResources.marker(engine.getData(), marker.marker());
|
||||
if (spawner == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
KList<IrisEntitySpawn> candidates = marker.initial() ? spawner.getInitialSpawns() : spawner.getSpawns();
|
||||
List<EntitySpawn> candidates = marker.initial() ? spawner.initialSpawns() : spawner.spawns();
|
||||
if (candidates.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
IrisEntitySpawn spawn = IRare.expandWeighted(candidates).getRandom();
|
||||
EntitySpawn spawn = IRare.expandWeighted(candidates.stream().map(RareSpawn::new).toList()).getRandom().spawn();
|
||||
|
||||
BlockPosition position = marker.position();
|
||||
int chunkX = PowerOfTwoCoordinates.blockToChunkFloor(position.x());
|
||||
int chunkZ = PowerOfTwoCoordinates.blockToChunkFloor(position.z());
|
||||
if (!spawner.canSpawn(engine, chunkX, chunkZ)) {
|
||||
if (!SpawnerGate.canSpawn(marker.spawner(), spawner, engine, chunkX, chunkZ)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
int count = LootResolver.inclusive(RNG.r, spawn.getMinSpawns(), spawn.getMaxSpawns());
|
||||
int count = LootResolver.inclusive(RNG.r, spawn.minSpawns(), spawn.maxSpawns());
|
||||
if (count <= 0) {
|
||||
return Optional.empty();
|
||||
}
|
||||
boolean exhaustsMarker = irisMarker != null && irisMarker.shouldExhaust();
|
||||
boolean exhaustsMarker = spawnMarker != null && shouldExhaust(spawnMarker);
|
||||
List<Attempt> attempts = new ArrayList<>();
|
||||
BlockPosition above = new BlockPosition(position.x(), position.y() + AIR_ABOVE_MARKER, position.z());
|
||||
for (int i = 0; i < count; i++) {
|
||||
addAttempt(attempts, world, engine, new Candidate(spawner, spawn), above, false);
|
||||
addAttempt(attempts, world, engine, new Candidate(marker.spawner(), spawner, spawn), above, false);
|
||||
}
|
||||
return attempts.isEmpty() ? Optional.empty() : Optional.of(new Plan(spawner.getLoadKey(), chunkX, chunkZ, exhaustsMarker, attempts));
|
||||
return attempts.isEmpty() ? Optional.empty() : Optional.of(new Plan(marker.spawner(), chunkX, chunkZ, exhaustsMarker, attempts));
|
||||
}
|
||||
|
||||
private static boolean shouldExhaust(SpawnMarker marker) {
|
||||
return marker.exhaustionChance() > RNG.r.nextDouble();
|
||||
}
|
||||
|
||||
private void addAttempt(List<Attempt> attempts, PackWorld world, Engine engine, Candidate candidate, BlockPosition at, boolean checkSurface) {
|
||||
IrisEntity entity = candidate.spawn().getRealEntity(engine);
|
||||
EntityDefinition entity = SpawnResources.entity(engine.getData(), candidate.spawn().entity());
|
||||
if (entity == null) {
|
||||
IrisLogging.debug(" You are trying to spawn an entity that does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
IrisRange light = candidate.spawner().getAllowedLightLevels();
|
||||
Range light = candidate.spawner().allowedLightLevels();
|
||||
EntitySpec spec = resolution(world, engine).resolve(entity, entityRandom(world).rng());
|
||||
attempts.add(new Attempt(at, spec, surfaceOf(entity.getSurface()),
|
||||
(int) Math.ceil(light.getMin()), (int) Math.floor(light.getMax()), checkSurface));
|
||||
attempts.add(new Attempt(at, spec, surfaceOf(entity.surface()),
|
||||
(int) Math.ceil(light.min()), (int) Math.floor(light.max()), checkSurface));
|
||||
}
|
||||
|
||||
private static EntityResolution resolution(PackWorld world, Engine engine) {
|
||||
LootItems items = new LootItems(world.resources().items(), engine.isStudio());
|
||||
return new EntityResolution(items, engine.getWorld().platformWorld());
|
||||
return new EntityResolution(items, engine.getWorld().platformWorld(), world.state(EffectTimers.class, ignored -> new EffectTimers()));
|
||||
}
|
||||
|
||||
private static EntityRandom entityRandom(PackWorld world) {
|
||||
return world.state(EntityRandom.class, EntityRandom::new);
|
||||
}
|
||||
|
||||
private static Surface surfaceOf(IrisSurface surface) {
|
||||
private static Surface surfaceOf(SpawnSurface surface) {
|
||||
return Surface.valueOf(surface.name());
|
||||
}
|
||||
|
||||
private static KList<IrisSpawner> shuffled(Engine engine, KList<String> keys) {
|
||||
return SpawnResources.spawners(engine.getData(), keys).shuffleCopy(RNG.r);
|
||||
/** The spawners an area lists, in a random order. */
|
||||
private static List<KeyedSpawner> shuffled(Engine engine, IrisRegistrant owner) {
|
||||
List<String> keys = owner.getModuleSettings().find(SpawnerSettings.class).map(SpawnerSettings::spawners).orElse(List.of());
|
||||
return new KList<>(SpawnResources.spawners(engine.getData(), keys)).shuffleCopy(RNG.r);
|
||||
}
|
||||
|
||||
private static Stream<Candidate> spawnsOf(IrisSpawner spawner, boolean initial) {
|
||||
KList<IrisEntitySpawn> spawns = initial ? spawner.getInitialSpawns() : spawner.getSpawns();
|
||||
return spawns.stream().map(spawn -> new Candidate(spawner, spawn));
|
||||
private static Stream<Candidate> spawnsOf(KeyedSpawner keyed, boolean initial) {
|
||||
List<EntitySpawn> spawns = initial ? keyed.spawner().initialSpawns() : keyed.spawner().spawns();
|
||||
return spawns.stream().map(spawn -> new Candidate(keyed.key(), keyed.spawner(), spawn));
|
||||
}
|
||||
|
||||
/** A spawn of a spawner, which picks as often as the spawn's rarity says. */
|
||||
private record Candidate(IrisSpawner spawner, IrisEntitySpawn spawn) implements IRare {
|
||||
private record Candidate(String key, Spawner spawner, EntitySpawn spawn) implements IRare {
|
||||
@Override
|
||||
public int getRarity() {
|
||||
return spawn.getRarity();
|
||||
return spawn.rarity();
|
||||
}
|
||||
}
|
||||
|
||||
/** A spawn that picks as often as its rarity says. */
|
||||
private record RareSpawn(EntitySpawn spawn) implements IRare {
|
||||
@Override
|
||||
public int getRarity() {
|
||||
return spawn.rarity();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.SpawnTimeBlock;
|
||||
import art.arcane.iris.builtin.spawn.SpawnWeather;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
|
||||
/** The time of day and the weather a command or spawner of the pack asks for, checked against a world. */
|
||||
final class SpawnConditions {
|
||||
private static final double TICKS_PER_HOUR = 1000D;
|
||||
private static final double HOURS_AT_TIME_ZERO = 6;
|
||||
private static final double HOURS_PER_DAY = 24;
|
||||
|
||||
private SpawnConditions() {
|
||||
}
|
||||
|
||||
static boolean allow(SpawnTimeBlock time, SpawnWeather weather, PlatformWorld world) {
|
||||
return time.contains(hourOf(world)) && weather.matches(world.isStorming(), world.isThundering());
|
||||
}
|
||||
|
||||
/** The world's time of day as a clock hour: tick 0 is 6 in the morning. */
|
||||
static double hourOf(PlatformWorld world) {
|
||||
return ((world.getTime() / TICKS_PER_HOUR) + HOURS_AT_TIME_ZERO) % HOURS_PER_DAY;
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,21 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.EffectSettings;
|
||||
import art.arcane.iris.builtin.spawn.SpawnerSettings;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.service.AmbientEffects;
|
||||
import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:spawn}: the spawners, entities and markers of the pack ({@link SpawnResources}), and the entities that appear in the world
|
||||
* over time because of them. It has no generation stage; Iris asks it through {@link EntitySpawns} when it looks for
|
||||
* something to spawn in a chunk or at a marker.
|
||||
* Module {@code iris:spawn}: the spawners, entities and markers of the pack ({@link SpawnResources}), the
|
||||
* {@link SpawnerSettings} that dimensions, regions and biomes list, the entities that appear in the world over time
|
||||
* because of them, and the ambient effects ({@link EffectSettings}) that play around players. It has no generation
|
||||
* stage; Iris asks it through {@link EntitySpawns} when it looks for something to spawn in a chunk or at a marker, and
|
||||
* through {@link AmbientEffects} for the effects due around a player.
|
||||
*/
|
||||
public final class SpawnModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
@@ -43,7 +48,10 @@ public final class SpawnModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(SpawnerSettings.class);
|
||||
registry.registerSettings(EffectSettings.class);
|
||||
SpawnResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerService(EntitySpawns.class, new EntitySpawning());
|
||||
registry.registerService(AmbientEffects.class, new AmbientEffecting());
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,15 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -39,39 +39,43 @@ import java.util.List;
|
||||
*/
|
||||
public final class SpawnResources {
|
||||
/** Spawners, in {@code spawners/}. */
|
||||
public static final ResourceKind<IrisSpawner> SPAWNERS = ResourceKind.of("iris:spawn/spawner", "spawners", IrisSpawner.class);
|
||||
public static final ResourceKind<Spawner> SPAWNERS = ResourceKind.of("iris:spawn/spawner", "spawners", Spawner.class);
|
||||
/** Entities, in {@code entities/}. */
|
||||
public static final ResourceKind<IrisEntity> ENTITIES = ResourceKind.of("iris:spawn/entity", "entities", IrisEntity.class);
|
||||
public static final ResourceKind<EntityDefinition> ENTITIES = ResourceKind.of("iris:spawn/entity", "entities", EntityDefinition.class);
|
||||
/** Markers, in {@code markers/}. */
|
||||
public static final ResourceKind<IrisMarker> MARKERS = ResourceKind.of("iris:spawn/marker", "markers", IrisMarker.class);
|
||||
public static final ResourceKind<SpawnMarker> MARKERS = ResourceKind.of("iris:spawn/marker", "markers", SpawnMarker.class);
|
||||
|
||||
private SpawnResources() {
|
||||
}
|
||||
|
||||
/** A spawner and the key the pack names it by. */
|
||||
public record KeyedSpawner(String key, Spawner spawner) {
|
||||
}
|
||||
|
||||
/** Every resource kind of the spawn module. */
|
||||
public static List<ResourceKind<?>> kinds() {
|
||||
return List.of(SPAWNERS, ENTITIES, MARKERS);
|
||||
}
|
||||
|
||||
public static IrisSpawner spawner(IrisData data, String key) {
|
||||
public static Spawner spawner(IrisData data, String key) {
|
||||
return find(data, SPAWNERS, key);
|
||||
}
|
||||
|
||||
public static IrisEntity entity(IrisData data, String key) {
|
||||
public static EntityDefinition entity(IrisData data, String key) {
|
||||
return find(data, ENTITIES, key);
|
||||
}
|
||||
|
||||
public static IrisMarker marker(IrisData data, String key) {
|
||||
public static SpawnMarker marker(IrisData data, String key) {
|
||||
return find(data, MARKERS, key);
|
||||
}
|
||||
|
||||
/** The spawners of the pack named by {@code keys}, in order, without the ones the pack lacks. */
|
||||
public static KList<IrisSpawner> spawners(IrisData data, List<String> keys) {
|
||||
KList<IrisSpawner> spawners = new KList<>();
|
||||
public static List<KeyedSpawner> spawners(IrisData data, List<String> keys) {
|
||||
List<KeyedSpawner> spawners = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
IrisSpawner spawner = spawner(data, key);
|
||||
Spawner spawner = spawner(data, key);
|
||||
if (spawner != null) {
|
||||
spawners.add(spawner);
|
||||
spawners.add(new KeyedSpawner(key, spawner));
|
||||
}
|
||||
}
|
||||
return spawners;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.SpawnRate;
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
|
||||
/**
|
||||
* Whether a spawner may fire: in a biome of the kind its group wants, in the time and weather it asks for, and not
|
||||
* more often than its rates allow. The rates count in the engine's persisted data, by the key the pack names the
|
||||
* spawner by.
|
||||
*/
|
||||
final class SpawnerGate {
|
||||
private SpawnerGate() {
|
||||
}
|
||||
|
||||
/** Whether a spawner of this group fires in {@code biome}. */
|
||||
static boolean suits(Spawner spawner, IrisBiome biome) {
|
||||
return switch (spawner.group()) {
|
||||
case NORMAL -> switch (biome.getInferredType()) {
|
||||
case SHORE, SEA, CAVE -> false;
|
||||
case LAND -> true;
|
||||
};
|
||||
case CAVE -> true;
|
||||
case UNDERWATER -> switch (biome.getInferredType()) {
|
||||
case SHORE, LAND, CAVE -> false;
|
||||
case SEA -> true;
|
||||
};
|
||||
case BEACH -> switch (biome.getInferredType()) {
|
||||
case SHORE -> true;
|
||||
case LAND, CAVE, SEA -> false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/** Whether the world is in the time and weather the spawner asks for. */
|
||||
static boolean suits(Spawner spawner, PlatformWorld world) {
|
||||
return SpawnConditions.allow(spawner.timeBlock(), spawner.weather(), world);
|
||||
}
|
||||
|
||||
/** Whether the spawner may fire in the chunk now. */
|
||||
static boolean canSpawn(String key, Spawner spawner, Engine engine, int chunkX, int chunkZ) {
|
||||
if (!canSpawn(key, spawner, engine)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SpawnRate rate = spawner.maximumRatePerChunk();
|
||||
return rate.isInfinite() || engine.getEngineData().getChunk(chunkX, chunkZ).getCooldown(key).canSpawn(rate.interval());
|
||||
}
|
||||
|
||||
/** Counts a spawn of the spawner in the chunk against its rates. */
|
||||
static void spawned(String key, Spawner spawner, Engine engine, int chunkX, int chunkZ) {
|
||||
spawned(key, spawner, engine);
|
||||
if (spawner.maximumRatePerChunk().isInfinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
engine.getEngineData().getChunk(chunkX, chunkZ).getCooldown(key).spawn();
|
||||
}
|
||||
|
||||
private static boolean canSpawn(String key, Spawner spawner, Engine engine) {
|
||||
PlatformWorld world = engine.getWorld().platformWorld();
|
||||
if (world == null || !suits(spawner, world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SpawnRate rate = spawner.maximumRate();
|
||||
return rate.isInfinite() || engine.getEngineData().getCooldown(key).canSpawn(rate.interval());
|
||||
}
|
||||
|
||||
private static void spawned(String key, Spawner spawner, Engine engine) {
|
||||
if (spawner.maximumRate().isInfinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
engine.getEngineData().getCooldown(key).spawn();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
* 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.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersMaxSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayerBlocks;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.iris.builtin.terrain.SeaLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisValues;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* What the terrain module keeps for one world about the layers of its biomes: each layer made ready ({@link ResolvedLayer})
|
||||
* and the noise that sets the thickness of a biome's layers, and the blocks the layers of a biome stack up to at a column.
|
||||
* A biome's layers are its {@link LayersSettings}, {@link SeaLayersSettings} and {@link CaveCeilingLayersSettings}; a biome
|
||||
* that declares no layers has the one layer of grass the settings default to.
|
||||
*
|
||||
* <p>The noise of a biome's layers is built once, from the random of the first column asked for, as it always was.
|
||||
*/
|
||||
public final class BiomeLayers {
|
||||
private static final int SURFACE_HEIGHT_SEED = 7235;
|
||||
private static final int SEA_HEIGHT_SEED = 7735;
|
||||
private static final int LOCKED_LAYERS_REFERENCE_HEIGHT = 512;
|
||||
private static final LayersSettings DEFAULT_LAYERS = new LayersSettings();
|
||||
private static final PaletteLayer NO_LAYER = PaletteLayer.withoutBlocks();
|
||||
|
||||
private static final class States {
|
||||
private static final PlatformBlockState BARRIER = B.getState("BARRIER");
|
||||
}
|
||||
|
||||
private final Supplier<LayerBlocks> layerBlocks;
|
||||
private final Map<PaletteLayer, ResolvedLayer> resolved = new ConcurrentHashMap<>();
|
||||
private final Map<LayersSettings, AtomicCache<KList<CNG>>> surfaceHeights = new ConcurrentHashMap<>();
|
||||
private final Map<SeaLayersSettings, AtomicCache<KList<CNG>>> seaHeights = new ConcurrentHashMap<>();
|
||||
private volatile Double busiestBiomeLayerCount;
|
||||
|
||||
/** The layers of the world {@code engine} generates now. */
|
||||
public static BiomeLayers of(Engine engine) {
|
||||
return engine.getGeneration().state(BiomeLayers.class,
|
||||
generating -> new BiomeLayers(() -> LayerBlocks.of(generating.getGeneration().world())));
|
||||
}
|
||||
|
||||
/** The layers of a world whose layer blocks {@code layerBlocks} gives, asked for when a layer first picks a block. */
|
||||
public BiomeLayers(Supplier<LayerBlocks> layerBlocks) {
|
||||
this.layerBlocks = layerBlocks;
|
||||
}
|
||||
|
||||
/** {@code layer} ready for this world; its block picks are the world's {@link LayerBlocks}. */
|
||||
public ResolvedLayer resolve(PaletteLayer layer) {
|
||||
return resolved.computeIfAbsent(layer, declared -> ResolvedLayer.of(declared, layerBlocks));
|
||||
}
|
||||
|
||||
/** The biome's wall, which places no block when the biome declares none. */
|
||||
public ResolvedLayer wall(IrisBiome biome) {
|
||||
PaletteLayer layer = biome.getModuleSettings().find(WallSettings.class).map(WallSettings::layer).orElse(NO_LAYER);
|
||||
return resolve(layer);
|
||||
}
|
||||
|
||||
/** The layers of the biome's surface, top first. */
|
||||
public static List<PaletteLayer> layersOf(IrisBiome biome) {
|
||||
return surfaceSettings(biome).layers();
|
||||
}
|
||||
|
||||
/** The noise style of each layer of the biome's surface, top first, as Iris's generators know them. */
|
||||
public static List<NoiseStyle> layerStyles(IrisBiome biome) {
|
||||
return layersOf(biome).stream().map(layer -> IrisValues.generatorStyle(layer.style()).getStyle()).toList();
|
||||
}
|
||||
|
||||
/** The most layers any biome the dimension reaches has, which is what studio's layer load view compares a biome with. */
|
||||
public double busiestLayerCount(Engine engine) {
|
||||
Double cached = busiestBiomeLayerCount;
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
double busiest = 0D;
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
busiest = Math.max(busiest, layersOf(biome).size());
|
||||
}
|
||||
busiestBiomeLayerCount = busiest;
|
||||
return busiest;
|
||||
}
|
||||
|
||||
/** The blocks the biome's layers stack up to at the column, top first, at most {@code maxDepth} of them. */
|
||||
public KList<PlatformBlockState> generateLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
|
||||
if (isLocked(biome)) {
|
||||
return generateLockedLayers(biome, wx, wz, random, maxDepth, height, complex);
|
||||
}
|
||||
|
||||
KList<PlatformBlockState> blocks = new KList<>();
|
||||
if (maxDepth <= 0) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
LayersSettings settings = surfaceSettings(biome);
|
||||
List<PaletteLayer> layers = settings.layers();
|
||||
if (layers.isEmpty()) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
KList<CNG> heightNoises = surfaceHeightNoises(settings, random);
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
ResolvedLayer layer = resolve(layers.get(i));
|
||||
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
|
||||
if (depth <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
stackLayer(blocks, layer, i, depth, wx, wz, random, maxDepth);
|
||||
if (blocks.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
separateLayers(blocks, dimension, maxDepth);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** The blocks the biome's cave ceiling layers stack up to at the column, nearest the ceiling first, at most {@code maxDepth} of them. */
|
||||
public KList<PlatformBlockState> generateCeilingLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
|
||||
KList<PlatformBlockState> blocks = new KList<>();
|
||||
if (maxDepth <= 0) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
List<PaletteLayer> ceilingLayers = biome.getModuleSettings().find(CaveCeilingLayersSettings.class)
|
||||
.map(CaveCeilingLayersSettings::layers).orElse(List.of());
|
||||
if (ceilingLayers.isEmpty()) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
KList<CNG> heightNoises = surfaceHeightNoises(surfaceSettings(biome), random);
|
||||
// Ceiling layers reuse the surface-layer height noise, so entries beyond the surface layers have none; skip them.
|
||||
int usableLayers = Math.min(ceilingLayers.size(), heightNoises.size());
|
||||
for (int i = 0; i < usableLayers; i++) {
|
||||
ResolvedLayer layer = resolve(ceilingLayers.get(i));
|
||||
double depth = layerThickness(layer, heightNoises.get(i), wx, wz);
|
||||
if (depth <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
stackLayer(blocks, layer, i, depth, wx, wz, random, maxDepth);
|
||||
if (blocks.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
separateLayers(blocks, dimension, maxDepth);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** The blocks of the biome's sea layers at the column, from the water surface down, at most {@code maxDepth} of them. */
|
||||
public KList<PlatformBlockState> generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, IrisData data) {
|
||||
KList<PlatformBlockState> blocks = new KList<>();
|
||||
SeaLayersSettings settings = biome.getModuleSettings().find(SeaLayersSettings.class).orElse(null);
|
||||
if (settings == null || settings.layers().isEmpty()) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
List<PaletteLayer> layers = settings.layers();
|
||||
KList<CNG> heightNoises = seaHeightNoises(settings, random);
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
ResolvedLayer layer = resolve(layers.get(i));
|
||||
int depth = heightNoises.get(i).fit(layer.minHeight(), layer.maxHeight(), wx / layer.zoom(), wz / layer.zoom());
|
||||
if (depth < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
stackLayer(blocks, layer, i, depth, wx, wz, random, maxDepth);
|
||||
if (blocks.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private KList<PlatformBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthLimit, int height, IrisComplex complex) {
|
||||
KList<PlatformBlockState> stacked = new KList<>();
|
||||
KList<PlatformBlockState> locked = new KList<>();
|
||||
int maxDepth = Math.min(maxDepthLimit, lockedLayersMax(biome));
|
||||
if (maxDepth <= 0) {
|
||||
return stacked;
|
||||
}
|
||||
|
||||
LayersSettings settings = surfaceSettings(biome);
|
||||
List<PaletteLayer> layers = settings.layers();
|
||||
if (!layers.isEmpty()) {
|
||||
KList<CNG> heightNoises = surfaceHeightNoises(settings, random);
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
ResolvedLayer layer = resolve(layers.get(i));
|
||||
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
|
||||
if (depth <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
stackLayerUnlimited(stacked, layer, i, depth, wx, wz, random);
|
||||
}
|
||||
}
|
||||
|
||||
if (stacked.isEmpty()) {
|
||||
return locked;
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxDepth; i++) {
|
||||
int offset = (LOCKED_LAYERS_REFERENCE_HEIGHT - height) - i;
|
||||
locked.add(stacked.get(Math.max(offset % stacked.size(), 0)));
|
||||
}
|
||||
|
||||
return locked;
|
||||
}
|
||||
|
||||
private void stackLayer(KList<PlatformBlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random, int maxDepth) {
|
||||
for (int j = 0; j < depth; j++) {
|
||||
if (blocks.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
addBlock(blocks, layer, index, j, wx, wz, random);
|
||||
}
|
||||
}
|
||||
|
||||
private void stackLayerUnlimited(KList<PlatformBlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random) {
|
||||
for (int j = 0; j < depth; j++) {
|
||||
addBlock(blocks, layer, index, j, wx, wz, random);
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds the layer's block {@code j} blocks down; a layer that fails to pick adds nothing. */
|
||||
private void addBlock(KList<PlatformBlockState> blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) {
|
||||
double zoom = layer.zoom();
|
||||
try {
|
||||
blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** The barrier blocks a dimension puts between layers to show them apart. */
|
||||
private void separateLayers(KList<PlatformBlockState> blocks, IrisDimension dimension, int maxDepth) {
|
||||
if (!dimension.isExplodeBiomePalettes()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < dimension.getExplodeBiomePaletteSize(); j++) {
|
||||
blocks.add(States.BARRIER);
|
||||
if (blocks.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** How thick the layer is at the column: nothing where the slope is outside the layer's limits. */
|
||||
private double layerDepth(ResolvedLayer layer, CNG heightNoise, double wx, double wz, IrisComplex complex) {
|
||||
double depth = layerThickness(layer, heightNoise, wx, wz);
|
||||
SlopeClip slope = layer.slopeCondition();
|
||||
if (!slope.isDefault() && !slope.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
private double layerThickness(ResolvedLayer layer, CNG heightNoise, double wx, double wz) {
|
||||
double zoom = layer.zoom();
|
||||
return heightNoise.fit(layer.minHeight(), layer.maxHeight(), wx / zoom, wz / zoom);
|
||||
}
|
||||
|
||||
private KList<CNG> surfaceHeightNoises(LayersSettings settings, RNG rng) {
|
||||
AtomicCache<KList<CNG>> cache = surfaceHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
|
||||
return heightNoises(cache, settings.layers(), SURFACE_HEIGHT_SEED, rng);
|
||||
}
|
||||
|
||||
private KList<CNG> seaHeightNoises(SeaLayersSettings settings, RNG rng) {
|
||||
AtomicCache<KList<CNG>> cache = seaHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
|
||||
return heightNoises(cache, settings.layers(), SEA_HEIGHT_SEED, rng);
|
||||
}
|
||||
|
||||
private KList<CNG> heightNoises(AtomicCache<KList<CNG>> cache, List<PaletteLayer> layers, int firstSeed, RNG rng) {
|
||||
KList<CNG> cached = cache.getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return cache.aquire(() -> {
|
||||
KList<CNG> noises = new KList<>();
|
||||
int seed = firstSeed;
|
||||
for (PaletteLayer layer : layers) {
|
||||
noises.add(resolve(layer).heightNoise(rng.nextParallelRNG((seed++) * seed * seed * seed)));
|
||||
}
|
||||
return noises;
|
||||
});
|
||||
}
|
||||
|
||||
private static LayersSettings surfaceSettings(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(LayersSettings.class).orElse(DEFAULT_LAYERS);
|
||||
}
|
||||
|
||||
private static boolean isLocked(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(LockLayersSettings.class).map(LockLayersSettings::locked).orElse(false);
|
||||
}
|
||||
|
||||
private static int lockedLayersMax(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(LockLayersMaxSettings.class).map(LockLayersMaxSettings::layers).orElse(LockLayersMaxSettings.DEFAULT_LAYERS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.terrain;
|
||||
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** A palette's blocks as the platform's, the way terrain layers and palettes always picked from them. */
|
||||
final class PaletteBlocks {
|
||||
private PaletteBlocks() {
|
||||
}
|
||||
|
||||
/** The platform's block of each spec that has one, each repeated by its weight. */
|
||||
static List<PlatformBlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
List<PlatformBlockState> weighted = new ArrayList<>();
|
||||
for (BlockSpec spec : palette) {
|
||||
PlatformBlockState state = B.getState(registry.resolve(spec).key());
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
for (int n = 0; n < spec.weight(); n++) {
|
||||
weighted.add(state);
|
||||
}
|
||||
}
|
||||
return List.copyOf(weighted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.terrain.LayerBlocks;
|
||||
import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* One {@link PaletteLayer} made ready for one world: its blocks as the platform's, and the noise that decides how thick
|
||||
* it is here, built when first asked for. Which block it picks where is the world's {@link LayerBlocks}, shared with
|
||||
* every other module that picks from the layer.
|
||||
*
|
||||
* <p>The thickness noise is built once, from the random of whoever asks first, as the layers of a biome always were.
|
||||
*/
|
||||
public final class ResolvedLayer {
|
||||
private final PaletteLayer settings;
|
||||
private final Supplier<LayerBlocks> layerBlocks;
|
||||
private final AtomicCache<List<PlatformBlockState>> blocks = new AtomicCache<>();
|
||||
private final AtomicCache<CNG> heightNoise = new AtomicCache<>();
|
||||
|
||||
private ResolvedLayer(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks) {
|
||||
this.settings = settings;
|
||||
this.layerBlocks = layerBlocks;
|
||||
}
|
||||
|
||||
/** {@code settings} ready for the world whose layer blocks {@code layerBlocks} gives, asked for when first needed. */
|
||||
static ResolvedLayer of(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks) {
|
||||
return new ResolvedLayer(settings, layerBlocks);
|
||||
}
|
||||
|
||||
public PaletteLayer settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public int minHeight() {
|
||||
return settings.minHeight();
|
||||
}
|
||||
|
||||
public int maxHeight() {
|
||||
return settings.maxHeight();
|
||||
}
|
||||
|
||||
public double zoom() {
|
||||
return settings.zoom();
|
||||
}
|
||||
|
||||
public SlopeClip slopeCondition() {
|
||||
return settings.slopeCondition();
|
||||
}
|
||||
|
||||
/** Whether the layer lists any block, which is not the same as picking one: a listed block may have no weight. */
|
||||
public boolean hasPalette() {
|
||||
return !settings.palette().isEmpty();
|
||||
}
|
||||
|
||||
/** The noise that sets the layer's thickness, built from {@code rng} unless an earlier caller's is already kept. */
|
||||
public CNG heightNoise(RNG rng) {
|
||||
CNG cached = heightNoise.getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return heightNoise.aquire(() -> CNG.signature(rng.nextParallelRNG(settings.minHeight() * settings.maxHeight() + blocks().size())));
|
||||
}
|
||||
|
||||
/** The layer's block at the position, picked as {@link LayerBlocks#pick} says, or null when the palette has no block. */
|
||||
public PlatformBlockState get(RNG parent, int signature, double x, double y, double z) {
|
||||
int index = layerBlocks.get().pick(settings, parent, signature, x, y, z);
|
||||
return index == LayerBlocks.NONE ? null : blocks().get(index);
|
||||
}
|
||||
|
||||
/** {@link #get(RNG, int, double, double, double)} for a layer asked once per column, such as a slab or a wall. */
|
||||
public PlatformBlockState get(RNG rng, double x, double y, double z) {
|
||||
return get(rng, 0, x, y, z);
|
||||
}
|
||||
|
||||
private List<PlatformBlockState> blocks() {
|
||||
List<PlatformBlockState> cached = blocks.getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return blocks.aquire(() -> layerBlocks.get().blocks(settings).stream().map(block -> B.getState(block.key())).toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.FluidPaletteSettings;
|
||||
import art.arcane.iris.builtin.terrain.RockPaletteSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* What the terrain module keeps for one world about the palettes that fill its terrain: the rock below the biomes' layers
|
||||
* and the fluid of its oceans and aquifers, as a block for every column, and the rock of an upper dimension. They are the
|
||||
* dimension's {@link RockPaletteSettings} and {@link FluidPaletteSettings}.
|
||||
*
|
||||
* <p>The noise of a palette is seeded from the world's complex seed and a signature of its own, as the complex always did, so
|
||||
* a column's rock and fluid do not depend on who asks first.
|
||||
*/
|
||||
public final class TerrainPalettes {
|
||||
private static final int ROCK_SIGNATURE = 45;
|
||||
private static final int FLUID_SIGNATURE = 78;
|
||||
/** The salt Iris's material palettes always added to the seed of the noise that picks their blocks. */
|
||||
private static final int PALETTE_NOISE_SALT = -23_498_896;
|
||||
|
||||
/** A block for every column. */
|
||||
@FunctionalInterface
|
||||
public interface ColumnBlocks {
|
||||
/** The block at the column, or null when the palette has no block. */
|
||||
PlatformBlockState at(double x, double z);
|
||||
}
|
||||
|
||||
private final Engine engine;
|
||||
private final AtomicCache<ColumnBlocks> rock = new AtomicCache<>();
|
||||
private final AtomicCache<ColumnBlocks> fluid = new AtomicCache<>();
|
||||
private final Map<UpperDimensionContext, ColumnBlocks> upperRocks = new ConcurrentHashMap<>();
|
||||
|
||||
TerrainPalettes(Engine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/** The palettes of the world {@code engine} generates now. */
|
||||
public static TerrainPalettes of(Engine engine) {
|
||||
return engine.getGeneration().state(TerrainPalettes.class, TerrainPalettes::new);
|
||||
}
|
||||
|
||||
/** Builds the rock and fluid noise now instead of when first asked for. */
|
||||
public void warm() {
|
||||
rock();
|
||||
fluid();
|
||||
}
|
||||
|
||||
/** The rock at the column, below the biome's layers. */
|
||||
public PlatformBlockState rockAt(double x, double z) {
|
||||
return rock().at(x, z);
|
||||
}
|
||||
|
||||
/** The fluid at the column, above the terrain up to the fluid height. */
|
||||
public PlatformBlockState fluidAt(double x, double z) {
|
||||
return fluid().at(x, z);
|
||||
}
|
||||
|
||||
/** The rock at the column of the upper dimension: the world's own when the upper dimension is the dimension itself. */
|
||||
public PlatformBlockState upperRockAt(UpperDimensionContext upper, double x, double z) {
|
||||
return upperRocks.computeIfAbsent(upper, this::upperRock).at(x, z);
|
||||
}
|
||||
|
||||
private ColumnBlocks rock() {
|
||||
return rock.aquireOrThrow(() -> columns(rockPalette(engine.getDimension()), complexRng().nextParallelRNG(ROCK_SIGNATURE), engine.getData()));
|
||||
}
|
||||
|
||||
private ColumnBlocks fluid() {
|
||||
return fluid.aquireOrThrow(() -> columns(fluidPalette(engine.getDimension()), complexRng().nextParallelRNG(FLUID_SIGNATURE), engine.getData()));
|
||||
}
|
||||
|
||||
private RNG complexRng() {
|
||||
return new RNG(engine.getSeedManager().getComplex());
|
||||
}
|
||||
|
||||
private ColumnBlocks upperRock(UpperDimensionContext upper) {
|
||||
if (upper.isSelfReferencing()) {
|
||||
return rock();
|
||||
}
|
||||
|
||||
long seedOffset = upper.getDimension().getLoadKey().hashCode();
|
||||
RNG rng = new RNG(engine.getSeedManager().getComplex() ^ seedOffset);
|
||||
return columns(rockPalette(upper.getDimension()), rng.nextParallelRNG(ROCK_SIGNATURE), upper.getData());
|
||||
}
|
||||
|
||||
private static PaletteSpec rockPalette(IrisDimension dimension) {
|
||||
return dimension.getModuleSettings().find(RockPaletteSettings.class).orElseGet(RockPaletteSettings::new).palette();
|
||||
}
|
||||
|
||||
private static PaletteSpec fluidPalette(IrisDimension dimension) {
|
||||
return dimension.getModuleSettings().find(FluidPaletteSettings.class).orElseGet(FluidPaletteSettings::new).palette();
|
||||
}
|
||||
|
||||
/** The palette's blocks over the columns, picked by its noise: the noise at a column, from 0 to 1, is how far down the weighted list the block is. */
|
||||
private static ColumnBlocks columns(PaletteSpec palette, RNG rng, IrisData data) {
|
||||
IrisPackResources resources = data.getPackResources();
|
||||
List<PlatformBlockState> blocks = PaletteBlocks.weighted(resources.blocks(), palette.palette());
|
||||
if (blocks.isEmpty()) {
|
||||
return (x, z) -> null;
|
||||
}
|
||||
|
||||
long seed = rng.getSeed() + (PALETTE_NOISE_SALT + blocks.size());
|
||||
NoiseSampler noise = resources.noise().sampler(palette.style(), seed);
|
||||
int last = blocks.size() - 1;
|
||||
return (x, z) -> blocks.get((int) Math.round(noise.sample(x, z) * last));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user