mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Move decoration runtime state into the pack runtime
- Add decorator and deposit runtimes and ore chance seed tables to the pack runtime - Pass the pack runtime through decorator sampling, decorator placement and hydrology vegetation - Resolve the pack runtime once per column in the engine decorators - Pass the pack runtime to ore generation and deposit clump lookups - Remove the decorator, ore chance and deposit clump caches and their keys - Cover deposit clump scoping with a runtime test in place of the key test
This commit is contained in:
1 parent
1a93918b82
commit
4f084a7d7a
47 files changed
+637
-481
No files matched your search
@@ -257,16 +257,16 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
return IrisBiomeOres.canReplaceSurfaceOre(this, state);
|
||||
}
|
||||
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
return IrisBiomeOres.generateOres(this, x, y, z, rng, data, surface);
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, PackRuntime runtime, boolean surface) {
|
||||
return IrisBiomeOres.generateOres(this, x, y, z, rng, runtime, surface);
|
||||
}
|
||||
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return IrisBiomeOres.generateSurfaceOres(this, x, y, z, rng, data);
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return IrisBiomeOres.generateSurfaceOres(this, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return IrisBiomeOres.generateUndergroundOres(this, x, y, z, rng, data);
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return IrisBiomeOres.generateUndergroundOres(this, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public boolean hasSurfaceOres() {
|
||||
|
||||
@@ -22,7 +22,7 @@ import art.arcane.iris.generation.decoration.IrisOreGenerator;
|
||||
import art.arcane.iris.generation.decoration.IrisOreBands;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.iris.generation.block.B;
|
||||
@@ -39,17 +39,17 @@ final class IrisBiomeOres {
|
||||
private IrisBiomeOres() {
|
||||
}
|
||||
|
||||
static NativeBlockState generateOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
static NativeBlockState generateOres(IrisBiome biome, int x, int y, int z, RNG rng, PackRuntime runtime, boolean surface) {
|
||||
KList<IrisOreGenerator> localOres = surface ? getSurfaceOres(biome) : getUndergroundOres(biome);
|
||||
return generateOres(localOres, x, y, z, rng, data);
|
||||
return generateOres(localOres, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
static NativeBlockState generateSurfaceOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getSurfaceOres(biome), x, y, z, rng, data);
|
||||
static NativeBlockState generateSurfaceOres(IrisBiome biome, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getSurfaceOres(biome), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
static NativeBlockState generateUndergroundOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getUndergroundOres(biome), x, y, z, rng, data);
|
||||
static NativeBlockState generateUndergroundOres(IrisBiome biome, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getUndergroundOres(biome), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
static boolean hasSurfaceOres(IrisBiome biome) {
|
||||
@@ -122,7 +122,7 @@ final class IrisBiomeOres {
|
||||
});
|
||||
}
|
||||
|
||||
private static NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, IrisData data) {
|
||||
private static NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
if (localOres.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ final class IrisBiomeOres {
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, runtime);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.GenerationFailures;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.mantle.EngineMantle;
|
||||
@@ -92,7 +93,7 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
static IrisDecorator pickDecorator(IrisBiome biome, IrisDecorationPart part, RNG gRNG,
|
||||
RNG colRng, IrisData data, double realX, double realZ) {
|
||||
RNG colRng, PackRuntime runtime, double realX, double realZ) {
|
||||
IrisDecorator[] bucket = biome.getDecoratorBucket(part);
|
||||
if (bucket.length == 0) {
|
||||
return null;
|
||||
@@ -103,14 +104,14 @@ final class DecoratorCore {
|
||||
|
||||
for (IrisDecorator d : bucket) {
|
||||
try {
|
||||
if (d.passesChanceGate(gRNG, realX, realZ, data)) {
|
||||
if (d.passesChanceGate(gRNG, realX, realZ, runtime)) {
|
||||
count++;
|
||||
if (count == 1 || colRng.nextInt(count) == 0) {
|
||||
picked = d;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
skip(e, d, data, (int) realX, -1, (int) realZ, biome);
|
||||
skip(e, d, runtime.data(), (int) realX, -1, (int) realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,14 +120,14 @@ final class DecoratorCore {
|
||||
|
||||
static void placeSurfaceSingle(IrisDecorator decorator,
|
||||
int x, int z, int realX, int height, int realZ,
|
||||
Hunk<NativeBlockState> data, RNG rng, IrisData irisData,
|
||||
Hunk<NativeBlockState> data, RNG rng, PackRuntime runtime,
|
||||
boolean underwater, boolean caveSkipFluid, EngineMantle mantle) {
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBlockState bdx = data.get(x, height, z);
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
|
||||
if (!IrisSpeleothems.isSpike(bd) && !underwater && !canGoOn(bd, bdx)
|
||||
&& !decorator.isForcePlace() && decorator.getForceBlock() == null) {
|
||||
@@ -138,14 +139,14 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
data.set(x, height, z, fixFacesForHunk(
|
||||
decorator.getForceBlock().getBlockData(irisData), data, x, z, realX, height, realZ, mantle));
|
||||
decorator.getForceBlock().getBlockData(runtime.data()), data, x, z, realX, height, realZ, mantle));
|
||||
}
|
||||
|
||||
if (!decorator.isForcePlace()) {
|
||||
if (decorator.getWhitelist() != null && !matchesPalette(decorator.getWhitelistArray(irisData), bdx)) {
|
||||
if (decorator.getWhitelist() != null && !matchesPalette(decorator.getWhitelistArray(runtime.data()), bdx)) {
|
||||
return;
|
||||
}
|
||||
if (decorator.getBlacklist() != null && matchesPalette(decorator.getBlacklistArray(irisData), bdx)) {
|
||||
if (decorator.getBlacklist() != null && matchesPalette(decorator.getBlacklistArray(runtime.data()), bdx)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -176,7 +177,7 @@ final class DecoratorCore {
|
||||
data.set(x, lowerY, z, lower);
|
||||
data.set(x, upperY, z, IrisProceduralBlocks.normalizeWaterlogging(upper, data.get(x, upperY, z), true));
|
||||
} catch (Throwable e) {
|
||||
skip(e, decorator, irisData, realX, lowerY, realZ, null);
|
||||
skip(e, decorator, runtime.data(), realX, lowerY, realZ, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -202,8 +203,8 @@ final class DecoratorCore {
|
||||
|
||||
static void placeSingleAt(IrisDecorator decorator, int x, int z,
|
||||
int realX, int height, int realZ, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, boolean applyFixFaces, EngineMantle mantle) {
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
RNG rng, PackRuntime runtime, boolean applyFixFaces, EngineMantle mantle) {
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
@@ -212,7 +213,7 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
if (IrisSpeleothems.isSpike(bd)) {
|
||||
if (height + 1 < data.getHeight() && allowsSurface(decorator, data.get(x, height + 1, z), irisData)) {
|
||||
if (height + 1 < data.getHeight() && allowsSurface(decorator, data.get(x, height + 1, z), runtime.data())) {
|
||||
placeSingleSpike(bd, data, x, z, height, false, false);
|
||||
}
|
||||
return;
|
||||
@@ -225,17 +226,17 @@ final class DecoratorCore {
|
||||
|
||||
static void placeStackUp(IrisDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int max, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, PlaceOpts opts) {
|
||||
RNG rng, PackRuntime runtime, PlaceOpts opts) {
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBlockState support = data.get(x, height, z);
|
||||
if (!allowsSurface(decorator, support, irisData)) {
|
||||
if (!allowsSurface(decorator, support, runtime.data())) {
|
||||
return;
|
||||
}
|
||||
int effectiveMax = opts.underwater ? Math.min(max, opts.fluidHeight - height) : max;
|
||||
int stack = computeStack(decorator, rng, realX, realZ, irisData, effectiveMax);
|
||||
int stack = computeStack(decorator, rng, realX, realZ, runtime, effectiveMax);
|
||||
int placed = 0;
|
||||
boolean hasSpikes = false;
|
||||
NativeBlockState sampledBlock = null;
|
||||
@@ -254,8 +255,8 @@ final class DecoratorCore {
|
||||
boolean top = threshold >= decorator.getTopThreshold();
|
||||
if (sampledBlock == null || top != sampledTop) {
|
||||
sampledBlock = top
|
||||
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
|
||||
: decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
? decorator.pickBlockDataTop(rng, runtime, realX, realZ)
|
||||
: decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState block = sampledBlock;
|
||||
@@ -288,15 +289,15 @@ final class DecoratorCore {
|
||||
|
||||
static void placeStackDown(IrisDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int minHeight, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, int max, PlaceOpts opts, EngineMantle mantle) {
|
||||
RNG rng, PackRuntime runtime, int max, PlaceOpts opts, EngineMantle mantle) {
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState support = height + 1 < data.getHeight() ? data.get(x, height + 1, z) : null;
|
||||
if (!allowsSurface(decorator, support, irisData)) {
|
||||
if (!allowsSurface(decorator, support, runtime.data())) {
|
||||
return;
|
||||
}
|
||||
int stack = computeStack(decorator, rng, realX, realZ, irisData, max);
|
||||
int stack = computeStack(decorator, rng, realX, realZ, runtime, max);
|
||||
int placed = 0;
|
||||
boolean hasSpikes = false;
|
||||
NativeBlockState sampledBlock = null;
|
||||
@@ -315,8 +316,8 @@ final class DecoratorCore {
|
||||
boolean top = threshold >= decorator.getTopThreshold();
|
||||
if (sampledBlock == null || top != sampledTop) {
|
||||
sampledBlock = top
|
||||
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
|
||||
: decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
? decorator.pickBlockDataTop(rng, runtime, realX, realZ)
|
||||
: decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState block = sampledBlock;
|
||||
@@ -349,11 +350,11 @@ final class DecoratorCore {
|
||||
static void placeFloatingSimple(IrisDecorator decorator,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, EngineMantle mantle) {
|
||||
RNG rng, PackRuntime runtime, EngineMantle mantle) {
|
||||
if (!hasFloatingSurface(data, xf, height, zf)) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
@@ -363,7 +364,7 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
if (IrisSpeleothems.isSpike(bd)) {
|
||||
if (max > 1 && allowsSurface(decorator, data.get(xf, height, zf), irisData)) {
|
||||
if (max > 1 && allowsSurface(decorator, data.get(xf, height, zf), runtime.data())) {
|
||||
placeSingleSpike(bd, data, xf, zf, height + 1, true, false);
|
||||
}
|
||||
return;
|
||||
@@ -383,7 +384,7 @@ final class DecoratorCore {
|
||||
data.set(xf, lowerY, zf, IrisProceduralBlocks.normalizeWaterlogging(lower, data.get(xf, lowerY, zf), true));
|
||||
data.set(xf, upperY, zf, IrisProceduralBlocks.normalizeWaterlogging(upper, data.get(xf, upperY, zf), true));
|
||||
} catch (Throwable e) {
|
||||
skip(e, decorator, irisData, realX, lowerY, realZ, null);
|
||||
skip(e, decorator, runtime.data(), realX, lowerY, realZ, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -396,11 +397,11 @@ final class DecoratorCore {
|
||||
static int placeFloatingStacked(IrisDecorator decorator,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, EngineMantle mantle) {
|
||||
RNG rng, PackRuntime runtime, EngineMantle mantle) {
|
||||
if (!hasFloatingSurface(data, xf, height, zf)) {
|
||||
return 0;
|
||||
}
|
||||
int stack = decorator.getHeight(rng, realX, realZ, irisData);
|
||||
int stack = decorator.getHeight(rng, realX, realZ, runtime);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
|
||||
} else {
|
||||
@@ -420,8 +421,8 @@ final class DecoratorCore {
|
||||
boolean top = threshold >= decorator.getTopThreshold();
|
||||
if (sampledBlock == null || top != sampledTop) {
|
||||
sampledBlock = top
|
||||
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
|
||||
: decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
? decorator.pickBlockDataTop(rng, runtime, realX, realZ)
|
||||
: decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState bd = sampledBlock;
|
||||
@@ -433,7 +434,7 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
if (IrisSpeleothems.isSpike(bd)) {
|
||||
if (!allowsSurface(decorator, data.get(xf, height, zf), irisData)
|
||||
if (!allowsSurface(decorator, data.get(xf, height, zf), runtime.data())
|
||||
|| !IrisSpeleothems.canPlace(bd, data, xf, zf, h, true, false)) {
|
||||
break;
|
||||
}
|
||||
@@ -581,8 +582,8 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
static int computeStack(IrisDecorator decorator, RNG rng, double realX, double realZ,
|
||||
IrisData irisData, int max) {
|
||||
int stack = decorator.getHeight(rng, realX, realZ, irisData);
|
||||
PackRuntime runtime, int max) {
|
||||
int stack = decorator.getHeight(rng, realX, realZ, runtime);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
|
||||
/** What one engine derives from an {@link IrisDecorator}: the stack, placement and variance generators of each seed. */
|
||||
public final class DecoratorRuntime {
|
||||
private static final int SEED_CAPACITY = 32;
|
||||
|
||||
private final SeedTable<CNG> heightGenerators;
|
||||
private final SeedTable<CNG> layerGenerators;
|
||||
private final SeedTable<CNG> varianceGenerators;
|
||||
|
||||
public DecoratorRuntime(IrisDecorator decorator, PackRuntime runtime) {
|
||||
this.heightGenerators = new SeedTable<>(SEED_CAPACITY, seed -> decorator.createHeightGenerator(seed, runtime));
|
||||
this.layerGenerators = new SeedTable<>(SEED_CAPACITY, seed -> decorator.createLayerGenerator(seed, runtime));
|
||||
this.varianceGenerators = new SeedTable<>(SEED_CAPACITY, seed -> decorator.createVarianceGenerator(seed, runtime));
|
||||
}
|
||||
|
||||
public CNG heightGenerator(long seed) {
|
||||
return heightGenerators.get(seed);
|
||||
}
|
||||
|
||||
public CNG layerGenerator(long seed) {
|
||||
return layerGenerators.get(seed);
|
||||
}
|
||||
|
||||
public CNG varianceGenerator(long seed) {
|
||||
return varianceGenerators.get(seed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
/**
|
||||
* What one engine derives from an {@link IrisDepositGenerator}: the clump variants of the engine's deposit seed, at
|
||||
* the configured size and at each scaled size the deposit modifier asks for.
|
||||
*/
|
||||
public final class DepositRuntime {
|
||||
private static final int SCALED_SIZE_CAPACITY = 64;
|
||||
|
||||
private final IrisDepositGenerator deposit;
|
||||
private final PackRuntime runtime;
|
||||
private final long depositSeed;
|
||||
private final SeedTable<KList<IrisObject>> scaledClumps;
|
||||
private volatile KList<IrisObject> clumps;
|
||||
|
||||
public DepositRuntime(IrisDepositGenerator deposit, PackRuntime runtime) {
|
||||
this.deposit = deposit;
|
||||
this.runtime = runtime;
|
||||
this.depositSeed = runtime.engine().getSeedManager().getDeposit();
|
||||
this.scaledClumps = new SeedTable<>(SCALED_SIZE_CAPACITY, sizes -> deposit.createScaledClumps(
|
||||
depositSeed, minSize(sizes), maxSize(sizes), runtime.data()));
|
||||
}
|
||||
|
||||
public KList<IrisObject> clumps() {
|
||||
KList<IrisObject> built = clumps;
|
||||
if (built != null) {
|
||||
return built;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (clumps == null) {
|
||||
clumps = deposit.createClumps(depositSeed, runtime.data());
|
||||
}
|
||||
return clumps;
|
||||
}
|
||||
}
|
||||
|
||||
public KList<IrisObject> scaledClumps(int minSize, int maxSize) {
|
||||
return scaledClumps.get(sizeKey(minSize, maxSize));
|
||||
}
|
||||
|
||||
private static long sizeKey(int minSize, int maxSize) {
|
||||
return ((long) minSize << 32) | (maxSize & 0xffffffffL);
|
||||
}
|
||||
|
||||
private static int minSize(long sizeKey) {
|
||||
return (int) (sizeKey >>> 32);
|
||||
}
|
||||
|
||||
private static int maxSize(long sizeKey) {
|
||||
return (int) sizeKey;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -36,7 +37,8 @@ public class FloatingDecorator {
|
||||
int height, int max, Hunk<NativeBlockState> data, RNG rng,
|
||||
Runnable candidatesNullCallback) {
|
||||
RNG gRNG = new RNG(DecoratorCore.partSeed(engine.getSeedManager().getComponent(), part));
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(target, part, gRNG, rng, engine.getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(engine);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(target, part, gRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
candidatesNullCallback.run();
|
||||
@@ -45,11 +47,11 @@ public class FloatingDecorator {
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data,
|
||||
gRNG, engine.getData(), engine.getMantle());
|
||||
gRNG, runtime, engine.getMantle());
|
||||
return max > 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
return DecoratorCore.placeFloatingStacked(decorator, xf, zf, realX, realZ, height, max, data,
|
||||
gRNG, engine.getData(), engine.getMantle());
|
||||
gRNG, runtime, engine.getMantle());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.block.B;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
@@ -32,7 +33,7 @@ public final class HydrologyVegetation {
|
||||
this.shoreRng = new RNG(DecoratorCore.partSeed(this.seed, IrisDecorationPart.SHORE_LINE));
|
||||
}
|
||||
|
||||
public void decorate(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, WaterRole role, Water water, IrisData data) {
|
||||
public void decorate(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, WaterRole role, Water water, PackRuntime runtime) {
|
||||
Placement placement = placement(role);
|
||||
if (placement == Placement.NONE) {
|
||||
return;
|
||||
@@ -45,7 +46,7 @@ public final class HydrologyVegetation {
|
||||
if (ground < 0 || ground + 1 >= output.getHeight()) {
|
||||
return;
|
||||
}
|
||||
Column column = new Column(output, localX, localZ, x, z, ground, water, data);
|
||||
Column column = new Column(output, localX, localZ, x, z, ground, water, runtime);
|
||||
if (placement == Placement.SHORE) {
|
||||
decorateShore(column, decorators.shore);
|
||||
return;
|
||||
@@ -112,7 +113,7 @@ public final class HydrologyVegetation {
|
||||
int count = 0;
|
||||
for (IrisDecorator decorator : bucket) {
|
||||
try {
|
||||
if (!decorator.passesChanceGate(partRng, column.x, column.z, column.data)) {
|
||||
if (!decorator.passesChanceGate(partRng, column.x, column.z, column.runtime)) {
|
||||
continue;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -213,9 +214,10 @@ public final class HydrologyVegetation {
|
||||
private final int z;
|
||||
private final int ground;
|
||||
private final Water water;
|
||||
private final PackRuntime runtime;
|
||||
private final IrisData data;
|
||||
|
||||
private Column(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, int ground, Water water, IrisData data) {
|
||||
private Column(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, int ground, Water water, PackRuntime runtime) {
|
||||
this.output = output;
|
||||
this.localX = localX;
|
||||
this.localZ = localZ;
|
||||
@@ -223,7 +225,8 @@ public final class HydrologyVegetation {
|
||||
this.z = z;
|
||||
this.ground = ground;
|
||||
this.water = water;
|
||||
this.data = data;
|
||||
this.runtime = runtime;
|
||||
this.data = runtime.data();
|
||||
}
|
||||
|
||||
private boolean accepts(IrisDecorator decorator, NativeBlockState support) {
|
||||
@@ -231,7 +234,7 @@ public final class HydrologyVegetation {
|
||||
}
|
||||
|
||||
private int stack(IrisDecorator decorator, RNG rng, int room) {
|
||||
return decorator.isStacking() ? Math.min(room, DecoratorCore.computeStack(decorator, rng, x, z, data, room)) : 1;
|
||||
return decorator.isStacking() ? Math.min(room, DecoratorCore.computeStack(decorator, rng, x, z, runtime, room)) : 1;
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, RNG rng, int baseY, int room, Slot slot, NativeBlockState support) {
|
||||
@@ -243,7 +246,7 @@ public final class HydrologyVegetation {
|
||||
}
|
||||
|
||||
private void placePicked(IrisDecorator decorator, RNG rng, int baseY, int room, Slot slot, NativeBlockState support) {
|
||||
NativeBlockState first = decorator.pickBlockData(rng, data, x, z);
|
||||
NativeBlockState first = decorator.pickBlockData(rng, runtime, x, z);
|
||||
if (first == null) {
|
||||
return;
|
||||
}
|
||||
@@ -260,7 +263,7 @@ public final class HydrologyVegetation {
|
||||
int y = baseY + index;
|
||||
boolean top = (stack == 1 ? 1D : (double) index / (stack - 1)) >= decorator.getTopThreshold();
|
||||
if (top != sampledTop) {
|
||||
sampled = top ? decorator.pickBlockDataTop(rng, data, x, z) : decorator.pickBlockData(rng, data, x, z);
|
||||
sampled = top ? decorator.pickBlockDataTop(rng, runtime, x, z) : decorator.pickBlockData(rng, runtime, x, z);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState block = sampled == null ? null : fit(sampled, y, slot, decorator, index == 0 ? support : null);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.terrain.InferredType;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
@@ -47,21 +48,22 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
Hunk<NativeBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
|
||||
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, height, max, caveSkipFluid);
|
||||
place(decorator, x, z, realX, realZ, data, height, max, caveSkipFluid, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
int height, int max, boolean caveSkipFluid) {
|
||||
int height, int max, boolean caveSkipFluid, PackRuntime runtime) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (caveSkipFluid) {
|
||||
NativeBlockState state = data.get(x, height, z);
|
||||
@@ -69,13 +71,13 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
}
|
||||
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, partRNG, getData(), true, getEngine().getMantle());
|
||||
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, partRNG, runtime, true, getEngine().getMantle());
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.PlaceOpts opts = DecoratorCore.SCRATCH_OPTS.get();
|
||||
opts.reset();
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, partRNG, getData(), max, opts, getEngine().getMantle());
|
||||
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, partRNG, runtime, max, opts, getEngine().getMantle());
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ package art.arcane.iris.generation.decoration;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -53,8 +52,6 @@ import lombok.experimental.Accessors;
|
||||
@Description("A biome decorator is used for placing flowers, grass, cacti and so on")
|
||||
@Data
|
||||
public class IrisDecorator {
|
||||
private final transient LazyBoundedCache<GeneratorKey, Generators> generators = new LazyBoundedCache<>(32);
|
||||
private transient volatile Generators recentGenerators;
|
||||
private final transient AtomicCache<KList<NativeBlockState>> blockData = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<NativeBlockState>> blockDataTops = new AtomicCache<>();
|
||||
private final transient AtomicCache<NativeBlockState[]> blockDataArray = new AtomicCache<>();
|
||||
@@ -119,50 +116,39 @@ public class IrisDecorator {
|
||||
@Description("When the stack passes the top threshold, the top palette will start being used instead of the normal palette.")
|
||||
private double topThreshold = 1.0;
|
||||
|
||||
public int getHeight(RNG rng, double x, double z, IrisData data) {
|
||||
public int getHeight(RNG rng, double x, double z, PackRuntime runtime) {
|
||||
if (stackMin == stackMax) {
|
||||
return stackMin;
|
||||
}
|
||||
|
||||
return getHeightGenerator(rng, data)
|
||||
return getHeightGenerator(rng, runtime)
|
||||
.fit(stackMin, stackMax,
|
||||
x / heightVariance.getZoom(),
|
||||
z / heightVariance.getZoom());
|
||||
}
|
||||
|
||||
public CNG getHeightGenerator(RNG rng, IrisData data) {
|
||||
AtomicCache<CNG> cache = generators(rng, data).height;
|
||||
CNG cached = cache.getIfPresent();
|
||||
return cached != null ? cached : cache.aquire(() ->
|
||||
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), PackRuntime.forContext(data)));
|
||||
public CNG getHeightGenerator(RNG rng, PackRuntime runtime) {
|
||||
return runtime.decorator(this).heightGenerator(rng.getSeed());
|
||||
}
|
||||
|
||||
public CNG getGenerator(RNG rng, IrisData data) {
|
||||
AtomicCache<CNG> cache = generators(rng, data).layer;
|
||||
CNG cached = cache.getIfPresent();
|
||||
return cached != null ? cached : cache.aquire(() -> style.create(rng.nextParallelRNG(getBlockData(data).size()), PackRuntime.forContext(data)));
|
||||
public CNG getGenerator(RNG rng, PackRuntime runtime) {
|
||||
return runtime.decorator(this).layerGenerator(rng.getSeed());
|
||||
}
|
||||
|
||||
public CNG getVarianceGenerator(RNG rng, IrisData data) {
|
||||
AtomicCache<CNG> cache = generators(rng, data).variance;
|
||||
CNG cached = cache.getIfPresent();
|
||||
return cached != null ? cached : cache.aquire(() -> createVarianceGenerator(rng, data));
|
||||
public CNG getVarianceGenerator(RNG rng, PackRuntime runtime) {
|
||||
return runtime.decorator(this).varianceGenerator(rng.getSeed());
|
||||
}
|
||||
|
||||
private Generators generators(RNG rng, IrisData data) {
|
||||
long seed = rng.getSeed();
|
||||
Engine engine = data == null ? null : data.getEngine();
|
||||
Generators recent = recentGenerators;
|
||||
if (recent != null && recent.key.seed == seed && recent.key.data == data && recent.key.engine == engine) {
|
||||
return recent;
|
||||
}
|
||||
Generators selected = generators.computeIfAbsent(new GeneratorKey(seed, data, engine), Generators::new);
|
||||
recentGenerators = selected;
|
||||
return selected;
|
||||
public CNG createHeightGenerator(long seed, PackRuntime runtime) {
|
||||
return heightVariance.create(new RNG(seed).nextParallelRNG(getBlockData(runtime.data()).size() + stackMax + stackMin), runtime);
|
||||
}
|
||||
|
||||
private CNG createVarianceGenerator(RNG rng, IrisData data) {
|
||||
return variance.createNoCache(deriveVarianceSeed(rng, data), PackRuntime.forContext(data)).scale(1D / variance.getZoom());
|
||||
public CNG createLayerGenerator(long seed, PackRuntime runtime) {
|
||||
return style.create(new RNG(seed).nextParallelRNG(getBlockData(runtime.data()).size()), runtime);
|
||||
}
|
||||
|
||||
public CNG createVarianceGenerator(long seed, PackRuntime runtime) {
|
||||
return variance.createNoCache(deriveVarianceSeed(new RNG(seed), runtime.data()), runtime).scale(1D / variance.getZoom());
|
||||
}
|
||||
|
||||
RNG deriveVarianceSeed(RNG rng, IrisData data) {
|
||||
@@ -174,27 +160,27 @@ public class IrisDecorator {
|
||||
return palette;
|
||||
}
|
||||
|
||||
public boolean passesChanceGate(RNG rng, double x, double z, IrisData data) {
|
||||
if (getBlockData(data).isEmpty()) {
|
||||
public boolean passesChanceGate(RNG rng, double x, double z, PackRuntime runtime) {
|
||||
if (getBlockData(runtime.data()).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
return getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance;
|
||||
return getGenerator(rng, runtime).fitDouble(0D, 1D, xx, zz) <= chance;
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockData(IrisBiome b, RNG rng, double x, double z, IrisData data) {
|
||||
if (!passesChanceGate(rng, x, z, data)) {
|
||||
public NativeBlockState getBlockData(IrisBiome b, RNG rng, double x, double z, PackRuntime runtime) {
|
||||
if (!passesChanceGate(rng, x, z, runtime)) {
|
||||
return null;
|
||||
}
|
||||
if (getBlockData(data).size() == 1) {
|
||||
return getBlockData(data).get(0);
|
||||
if (getBlockData(runtime.data()).size() == 1) {
|
||||
return getBlockData(runtime.data()).get(0);
|
||||
}
|
||||
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x);
|
||||
return getVarianceGenerator(rng, runtime).fit(getBlockData(runtime.data()), z, x);
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
|
||||
KList<NativeBlockState> palette = getBlockData(data);
|
||||
public NativeBlockState getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, PackRuntime runtime) {
|
||||
KList<NativeBlockState> palette = getBlockData(runtime.data());
|
||||
if (palette.isEmpty()) {
|
||||
IrisLogging.warnOnce("decorator-empty:" + b.getName(), "Empty Block Data for " + b.getName());
|
||||
return null;
|
||||
@@ -204,24 +190,24 @@ public class IrisDecorator {
|
||||
return palette.get(0);
|
||||
}
|
||||
|
||||
return getVarianceGenerator(rng, data).fit(palette, z, y, x); //X and Z must be switched
|
||||
return getVarianceGenerator(rng, runtime).fit(palette, z, y, x); //X and Z must be switched
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
|
||||
KList<NativeBlockState> topPalette = getBlockDataTops(data);
|
||||
public NativeBlockState getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, PackRuntime runtime) {
|
||||
KList<NativeBlockState> topPalette = getBlockDataTops(runtime.data());
|
||||
if (topPalette.isEmpty()) {
|
||||
return getBlockData100(b, rng, x, y, z, data);
|
||||
return getBlockData100(b, rng, x, y, z, runtime);
|
||||
}
|
||||
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
|
||||
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||
if (getGenerator(rng, runtime).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||
if (topPalette.size() == 1) {
|
||||
return topPalette.get(0);
|
||||
}
|
||||
|
||||
return getVarianceGenerator(rng, data).fit(topPalette, z, y, x); //X and Z must be switched
|
||||
return getVarianceGenerator(rng, runtime).fit(topPalette, z, y, x); //X and Z must be switched
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -337,55 +323,30 @@ public class IrisDecorator {
|
||||
return resolved;
|
||||
}
|
||||
|
||||
public NativeBlockState pickBlockData(RNG rng, IrisData data, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataArray(data);
|
||||
public NativeBlockState pickBlockData(RNG rng, PackRuntime runtime, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataArray(runtime.data());
|
||||
if (arr.length == 0) {
|
||||
return null;
|
||||
}
|
||||
if (arr.length == 1) {
|
||||
return arr[0];
|
||||
}
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, data).fit(0, arr.length - 1, z, x))];
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, runtime).fit(0, arr.length - 1, z, x))];
|
||||
}
|
||||
|
||||
public NativeBlockState pickBlockDataTop(RNG rng, IrisData data, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataTopsArray(data);
|
||||
public NativeBlockState pickBlockDataTop(RNG rng, PackRuntime runtime, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataTopsArray(runtime.data());
|
||||
if (arr.length == 0) {
|
||||
return pickBlockData(rng, data, x, z);
|
||||
return pickBlockData(rng, runtime, x, z);
|
||||
}
|
||||
if (arr.length == 1) {
|
||||
return arr[0];
|
||||
}
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, data).fit(0, arr.length - 1, z, x))];
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, runtime).fit(0, arr.length - 1, z, x))];
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean isStacking() {
|
||||
return getStackMax() > 1;
|
||||
}
|
||||
|
||||
private static final class Generators {
|
||||
private final GeneratorKey key;
|
||||
private final AtomicCache<CNG> layer = new AtomicCache<>();
|
||||
private final AtomicCache<CNG> variance = new AtomicCache<>();
|
||||
private final AtomicCache<CNG> height = new AtomicCache<>();
|
||||
|
||||
private Generators(GeneratorKey key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
private record GeneratorKey(long seed, IrisData data, Engine engine) {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof GeneratorKey key
|
||||
&& seed == key.seed && data == key.data && engine == key.engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (31 * Long.hashCode(seed) + System.identityHashCode(data))
|
||||
+ System.identityHashCode(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
-37
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
@@ -62,12 +63,10 @@ public class IrisDepositGenerator {
|
||||
private static final long FNV_OFFSET_BASIS = 0xcbf29ce484222325L;
|
||||
private static final long FNV_PRIME = 0x100000001b3L;
|
||||
|
||||
private final transient ConcurrentMap<ClumpCacheKey, KList<IrisObject>> objects = new ConcurrentHashMap<>();
|
||||
private final transient AtomicCache<KList<NativeBlockState>> blockData = new AtomicCache<>();
|
||||
private final transient AtomicCache<Boolean> ore = new AtomicCache<>();
|
||||
private final transient AtomicCache<KSet<String>> replaceableBlockData = new AtomicCache<>();
|
||||
private final transient AtomicCache<KSet<String>> surfaceReplaceableBlockData = new AtomicCache<>();
|
||||
private final transient ConcurrentMap<ClumpCacheKey, KList<IrisObject>> scaledObjects = new ConcurrentHashMap<>();
|
||||
@Required
|
||||
@MinNumber(-8192)
|
||||
@MaxNumber(8192)
|
||||
@@ -145,54 +144,47 @@ public class IrisDepositGenerator {
|
||||
@Description("If set to true, this deposit will replace bedrock")
|
||||
private boolean replaceBedrock = false;
|
||||
|
||||
public IrisObject getClump(Engine engine, RNG rng, IrisData rdata) {
|
||||
public IrisObject getClump(PackRuntime runtime, RNG rng) {
|
||||
if (shape != IrisDepositShape.IRIS) {
|
||||
return generateConfiguredClumpObject(rng, rdata, minSize, maxSize);
|
||||
return generateConfiguredClumpObject(rng, runtime.data(), minSize, maxSize);
|
||||
}
|
||||
|
||||
ClumpCacheKey cacheKey = new ClumpCacheKey(engine.getSeedManager().getDeposit(), minSize, maxSize);
|
||||
KList<IrisObject> objects = this.objects.computeIfAbsent(cacheKey, key -> {
|
||||
RNG rngv = new RNG(key.depositSeed() + stableClumpSalt(rdata));
|
||||
KList<IrisObject> objectsf = new KList<>();
|
||||
|
||||
for (int i = 0; i < varience; i++) {
|
||||
objectsf.add(generateClumpObject(
|
||||
rngv.nextParallelRNG(2349 * i + 3598), rdata, key.minSize(), key.maxSize()));
|
||||
}
|
||||
|
||||
return objectsf;
|
||||
});
|
||||
KList<IrisObject> objects = runtime.deposit(this).clumps();
|
||||
return objects.get(rng.i(0, objects.size()));
|
||||
}
|
||||
|
||||
public IrisObject getClump(Engine engine, RNG rng, IrisData rdata, double sizeMultiplier) {
|
||||
public IrisObject getClump(PackRuntime runtime, RNG rng, double sizeMultiplier) {
|
||||
if (sizeMultiplier == 1D) {
|
||||
return getClump(engine, rng, rdata);
|
||||
return getClump(runtime, rng);
|
||||
}
|
||||
|
||||
int scaledMinSize = scaledDepositSize(minSize, sizeMultiplier);
|
||||
int scaledMaxSize = scaledDepositSize(maxSize, sizeMultiplier);
|
||||
if (shape != IrisDepositShape.IRIS) {
|
||||
return generateConfiguredClumpObject(rng, rdata, scaledMinSize, scaledMaxSize);
|
||||
return generateConfiguredClumpObject(rng, runtime.data(), scaledMinSize, scaledMaxSize);
|
||||
}
|
||||
|
||||
ClumpCacheKey cacheKey = new ClumpCacheKey(
|
||||
engine.getSeedManager().getDeposit(), scaledMinSize, scaledMaxSize);
|
||||
KList<IrisObject> objects = scaledObjects.computeIfAbsent(cacheKey, key -> {
|
||||
long sizeSeed = ((long) key.minSize() << 32) ^ (key.maxSize() & 0xffffffffL);
|
||||
RNG rngv = new RNG(key.depositSeed() + stableClumpSalt(rdata) + sizeSeed);
|
||||
KList<IrisObject> generated = new KList<>();
|
||||
|
||||
for (int i = 0; i < varience; i++) {
|
||||
generated.add(generateClumpObject(
|
||||
rngv.nextParallelRNG(2349 * i + 3598), rdata, key.minSize(), key.maxSize()));
|
||||
}
|
||||
|
||||
return generated;
|
||||
});
|
||||
KList<IrisObject> objects = runtime.deposit(this).scaledClumps(scaledMinSize, scaledMaxSize);
|
||||
return objects.get(rng.i(0, objects.size()));
|
||||
}
|
||||
|
||||
public KList<IrisObject> createClumps(long depositSeed, IrisData rdata) {
|
||||
return createClumpVariants(new RNG(depositSeed + stableClumpSalt(rdata)), rdata, minSize, maxSize);
|
||||
}
|
||||
|
||||
public KList<IrisObject> createScaledClumps(long depositSeed, int scaledMinSize, int scaledMaxSize, IrisData rdata) {
|
||||
long sizeSeed = ((long) scaledMinSize << 32) ^ (scaledMaxSize & 0xffffffffL);
|
||||
return createClumpVariants(new RNG(depositSeed + stableClumpSalt(rdata) + sizeSeed), rdata, scaledMinSize, scaledMaxSize);
|
||||
}
|
||||
|
||||
private KList<IrisObject> createClumpVariants(RNG rngv, IrisData rdata, int clumpMinSize, int clumpMaxSize) {
|
||||
KList<IrisObject> variants = new KList<>();
|
||||
for (int i = 0; i < varience; i++) {
|
||||
variants.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598), rdata, clumpMinSize, clumpMaxSize));
|
||||
}
|
||||
return variants;
|
||||
}
|
||||
|
||||
public int getMaxDimension() {
|
||||
return Math.min(11, (int) Math.ceil(Math.cbrt(maxSize)));
|
||||
}
|
||||
@@ -279,7 +271,7 @@ public class IrisDepositGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Advances {@code rng} exactly as {@link #getClump(Engine, RNG, IrisData)} would and reports the clump's width
|
||||
* Advances {@code rng} exactly as {@link #getClump(PackRuntime, RNG)} would and reports the clump's width
|
||||
* and lowest block offset without building it, so a caller can reject the clump first and replay the build
|
||||
* only for clumps it keeps. Returns null without drawing when the shape has no footprint path.
|
||||
*/
|
||||
@@ -682,9 +674,6 @@ public class IrisDepositGenerator {
|
||||
return false;
|
||||
}
|
||||
|
||||
record ClumpCacheKey(long depositSeed, int minSize, int maxSize) {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface CellSink {
|
||||
void add(int x, int y, int z);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.pack.value.IrisRange;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
@@ -95,10 +95,10 @@ public final class IrisOreBands {
|
||||
/**
|
||||
* The ore placed at a Y inside {@link #contains(int)}, or null when no generator places one.
|
||||
*/
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, IrisData data, Engine engine) {
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
IrisOreGenerator[] candidates = byY == null ? generators : byY[y - minY];
|
||||
for (IrisOreGenerator candidate : candidates) {
|
||||
NativeBlockState ore = candidate.generate(x, y, z, rng, data, engine);
|
||||
NativeBlockState ore = candidate.generate(x, y, z, rng, runtime);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.pack.value.IrisRange;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
@@ -57,19 +56,12 @@ public class IrisOreGenerator {
|
||||
@Description("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 final transient LazyBoundedCache<ChanceKey, OreChance> chanceCache = new LazyBoundedCache<>(32);
|
||||
private transient volatile CachedChance recentChance;
|
||||
|
||||
public void warm(RNG rng, IrisData data) {
|
||||
chance(rng, data);
|
||||
palette.getLayerGenerator(rng, PackRuntime.forContext(data));
|
||||
public void warm(RNG rng, PackRuntime runtime) {
|
||||
runtime.oreChance(this, rng.getSeed());
|
||||
palette.getLayerGenerator(rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generate(x, y, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, IrisData data, Engine engine) {
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
if (threshold <= 0 || !range.contains(y)) {
|
||||
return null;
|
||||
}
|
||||
@@ -78,51 +70,22 @@ public class IrisOreGenerator {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (chance(rng, data, engine).sample(x, y, z) > threshold) {
|
||||
if (runtime.oreChance(this, rng.getSeed()).sample(x, y, z) > threshold) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return palette.get(rng, x, y, z, PackRuntime.of(engine, data));
|
||||
return palette.get(rng, x, y, z, runtime);
|
||||
}
|
||||
|
||||
private OreChance chance(RNG rng, IrisData data) {
|
||||
return chance(rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
|
||||
private OreChance chance(RNG rng, IrisData data, Engine engine) {
|
||||
long seed = rng.getSeed();
|
||||
CachedChance recent = recentChance;
|
||||
if (recent != null && recent.key.seed == seed && recent.key.data == data && recent.key.engine == engine) {
|
||||
return recent.chance;
|
||||
}
|
||||
ChanceKey key = new ChanceKey(seed, data, engine);
|
||||
OreChance selected = chanceCache.computeIfAbsent(key, ignored -> OreChance.of(chanceStyle.create(rng, PackRuntime.of(engine, data))));
|
||||
recentChance = new CachedChance(key, selected);
|
||||
return selected;
|
||||
}
|
||||
|
||||
private record ChanceKey(long seed, IrisData data, Engine engine) {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof ChanceKey key
|
||||
&& seed == key.seed && data == key.data && engine == key.engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (31 * Long.hashCode(seed) + System.identityHashCode(data))
|
||||
+ System.identityHashCode(engine);
|
||||
}
|
||||
}
|
||||
|
||||
private record CachedChance(ChanceKey key, OreChance chance) {
|
||||
public OreChance createChance(long seed, PackRuntime runtime) {
|
||||
return OreChance.of(chanceStyle.create(new RNG(seed), runtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* The chance field, with its single value resolved once when it is constant (a FLAT style),
|
||||
* which bands such as a full deepslate layer sample at every block.
|
||||
*/
|
||||
private record OreChance(CNG noise, boolean constant, double value) {
|
||||
public record OreChance(CNG noise, boolean constant, double value) {
|
||||
private static OreChance of(CNG noise) {
|
||||
boolean constant = noise.isConstant();
|
||||
return new OreChance(noise, constant, constant ? noise.noise(0D, 0D, 0D) : 0D);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -42,27 +43,28 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, limit);
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, limit, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
IrisBiome biome, int height, int max, int limit) {
|
||||
IrisBiome biome, int height, int max, int limit, PackRuntime runtime) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault()
|
||||
&& !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null) {
|
||||
data.set(x, height, z, block);
|
||||
}
|
||||
@@ -70,13 +72,13 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
int stack = Math.min(limit - height,
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, getData(), max - height));
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, runtime, max - height));
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
double threshold = stack == 1 ? 1.0 : ((double) i) / (stack - 1);
|
||||
NativeBlockState block = threshold >= decorator.getTopThreshold()
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, getData())
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, getData());
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, runtime)
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, runtime);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
+9
-7
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -42,25 +43,26 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, maxBaseY);
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, maxBaseY, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
IrisBiome biome, int height, int max, int maxBaseY) {
|
||||
IrisBiome biome, int height, int max, int maxBaseY, PackRuntime runtime) {
|
||||
if (!decorator.isStacking()) {
|
||||
int targetY = height + 1;
|
||||
if (DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
@@ -69,7 +71,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
int stack = Math.min(maxBaseY - height,
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, getData(), max - height));
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, runtime, max - height));
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
int targetY = h + 1;
|
||||
@@ -78,8 +80,8 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
double threshold = stack == 1 ? 1.0 : ((double) i) / (stack - 1);
|
||||
NativeBlockState block = threshold >= decorator.getTopThreshold()
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, getData())
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, getData());
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, runtime)
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, runtime);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
+10
-8
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -78,7 +79,8 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
int max
|
||||
) {
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
@@ -90,14 +92,14 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
try {
|
||||
placePicked(decorator, x, z, realX, realZ, data, biome, height, max);
|
||||
placePicked(decorator, x, z, realX, realZ, data, biome, height, max, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void placePicked(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
IrisBiome biome, int height, int max) {
|
||||
IrisBiome biome, int height, int max, PackRuntime runtime) {
|
||||
NativeBlockState support = data.get(x, height, z);
|
||||
if (support == null || !support.isSolid()) {
|
||||
return;
|
||||
@@ -111,7 +113,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)
|
||||
&& IrisSugarCane.canPlace(block, data, x, targetY, z, realX, realZ, getEngine())) {
|
||||
data.set(x, targetY, z, block);
|
||||
@@ -120,7 +122,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
int stack = DecoratorCore.computeStack(decorator, partRNG, realX, realZ, getData(), max - height);
|
||||
int stack = DecoratorCore.computeStack(decorator, partRNG, realX, realZ, runtime, max - height);
|
||||
|
||||
if (stack == 1) {
|
||||
int targetY = height + 1;
|
||||
@@ -128,7 +130,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBlockState block = decorator.getBlockDataForTop(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockDataForTop(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)
|
||||
&& IrisSugarCane.canPlace(block, data, x, targetY, z, realX, realZ, getEngine())) {
|
||||
data.set(x, targetY, z, block);
|
||||
@@ -146,8 +148,8 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
NativeBlockState block = threshold >= decorator.getTopThreshold()
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, getData())
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, getData());
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, runtime)
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, runtime);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.context.ChunkContext;
|
||||
@@ -73,21 +74,22 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
boolean caveSkipFluid = skipsFluid(inferredType);
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null || !isSlopeValid(decorator, realX, height, realZ)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, height, max, underwater, fluidHeight, caveSkipFluid);
|
||||
place(decorator, x, z, realX, realZ, data, height, max, underwater, fluidHeight, caveSkipFluid, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
int height, int max, boolean underwater, int fluidHeight, boolean caveSkipFluid) {
|
||||
int height, int max, boolean underwater, int fluidHeight, boolean caveSkipFluid, PackRuntime runtime) {
|
||||
AquaticPlacementSnapshot aquaticSnapshot = captureAquaticPlacement(
|
||||
decorator, getData(), data, x, z, height, max);
|
||||
if (decorator.isStacking()) {
|
||||
@@ -97,13 +99,13 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
opts.fluidHeight = fluidHeight;
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
opts.mantle = getEngine().getMantle();
|
||||
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, partRNG, getData(), opts);
|
||||
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, partRNG, runtime, opts);
|
||||
aquaticSnapshot.restoreIfUnsupported(data, x, z);
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ,
|
||||
data, partRNG, getData(), underwater, caveSkipFluid, getEngine().getMantle());
|
||||
data, partRNG, runtime, underwater, caveSkipFluid, getEngine().getMantle());
|
||||
aquaticSnapshot.restoreIfUnsupported(data, x, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ public final class GenerationCacheWarmer {
|
||||
public static void warm(Engine engine) {
|
||||
long start = M.ms();
|
||||
IrisData data = engine.getData();
|
||||
PackRuntime runtime = PackRuntime.of(engine, data);
|
||||
RNG root = new RNG(engine.getSeedManager().getComponent() + 7777L);
|
||||
int[] counter = {0};
|
||||
List<ProceduralWarmTask> proceduralTasks = new ArrayList<>();
|
||||
@@ -56,8 +57,8 @@ public final class GenerationCacheWarmer {
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
warmPlacements(biome.getObjects(), root, counter, data, engine);
|
||||
warmDecorators(biome.getDecorators(), engine.getSeedManager().getComponent(), counter, data);
|
||||
warmOres(biome.getOres(), engine.getSeedManager().getTerrain(), counter, data);
|
||||
warmDecorators(biome.getDecorators(), engine.getSeedManager().getComponent(), counter, runtime);
|
||||
warmOres(biome.getOres(), engine.getSeedManager().getTerrain(), counter, runtime);
|
||||
collectProcedural(biome.getProceduralObjects(), root, counter, proceduralTasks);
|
||||
}
|
||||
|
||||
@@ -65,11 +66,11 @@ public final class GenerationCacheWarmer {
|
||||
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
|
||||
for (IrisRegion region : regions) {
|
||||
warmPlacements(region.getObjects(), root, counter, data, engine);
|
||||
warmOres(region.getOres(), engine.getSeedManager().getTerrain(), counter, data);
|
||||
warmOres(region.getOres(), engine.getSeedManager().getTerrain(), counter, runtime);
|
||||
collectProcedural(region.getProceduralObjects(), root, counter, proceduralTasks);
|
||||
}
|
||||
|
||||
warmOres(engine.getDimension().getOres(), engine.getSeedManager().getTerrain(), counter, data);
|
||||
warmOres(engine.getDimension().getOres(), engine.getSeedManager().getTerrain(), counter, runtime);
|
||||
warmProcedural(proceduralTasks, data);
|
||||
|
||||
IrisLogging.debug("[IrisEngine timing] cache warm " + counter[0] + " configs=" + (M.ms() - start) + "ms");
|
||||
@@ -90,7 +91,7 @@ public final class GenerationCacheWarmer {
|
||||
}
|
||||
}
|
||||
|
||||
private static void warmDecorators(KList<IrisDecorator> decorators, long componentSeed, int[] counter, IrisData data) {
|
||||
private static void warmDecorators(KList<IrisDecorator> decorators, long componentSeed, int[] counter, PackRuntime runtime) {
|
||||
if (decorators == null) {
|
||||
return;
|
||||
}
|
||||
@@ -100,13 +101,13 @@ public final class GenerationCacheWarmer {
|
||||
}
|
||||
counter[0]++;
|
||||
RNG rng = new RNG(IrisEngineDecorator.seedForPart(componentSeed, decorator.getPartOf()));
|
||||
decorator.getHeightGenerator(rng, data);
|
||||
decorator.getGenerator(rng, data);
|
||||
decorator.getVarianceGenerator(rng, data);
|
||||
decorator.getHeightGenerator(rng, runtime);
|
||||
decorator.getGenerator(rng, runtime);
|
||||
decorator.getVarianceGenerator(rng, runtime);
|
||||
}
|
||||
}
|
||||
|
||||
private static void warmOres(KList<IrisOreGenerator> ores, long terrainSeed, int[] counter, IrisData data) {
|
||||
private static void warmOres(KList<IrisOreGenerator> ores, long terrainSeed, int[] counter, PackRuntime runtime) {
|
||||
if (ores == null) {
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +116,7 @@ public final class GenerationCacheWarmer {
|
||||
continue;
|
||||
}
|
||||
counter[0]++;
|
||||
ore.warm(new RNG(terrainSeed), data);
|
||||
ore.warm(new RNG(terrainSeed), runtime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,11 @@ import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.biome.IrisBiomePaletteLayer;
|
||||
import art.arcane.iris.generation.biome.IrisFloatingChildBiomes;
|
||||
import art.arcane.iris.generation.biome.PaletteLayerRuntime;
|
||||
import art.arcane.iris.generation.decoration.DecoratorRuntime;
|
||||
import art.arcane.iris.generation.decoration.DepositRuntime;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.decoration.IrisDepositGenerator;
|
||||
import art.arcane.iris.generation.decoration.IrisOreGenerator;
|
||||
import art.arcane.iris.generation.noise.ExpressionRuntime;
|
||||
import art.arcane.iris.generation.noise.GeneratorRuntime;
|
||||
import art.arcane.iris.generation.noise.IrisExpression;
|
||||
@@ -49,6 +54,7 @@ public final class PackRuntime {
|
||||
private static final int NOISE_LAYER_SEED_CAPACITY = 32;
|
||||
private static final int MATERIAL_PALETTE_SEED_CAPACITY = 32;
|
||||
private static final int CARVING_CHILD_SEED_CAPACITY = 8;
|
||||
private static final int ORE_CHANCE_SEED_CAPACITY = 32;
|
||||
|
||||
private final Engine engine;
|
||||
private final IrisData data;
|
||||
@@ -61,6 +67,12 @@ public final class PackRuntime {
|
||||
palette -> new SeedTable<>(MATERIAL_PALETTE_SEED_CAPACITY, seed -> palette.createLayerGenerator(seed, this)));
|
||||
private final RuntimeTable<IrisDimensionCarvingEntry, SeedTable<CNG>> carvingChildGenerators = new RuntimeTable<>(
|
||||
entry -> new SeedTable<>(CARVING_CHILD_SEED_CAPACITY, seed -> entry.createChildrenGenerator(seed, this)));
|
||||
private final RuntimeTable<IrisOreGenerator, SeedTable<IrisOreGenerator.OreChance>> oreChances = new RuntimeTable<>(
|
||||
ore -> new SeedTable<>(ORE_CHANCE_SEED_CAPACITY, seed -> ore.createChance(seed, this)));
|
||||
private final RuntimeTable<IrisDecorator, DecoratorRuntime> decorators =
|
||||
new RuntimeTable<>(decorator -> new DecoratorRuntime(decorator, this));
|
||||
private final RuntimeTable<IrisDepositGenerator, DepositRuntime> deposits =
|
||||
new RuntimeTable<>(deposit -> new DepositRuntime(deposit, this));
|
||||
private final RuntimeTable<IrisGenerator, GeneratorRuntime> generators = new RuntimeTable<>(GeneratorRuntime::new);
|
||||
private final RuntimeTable<IrisExpression, ExpressionRuntime> expressions =
|
||||
new RuntimeTable<>(expression -> new ExpressionRuntime(expression, this));
|
||||
@@ -157,6 +169,19 @@ public final class PackRuntime {
|
||||
return carvingChildGenerators.get(entry).get(seed);
|
||||
}
|
||||
|
||||
/** Ores are seeded by the stage that places them, so an ore keeps one chance field per seed. */
|
||||
public IrisOreGenerator.OreChance oreChance(IrisOreGenerator ore, long seed) {
|
||||
return oreChances.get(ore).get(seed);
|
||||
}
|
||||
|
||||
public DecoratorRuntime decorator(IrisDecorator decorator) {
|
||||
return decorators.get(decorator);
|
||||
}
|
||||
|
||||
public DepositRuntime deposit(IrisDepositGenerator deposit) {
|
||||
return deposits.get(deposit);
|
||||
}
|
||||
|
||||
public GeneratorRuntime generator(IrisGenerator generator) {
|
||||
return generators.get(generator);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.stage;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.decoration.HydrologyVegetation;
|
||||
import art.arcane.iris.generation.decoration.IrisCeilingDecorator;
|
||||
import art.arcane.iris.generation.decoration.IrisSeaFloorDecorator;
|
||||
@@ -140,6 +141,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<NativeBlockStat
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
HydrologyVegetation.Water water = new ComplexWater(getComplex());
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
int height;
|
||||
int realX = Math.round(x + i);
|
||||
@@ -159,7 +161,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<NativeBlockStat
|
||||
getComplex().getWaterHeadStream().get(realX, realZ)) : transitionTerrain.fluidHeight();
|
||||
|
||||
if (role != WaterRole.NONE) {
|
||||
getHydrologyVegetation().decorate(output, i, j, realX, realZ, role, water, getData());
|
||||
getHydrologyVegetation().decorate(output, i, j, realX, realZ, role, water, runtime);
|
||||
}
|
||||
|
||||
if (biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.stage;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.GenerationFailures;
|
||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||
@@ -306,7 +307,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<NativeBlockState
|
||||
if (footprint != null && footprint.empty() && !scalable) {
|
||||
return null;
|
||||
}
|
||||
IrisObject clump = footprint == null ? k.getClump(getEngine(), clumpRng, getData()) : null;
|
||||
IrisObject clump = footprint == null ? k.getClump(PackRuntime.of(getEngine(), getData()), clumpRng) : null;
|
||||
|
||||
int dim = footprint == null ? clump.getW() : footprint.width();
|
||||
int min = dim / 2;
|
||||
@@ -368,7 +369,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<NativeBlockState
|
||||
|
||||
double sizeMultiplier = depositBiome.getOreDepositSizeMultiplier();
|
||||
if (sizeMultiplier != 1D) {
|
||||
IrisObject scaledClump = k.getClump(getEngine(), clumpRng, getData(), sizeMultiplier);
|
||||
IrisObject scaledClump = k.getClump(PackRuntime.of(getEngine(), getData()), clumpRng, sizeMultiplier);
|
||||
int scaledDimension = scaledClump.getW();
|
||||
x = clampDepositCenter(x, scaledDimension, 16);
|
||||
if (clippedHeight) {
|
||||
|
||||
@@ -145,7 +145,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
private final IrisDimension dimension;
|
||||
private final IrisData data;
|
||||
private final PackRuntime runtime;
|
||||
private final Engine oreEngine;
|
||||
private final IrisComplex complex;
|
||||
private final ProceduralStream<Double> waterHeadStream;
|
||||
private final ProceduralStream<WaterRole> waterRoleStream;
|
||||
@@ -184,7 +183,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
dimension = getDimension();
|
||||
data = getData();
|
||||
runtime = PackRuntime.of(getEngine(), data);
|
||||
oreEngine = data == null ? null : data.getEngine();
|
||||
complex = getComplex();
|
||||
waterHeadStream = complex.getWaterHeadStream();
|
||||
waterRoleStream = complex.getWaterRoleStream();
|
||||
@@ -437,13 +435,13 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
private NativeBlockState surfaceOre(int realX, int y, int realZ) {
|
||||
NativeBlockState ore = null;
|
||||
if (biomeSurfaceOres.contains(y)) {
|
||||
ore = biomeSurfaceOres.generate(realX, y, realZ, rng, data, oreEngine);
|
||||
ore = biomeSurfaceOres.generate(realX, y, realZ, rng, runtime);
|
||||
}
|
||||
if (ore == null && regionSurfaceOres.contains(y)) {
|
||||
ore = regionSurfaceOres.generate(realX, y, realZ, rng, data, oreEngine);
|
||||
ore = regionSurfaceOres.generate(realX, y, realZ, rng, runtime);
|
||||
}
|
||||
if (ore == null && dimensionSurfaceOres.contains(y)) {
|
||||
ore = dimensionSurfaceOres.generate(realX, y, realZ, rng, data, oreEngine);
|
||||
ore = dimensionSurfaceOres.generate(realX, y, realZ, rng, runtime);
|
||||
}
|
||||
return ore;
|
||||
}
|
||||
@@ -451,13 +449,13 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
private NativeBlockState undergroundOre(int realX, int y, int realZ) {
|
||||
NativeBlockState ore = null;
|
||||
if (biomeUndergroundOres.contains(y)) {
|
||||
ore = biomeUndergroundOres.generate(realX, y, realZ, rng, data, oreEngine);
|
||||
ore = biomeUndergroundOres.generate(realX, y, realZ, rng, runtime);
|
||||
}
|
||||
if (ore == null && regionUndergroundOres.contains(y)) {
|
||||
ore = regionUndergroundOres.generate(realX, y, realZ, rng, data, oreEngine);
|
||||
ore = regionUndergroundOres.generate(realX, y, realZ, rng, runtime);
|
||||
}
|
||||
if (ore == null && dimensionUndergroundOres.contains(y)) {
|
||||
ore = dimensionUndergroundOres.generate(realX, y, realZ, rng, data, oreEngine);
|
||||
ore = dimensionUndergroundOres.generate(realX, y, realZ, rng, runtime);
|
||||
}
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.terrain;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.world.entity.IrisSpawnGroup;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.biome.IrisBiomeCustom;
|
||||
@@ -452,17 +453,17 @@ public class IrisDimension extends IrisRegistrant {
|
||||
carvingEntryIndex.reset();
|
||||
}
|
||||
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, PackRuntime runtime, boolean surface) {
|
||||
KList<IrisOreGenerator> localOres = surface ? getSurfaceOres() : getUndergroundOres();
|
||||
return generateOres(localOres, x, y, z, rng, data);
|
||||
return generateOres(localOres, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getSurfaceOres(), x, y, z, rng, data);
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getSurfaceOres(), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getUndergroundOres(), x, y, z, rng, data);
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getUndergroundOres(), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public boolean hasSurfaceOres() {
|
||||
@@ -473,7 +474,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
return !getUndergroundOres().isEmpty();
|
||||
}
|
||||
|
||||
private NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, IrisData data) {
|
||||
private NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
if (localOres.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -481,7 +482,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, runtime);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.terrain;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.cave.IrisCaveProfile;
|
||||
import art.arcane.iris.generation.decoration.IrisDepositGenerator;
|
||||
@@ -176,17 +177,17 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
|
||||
@ArrayType(type = IrisOreGenerator.class, min = 1)
|
||||
private KList<IrisOreGenerator> ores = new KList<>();
|
||||
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, PackRuntime runtime, boolean surface) {
|
||||
KList<IrisOreGenerator> localOres = surface ? getSurfaceOres() : getUndergroundOres();
|
||||
return generateOres(localOres, x, y, z, rng, data);
|
||||
return generateOres(localOres, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getSurfaceOres(), x, y, z, rng, data);
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getSurfaceOres(), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getUndergroundOres(), x, y, z, rng, data);
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getUndergroundOres(), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public boolean hasSurfaceOres() {
|
||||
@@ -197,7 +198,7 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
|
||||
return !getUndergroundOres().isEmpty();
|
||||
}
|
||||
|
||||
private NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, IrisData data) {
|
||||
private NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
if (localOres.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -205,7 +206,7 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, runtime);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -123,13 +123,13 @@ public final class IrisStructureStrata implements StructureStrata {
|
||||
private NativeBlockState ore(IrisOreBands first, IrisOreBands second, IrisOreBands third, int internalY) {
|
||||
NativeBlockState ore = null;
|
||||
if (first.contains(internalY)) {
|
||||
ore = first.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
ore = first.generate(x, internalY, z, rng, runtime);
|
||||
}
|
||||
if (ore == null && second.contains(internalY)) {
|
||||
ore = second.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
ore = second.generate(x, internalY, z, rng, runtime);
|
||||
}
|
||||
if (ore == null && third.contains(internalY)) {
|
||||
ore = third.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
ore = third.generate(x, internalY, z, rng, runtime);
|
||||
}
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ abstract class BiomePalettePlacement {
|
||||
super(runtime);
|
||||
this.decorator = decorator;
|
||||
RNG partRandom = new RNG(IrisEngineDecorator.seedForPart(componentSeed, decorator.getPartOf()));
|
||||
this.placementNoise = decorator.getGenerator(partRandom, data);
|
||||
this.blockNoise = decorator.getVarianceGenerator(partRandom, data);
|
||||
this.placementNoise = decorator.getGenerator(partRandom, runtime);
|
||||
this.blockNoise = decorator.getVarianceGenerator(partRandom, runtime);
|
||||
this.picksFromFlatNoise = decorator.getPartOf() == IrisDecorationPart.NONE
|
||||
|| decorator.getPartOf() == IrisDecorationPart.CEILING;
|
||||
this.sampleHeight = sampleHeight;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.testsupport.MockPackData;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
@@ -86,39 +88,42 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void pickDecorator_emptyBucket_returnsNull() {
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
when(biome.getDecoratorBucket(IrisDecorationPart.NONE)).thenReturn(new IrisDecorator[0]);
|
||||
|
||||
IrisDecorator result = DecoratorCore.pickDecorator(
|
||||
biome, IrisDecorationPart.NONE, new RNG(1L), new RNG(2L), data, 0.0, 0.0);
|
||||
biome, IrisDecorationPart.NONE, new RNG(1L), new RNG(2L), runtime, 0.0, 0.0);
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pickDecorator_nonePassChanceGate_returnsNull() {
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
IrisDecorator d = mock(IrisDecorator.class);
|
||||
when(d.passesChanceGate(any(RNG.class), anyDouble(), anyDouble(), any(IrisData.class))).thenReturn(false);
|
||||
when(d.passesChanceGate(any(RNG.class), anyDouble(), anyDouble(), any(PackRuntime.class))).thenReturn(false);
|
||||
when(biome.getDecoratorBucket(IrisDecorationPart.NONE)).thenReturn(new IrisDecorator[]{d});
|
||||
|
||||
IrisDecorator result = DecoratorCore.pickDecorator(
|
||||
biome, IrisDecorationPart.NONE, new RNG(1L), new RNG(2L), data, 0.0, 0.0);
|
||||
biome, IrisDecorationPart.NONE, new RNG(1L), new RNG(2L), runtime, 0.0, 0.0);
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pickDecorator_singleCandidate_alwaysReturnsThat() {
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
IrisDecorator d = mock(IrisDecorator.class);
|
||||
when(d.passesChanceGate(any(RNG.class), anyDouble(), anyDouble(), any(IrisData.class))).thenReturn(true);
|
||||
when(d.passesChanceGate(any(RNG.class), anyDouble(), anyDouble(), any(PackRuntime.class))).thenReturn(true);
|
||||
when(biome.getDecoratorBucket(IrisDecorationPart.NONE)).thenReturn(new IrisDecorator[]{d});
|
||||
|
||||
RNG gRNG = new RNG(42L);
|
||||
for (int t = 0; t < 50; t++) {
|
||||
IrisDecorator result = DecoratorCore.pickDecorator(
|
||||
biome, IrisDecorationPart.NONE, gRNG, new RNG(t * 13L + 7), data, 0.0, 0.0);
|
||||
biome, IrisDecorationPart.NONE, gRNG, new RNG(t * 13L + 7), runtime, 0.0, 0.0);
|
||||
assertSame(d, result);
|
||||
}
|
||||
}
|
||||
@@ -126,13 +131,14 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void pickDecorator_multiplePassingCandidates_selectsUniformly() {
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
|
||||
int n = 4;
|
||||
IrisDecorator[] decorators = new IrisDecorator[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
IrisDecorator d = mock(IrisDecorator.class);
|
||||
when(d.passesChanceGate(any(RNG.class), anyDouble(), anyDouble(), any(IrisData.class))).thenReturn(true);
|
||||
when(d.passesChanceGate(any(RNG.class), anyDouble(), anyDouble(), any(PackRuntime.class))).thenReturn(true);
|
||||
decorators[i] = d;
|
||||
}
|
||||
when(biome.getDecoratorBucket(IrisDecorationPart.NONE)).thenReturn(decorators);
|
||||
@@ -143,7 +149,7 @@ public class DecoratorCoreTest {
|
||||
|
||||
for (int t = 0; t < trials; t++) {
|
||||
IrisDecorator picked = DecoratorCore.pickDecorator(
|
||||
biome, IrisDecorationPart.NONE, gRNG, new RNG(t * 31L + 3), data, 0.0, 0.0);
|
||||
biome, IrisDecorationPart.NONE, gRNG, new RNG(t * 31L + 3), runtime, 0.0, 0.0);
|
||||
assertNotNull(picked);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (picked == decorators[i]) {
|
||||
@@ -164,22 +170,23 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void singleStackTargetsBlockAboveSupport() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState air = mock(NativeBlockState.class);
|
||||
NativeBlockState decorant = mock(NativeBlockState.class);
|
||||
when(air.isAir()).thenReturn(true);
|
||||
when(decorant.key()).thenReturn("minecraft:stone");
|
||||
when(decorant.canPlaceOnto(support)).thenReturn(true);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(1);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(1);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 4, 1);
|
||||
output.set(0, 1, 0, support);
|
||||
output.set(0, 2, 0, air);
|
||||
DecoratorCore.PlaceOpts opts = new DecoratorCore.PlaceOpts();
|
||||
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), data, opts);
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), runtime, opts);
|
||||
|
||||
assertSame(support, output.get(0, 1, 0));
|
||||
assertSame(decorant, output.get(0, 2, 0));
|
||||
@@ -188,21 +195,22 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void singleStackDoesNotOverwriteOccupiedTarget() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState occupied = mock(NativeBlockState.class);
|
||||
NativeBlockState decorant = mock(NativeBlockState.class);
|
||||
when(occupied.isAir()).thenReturn(false);
|
||||
when(occupied.isFluid()).thenReturn(false);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(1);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(1);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 4, 1);
|
||||
output.set(0, 1, 0, support);
|
||||
output.set(0, 2, 0, occupied);
|
||||
DecoratorCore.PlaceOpts opts = new DecoratorCore.PlaceOpts();
|
||||
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), data, opts);
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), runtime, opts);
|
||||
|
||||
assertSame(support, output.get(0, 1, 0));
|
||||
assertSame(occupied, output.get(0, 2, 0));
|
||||
@@ -211,7 +219,8 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void multiStackStopsBeforeOccupiedTarget() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState air = mock(NativeBlockState.class);
|
||||
NativeBlockState occupied = mock(NativeBlockState.class);
|
||||
@@ -221,10 +230,10 @@ public class DecoratorCoreTest {
|
||||
when(occupied.isFluid()).thenReturn(false);
|
||||
when(decorant.key()).thenReturn("minecraft:tall_grass");
|
||||
when(decorant.canPlaceOnto(support)).thenReturn(true);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(3);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(3);
|
||||
when(decorator.getTopThreshold()).thenReturn(0.75);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 5, 1);
|
||||
output.set(0, 1, 0, support);
|
||||
@@ -233,7 +242,7 @@ public class DecoratorCoreTest {
|
||||
output.set(0, 4, 0, air);
|
||||
DecoratorCore.PlaceOpts opts = new DecoratorCore.PlaceOpts();
|
||||
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 1, 4, output, new RNG(1L), data, opts);
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 1, 4, output, new RNG(1L), runtime, opts);
|
||||
|
||||
assertSame(decorant, output.get(0, 2, 0));
|
||||
assertSame(occupied, output.get(0, 3, 0));
|
||||
@@ -243,19 +252,20 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void descendingStackStopsAtLocalWorldFloor() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState decorant = mock(NativeBlockState.class);
|
||||
when(decorant.key()).thenReturn("minecraft:stone");
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(2);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(2);
|
||||
when(decorator.getTopThreshold()).thenReturn(1.0);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 2, 1);
|
||||
DecoratorCore.PlaceOpts opts = new DecoratorCore.PlaceOpts();
|
||||
|
||||
DecoratorCore.placeStackDown(
|
||||
decorator, 0, 0, 0, 0, 0, -64, output, new RNG(1L), data, 2, opts, null);
|
||||
decorator, 0, 0, 0, 0, 0, -64, output, new RNG(1L), runtime, 2, opts, null);
|
||||
|
||||
assertSame(decorant, output.get(0, 0, 0));
|
||||
}
|
||||
@@ -263,16 +273,17 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void singleDescendingStackPreservesTargetWhenPickIsNull() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState existing = mock(NativeBlockState.class);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(1);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(1);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 2, 1);
|
||||
output.set(0, 0, 0, existing);
|
||||
DecoratorCore.PlaceOpts opts = new DecoratorCore.PlaceOpts();
|
||||
|
||||
DecoratorCore.placeStackDown(
|
||||
decorator, 0, 0, 0, 0, 0, 0, output, new RNG(1L), data, 1, opts, null);
|
||||
decorator, 0, 0, 0, 0, 0, 0, output, new RNG(1L), runtime, 1, opts, null);
|
||||
|
||||
assertSame(existing, output.get(0, 0, 0));
|
||||
}
|
||||
@@ -280,10 +291,11 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void multiDescendingStackStopsWhenPickIsNull() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState lowerExisting = mock(NativeBlockState.class);
|
||||
NativeBlockState upperExisting = mock(NativeBlockState.class);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(2);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(2);
|
||||
when(decorator.getTopThreshold()).thenReturn(1.0);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 2, 1);
|
||||
@@ -292,7 +304,7 @@ public class DecoratorCoreTest {
|
||||
DecoratorCore.PlaceOpts opts = new DecoratorCore.PlaceOpts();
|
||||
|
||||
DecoratorCore.placeStackDown(
|
||||
decorator, 0, 0, 0, 0, 1, 0, output, new RNG(1L), data, 2, opts, null);
|
||||
decorator, 0, 0, 0, 0, 1, 0, output, new RNG(1L), runtime, 2, opts, null);
|
||||
|
||||
assertSame(lowerExisting, output.get(0, 0, 0));
|
||||
assertSame(upperExisting, output.get(0, 1, 0));
|
||||
@@ -301,18 +313,19 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void floatingStackStopsAtHunkCeiling() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState decorant = mock(NativeBlockState.class);
|
||||
when(decorant.key()).thenReturn("minecraft:stone");
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(3);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(3);
|
||||
when(decorator.getTopThreshold()).thenReturn(1.0);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 2, 1);
|
||||
output.set(0, 0, 0, sturdyState());
|
||||
int placed = DecoratorCore.placeFloatingStacked(
|
||||
decorator, 0, 0, 0, 0, 0, 3, output, new RNG(1L), data, null);
|
||||
decorator, 0, 0, 0, 0, 0, 3, output, new RNG(1L), runtime, null);
|
||||
|
||||
assertEquals(1, placed);
|
||||
assertSame(decorant, output.get(0, 1, 0));
|
||||
@@ -321,7 +334,8 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void floatingDecoratorsRejectUnsupportedSurface() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState decorant = mock(NativeBlockState.class);
|
||||
NativeBlockState air = airState();
|
||||
NativeBlockState fluid = mock(NativeBlockState.class);
|
||||
@@ -329,10 +343,10 @@ public class DecoratorCoreTest {
|
||||
when(plant.key()).thenReturn("minecraft:short_grass");
|
||||
when(fluid.isFluid()).thenReturn(true);
|
||||
when(decorant.key()).thenReturn("minecraft:cobblestone_slab");
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(2);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(2);
|
||||
when(decorator.getTopThreshold()).thenReturn(1.0);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
|
||||
for (NativeBlockState surface : new NativeBlockState[]{null, air, fluid, plant}) {
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 5, 1);
|
||||
@@ -342,11 +356,11 @@ public class DecoratorCoreTest {
|
||||
output.set(0, 4, 0, air);
|
||||
|
||||
DecoratorCore.placeFloatingSimple(
|
||||
decorator, 0, 0, 0, 0, 2, 3, output, new RNG(1L), data, null);
|
||||
decorator, 0, 0, 0, 0, 2, 3, output, new RNG(1L), runtime, null);
|
||||
assertSame(air, output.get(0, 3, 0));
|
||||
|
||||
int placed = DecoratorCore.placeFloatingStacked(
|
||||
decorator, 0, 0, 0, 0, 2, 3, output, new RNG(1L), data, null);
|
||||
decorator, 0, 0, 0, 0, 2, 3, output, new RNG(1L), runtime, null);
|
||||
assertEquals(0, placed);
|
||||
assertSame(surface, output.get(0, 2, 0));
|
||||
assertSame(air, output.get(0, 3, 0));
|
||||
@@ -357,27 +371,28 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void floatingDecoratorsPreserveSupportedPlacementWithoutMaterialGating() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState surface = mock(NativeBlockState.class);
|
||||
NativeBlockState decorant = mock(NativeBlockState.class);
|
||||
when(surface.isSolid()).thenReturn(true);
|
||||
when(decorant.key()).thenReturn("minecraft:cobblestone_slab");
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(2);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(2);
|
||||
when(decorator.getTopThreshold()).thenReturn(1.0);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 4, 1);
|
||||
output.set(0, 1, 0, surface);
|
||||
output.set(0, 2, 0, airState());
|
||||
output.set(0, 3, 0, airState());
|
||||
|
||||
DecoratorCore.placeFloatingSimple(
|
||||
decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), data, null);
|
||||
decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), runtime, null);
|
||||
assertSame(decorant, output.get(0, 2, 0));
|
||||
output.set(0, 2, 0, airState());
|
||||
|
||||
int placed = DecoratorCore.placeFloatingStacked(
|
||||
decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), data, null);
|
||||
decorator, 0, 0, 0, 0, 1, 3, output, new RNG(1L), runtime, null);
|
||||
assertEquals(2, placed);
|
||||
assertSame(surface, output.get(0, 1, 0));
|
||||
assertSame(decorant, output.get(0, 2, 0));
|
||||
@@ -387,12 +402,13 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void tallSurfacePlantDoesNotPlaceWhenUpperTargetIsOccupied() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState air = airState();
|
||||
NativeBlockState occupied = mock(NativeBlockState.class);
|
||||
NativeBlockState plant = tallPlantState();
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(plant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(plant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 4, 1);
|
||||
output.set(0, 0, 0, support);
|
||||
@@ -400,7 +416,7 @@ public class DecoratorCoreTest {
|
||||
output.set(0, 2, 0, occupied);
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), data, false, false, null);
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), runtime, false, false, null);
|
||||
|
||||
assertSame(air, output.get(0, 1, 0));
|
||||
assertSame(occupied, output.get(0, 2, 0));
|
||||
@@ -409,11 +425,12 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void tallFloatingPlantDoesNotPlaceWhenUpperTargetIsOccupied() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState air = airState();
|
||||
NativeBlockState occupied = mock(NativeBlockState.class);
|
||||
NativeBlockState plant = tallPlantState();
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(plant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(plant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 4, 1);
|
||||
output.set(0, 0, 0, sturdyState());
|
||||
@@ -421,7 +438,7 @@ public class DecoratorCoreTest {
|
||||
output.set(0, 2, 0, occupied);
|
||||
|
||||
DecoratorCore.placeFloatingSimple(
|
||||
decorator, 0, 0, 0, 0, 0, 3, output, new RNG(1L), data, null);
|
||||
decorator, 0, 0, 0, 0, 0, 3, output, new RNG(1L), runtime, null);
|
||||
|
||||
assertSame(air, output.get(0, 1, 0));
|
||||
assertSame(occupied, output.get(0, 2, 0));
|
||||
@@ -430,7 +447,8 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void tallSurfacePlantPlacesBothHalvesTogether() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState lowerAir = airState();
|
||||
NativeBlockState upperAir = airState();
|
||||
@@ -438,7 +456,7 @@ public class DecoratorCoreTest {
|
||||
NativeBlockState upper = mock(NativeBlockState.class);
|
||||
NativeBlockState plant = tallPlantState(lower, upper);
|
||||
when(plant.canPlaceOnto(support)).thenReturn(true);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(plant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(plant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 4, 1);
|
||||
output.set(0, 0, 0, support);
|
||||
@@ -446,7 +464,7 @@ public class DecoratorCoreTest {
|
||||
output.set(0, 2, 0, upperAir);
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), data, false, false, null);
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), runtime, false, false, null);
|
||||
|
||||
assertSame(lower, output.get(0, 1, 0));
|
||||
assertSame(upper, output.get(0, 2, 0));
|
||||
@@ -455,19 +473,20 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void surfaceDecorantRejectsInvalidNativeSupport() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState air = airState();
|
||||
NativeBlockState decorant = mock(NativeBlockState.class);
|
||||
when(decorant.canPlaceOnto(support)).thenReturn(false);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(decorant);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 3, 1);
|
||||
output.set(0, 0, 0, support);
|
||||
output.set(0, 1, 0, air);
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), data, false, false, null);
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), runtime, false, false, null);
|
||||
|
||||
assertSame(air, output.get(0, 1, 0));
|
||||
}
|
||||
@@ -476,7 +495,8 @@ public class DecoratorCoreTest {
|
||||
public void forcedSurfaceBlockStillPlacesDecorantAboveIt() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisBlockData forcedBlock = mock(IrisBlockData.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState farmland = sturdyState();
|
||||
NativeBlockState air = airState();
|
||||
@@ -484,14 +504,14 @@ public class DecoratorCoreTest {
|
||||
when(wheat.key()).thenReturn("minecraft:wheat[age=7]");
|
||||
when(decorator.getForceBlock()).thenReturn(forcedBlock);
|
||||
when(forcedBlock.getBlockData(data)).thenReturn(farmland);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(wheat);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(wheat);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 3, 1);
|
||||
output.set(0, 0, 0, support);
|
||||
output.set(0, 1, 0, air);
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), data, false, false, null);
|
||||
decorator, 0, 0, 0, 0, 0, output, new RNG(1L), runtime, false, false, null);
|
||||
|
||||
assertSame(farmland, output.get(0, 0, 0));
|
||||
assertSame(wheat, output.get(0, 1, 0));
|
||||
@@ -667,10 +687,10 @@ public class DecoratorCoreTest {
|
||||
SpikeFixture fixture = new SpikeFixture(1, upward);
|
||||
if (upward) {
|
||||
DecoratorCore.placeSurfaceSingle(fixture.decorator, 0, 0, 0, 0, 0,
|
||||
fixture.output, new RNG(1L), fixture.data, false, false, null);
|
||||
fixture.output, new RNG(1L), fixture.runtime, false, false, null);
|
||||
} else {
|
||||
DecoratorCore.placeSingleAt(fixture.decorator, 0, 0, 0, 1, 0,
|
||||
fixture.output, new RNG(1L), fixture.data, true, null);
|
||||
fixture.output, new RNG(1L), fixture.runtime, true, null);
|
||||
}
|
||||
assertEquals("tip", fixture.property(1, "thickness"));
|
||||
assertEquals(upward ? "up" : "down", fixture.property(1, "vertical_direction"));
|
||||
@@ -703,7 +723,7 @@ public class DecoratorCoreTest {
|
||||
when(fixture.decorator.getWhitelistArray(fixture.data)).thenReturn(new NativeBlockState[]{original});
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(fixture.decorator, 0, 0, 0, 0, 0,
|
||||
fixture.output, new RNG(1L), fixture.data, false, false, null);
|
||||
fixture.output, new RNG(1L), fixture.runtime, false, false, null);
|
||||
|
||||
assertSame(replacement, fixture.output.get(0, 0, 0));
|
||||
assertEquals("tip", fixture.property(1, "thickness"));
|
||||
@@ -717,8 +737,8 @@ public class DecoratorCoreTest {
|
||||
NativeBlockState obstruction = sturdyState();
|
||||
when(plant.key()).thenReturn("minecraft:weeping_vines_plant");
|
||||
when(tip.key()).thenReturn("minecraft:weeping_vines");
|
||||
when(fixture.decorator.pickBlockData(any(RNG.class), eq(fixture.data), anyDouble(), anyDouble())).thenReturn(tip);
|
||||
when(fixture.decorator.pickBlockDataTop(any(RNG.class), eq(fixture.data), anyDouble(), anyDouble())).thenReturn(tip);
|
||||
when(fixture.decorator.pickBlockData(any(RNG.class), eq(fixture.runtime), anyDouble(), anyDouble())).thenReturn(tip);
|
||||
when(fixture.decorator.pickBlockDataTop(any(RNG.class), eq(fixture.runtime), anyDouble(), anyDouble())).thenReturn(tip);
|
||||
fixture.output.set(0, 3, 0, obstruction);
|
||||
try (MockedStatic<B> blocks = mockStatic(B.class, CALLS_REAL_METHODS)) {
|
||||
blocks.when(() -> B.getState("minecraft:weeping_vines_plant")).thenReturn(plant);
|
||||
@@ -756,18 +776,19 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void stackedVineCurtainHangsFromTheWallItsTopStrandFaces() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH));
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(3);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(3);
|
||||
when(decorator.getTopThreshold()).thenReturn(1.0);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(16, 8, 16);
|
||||
output.set(8, 6, 8, sturdyState());
|
||||
output.set(8, 5, 7, sturdyState());
|
||||
output.set(9, 4, 8, sturdyState());
|
||||
|
||||
DecoratorCore.placeStackDown(decorator, 8, 8, 8, 8, 5, 0, output, new RNG(1L), data, 3,
|
||||
DecoratorCore.placeStackDown(decorator, 8, 8, 8, 8, 5, 0, output, new RNG(1L), runtime, 3,
|
||||
new DecoratorCore.PlaceOpts(), null);
|
||||
|
||||
assertEquals(EnumSet.of(BlockFace.NORTH, BlockFace.UP), faces(output.get(8, 5, 8)));
|
||||
@@ -778,16 +799,17 @@ public class DecoratorCoreTest {
|
||||
@Test
|
||||
public void stackedVineCurtainHangsUnderAnOpenCeiling() {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH));
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(3);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(3);
|
||||
when(decorator.getTopThreshold()).thenReturn(1.0);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(vine);
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(16, 8, 16);
|
||||
output.set(8, 6, 8, sturdyState());
|
||||
|
||||
DecoratorCore.placeStackDown(decorator, 8, 8, 8, 8, 5, 0, output, new RNG(1L), data, 3,
|
||||
DecoratorCore.placeStackDown(decorator, 8, 8, 8, 8, 5, 0, output, new RNG(1L), runtime, 3,
|
||||
new DecoratorCore.PlaceOpts(), null);
|
||||
|
||||
assertEquals(EnumSet.of(BlockFace.NORTH, BlockFace.UP), faces(output.get(8, 5, 8)));
|
||||
@@ -915,14 +937,15 @@ public class DecoratorCoreTest {
|
||||
|
||||
private Hunk<NativeBlockState> placeSpikeColumn(String material, int height, boolean upward, boolean waterlogged, boolean submerged) {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState spike = spikeState(material, Map.of(
|
||||
"thickness", "tip_merge", "vertical_direction", upward ? "down" : "up",
|
||||
"waterlogged", Boolean.toString(waterlogged)));
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(height);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(height);
|
||||
when(decorator.getTopThreshold()).thenReturn(0.75);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, height + 2, 1);
|
||||
NativeBlockState target = airState();
|
||||
@@ -941,9 +964,9 @@ public class DecoratorCoreTest {
|
||||
opts.underwater = submerged;
|
||||
opts.fluidHeight = height;
|
||||
if (upward) {
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 0, height, output, new RNG(1L), data, opts);
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 0, height, output, new RNG(1L), runtime, opts);
|
||||
} else {
|
||||
DecoratorCore.placeStackDown(decorator, 0, 0, 0, 0, height, 1, output, new RNG(1L), data, height, opts, null);
|
||||
DecoratorCore.placeStackDown(decorator, 0, 0, 0, 0, height, 1, output, new RNG(1L), runtime, height, opts, null);
|
||||
}
|
||||
assertSame(support, output.get(0, upward ? 0 : height + 1, 0));
|
||||
return output;
|
||||
@@ -987,23 +1010,24 @@ public class DecoratorCoreTest {
|
||||
private void assertSingleVoxelHalfPlacement(boolean floating) {
|
||||
for (String key : new String[]{"minecraft:oak_stairs[half=bottom]", "minecraft:oak_trapdoor[half=top]"}) {
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = data.standalonePackRuntime();
|
||||
NativeBlockState support = sturdyState();
|
||||
NativeBlockState air = airState();
|
||||
NativeBlockState occupied = mock(NativeBlockState.class);
|
||||
NativeBlockState block = mock(NativeBlockState.class);
|
||||
when(block.key()).thenReturn(key);
|
||||
when(block.canPlaceOnto(support)).thenReturn(true);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(block);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(block);
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 4, 1);
|
||||
output.set(0, 0, 0, support);
|
||||
output.set(0, 1, 0, air);
|
||||
output.set(0, 2, 0, occupied);
|
||||
|
||||
if (floating) {
|
||||
DecoratorCore.placeFloatingSimple(decorator, 0, 0, 0, 0, 0, 3, output, new RNG(1L), data, null);
|
||||
DecoratorCore.placeFloatingSimple(decorator, 0, 0, 0, 0, 0, 3, output, new RNG(1L), runtime, null);
|
||||
} else {
|
||||
DecoratorCore.placeSurfaceSingle(decorator, 0, 0, 0, 0, 0, output, new RNG(1L), data, false, false, null);
|
||||
DecoratorCore.placeSurfaceSingle(decorator, 0, 0, 0, 0, 0, output, new RNG(1L), runtime, false, false, null);
|
||||
}
|
||||
|
||||
assertSame(key, block, output.get(0, 1, 0));
|
||||
@@ -1033,7 +1057,8 @@ public class DecoratorCoreTest {
|
||||
}
|
||||
private class SpikeFixture {
|
||||
private final IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
private final IrisData data = mock(IrisData.class);
|
||||
private final IrisData data = MockPackData.create();
|
||||
private final PackRuntime runtime = data.standalonePackRuntime();
|
||||
private final DecoratorCore.PlaceOpts opts = new DecoratorCore.PlaceOpts();
|
||||
private final Hunk<NativeBlockState> output;
|
||||
private final int height;
|
||||
@@ -1049,17 +1074,17 @@ public class DecoratorCoreTest {
|
||||
output.set(0, upward ? 0 : height + 1, 0, sturdyState());
|
||||
NativeBlockState spike = spikeState("minecraft:sulfur_spike", Map.of(
|
||||
"thickness", "tip_merge", "vertical_direction", upward ? "down" : "up", "waterlogged", "false"));
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(height);
|
||||
when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(runtime))).thenReturn(height);
|
||||
when(decorator.getTopThreshold()).thenReturn(0.75);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
when(decorator.pickBlockData(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
when(decorator.pickBlockDataTop(any(RNG.class), eq(runtime), anyDouble(), anyDouble())).thenReturn(spike);
|
||||
}
|
||||
|
||||
private void place() {
|
||||
if (upward) {
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 0, height, output, new RNG(1L), data, opts);
|
||||
DecoratorCore.placeStackUp(decorator, 0, 0, 0, 0, 0, height, output, new RNG(1L), runtime, opts);
|
||||
} else {
|
||||
DecoratorCore.placeStackDown(decorator, 0, 0, 0, 0, height, 1, output, new RNG(1L), data, height, opts, null);
|
||||
DecoratorCore.placeStackDown(decorator, 0, 0, 0, 0, height, 1, output, new RNG(1L), runtime, height, opts, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -36,6 +37,7 @@ public class DecoratorStackSamplingTest {
|
||||
|
||||
private static void assertEquivalentStack(long seed, int height, int direction, int coordinate) {
|
||||
IrisData data = mock(IrisData.class);
|
||||
PackRuntime runtime = PackRuntime.standalone(data);
|
||||
RNG rng = new RNG(seed);
|
||||
RNG controlRng = new RNG(seed);
|
||||
CNG variance = new CNG(new RNG(seed + 11L));
|
||||
@@ -46,7 +48,7 @@ public class DecoratorStackSamplingTest {
|
||||
.setStackMin(height).setStackMax(height).setTopThreshold(0.4D));
|
||||
doReturn(body).when(decorator).getBlockDataArray(data);
|
||||
doReturn(top).when(decorator).getBlockDataTopsArray(data);
|
||||
doReturn(variance).when(decorator).getVarianceGenerator(rng, data);
|
||||
doReturn(variance).when(decorator).getVarianceGenerator(rng, runtime);
|
||||
NativeBlockState air = block("minecraft:air");
|
||||
doReturn(true).when(air).isAir();
|
||||
NativeBlockState support = block("minecraft:stone");
|
||||
@@ -64,11 +66,11 @@ public class DecoratorStackSamplingTest {
|
||||
int z = coordinate * 3 - 7;
|
||||
switch (direction) {
|
||||
case 0 -> DecoratorCore.placeStackUp(decorator, 0, 0, coordinate, z, 0, height,
|
||||
output, rng, data, opts);
|
||||
output, rng, runtime, opts);
|
||||
case 1 -> DecoratorCore.placeStackDown(decorator, 0, 0, coordinate, z, height, 0,
|
||||
output, rng, data, height, opts, null);
|
||||
output, rng, runtime, height, opts, null);
|
||||
case 2 -> assertEquals(height, DecoratorCore.placeFloatingStacked(decorator, 0, 0,
|
||||
coordinate, z, 0, height + 1, output, rng, data, null));
|
||||
coordinate, z, 0, height + 1, output, rng, runtime, null));
|
||||
default -> throw new IllegalArgumentException("Unknown stack direction");
|
||||
}
|
||||
boolean usedBody = false;
|
||||
@@ -84,8 +86,8 @@ public class DecoratorStackSamplingTest {
|
||||
usedTop |= topSegment;
|
||||
}
|
||||
assertSame(support, output.get(0, supportY, 0));
|
||||
verify(decorator, times(usedBody ? 1 : 0)).pickBlockData(rng, data, coordinate, z);
|
||||
verify(decorator, times(usedTop ? 1 : 0)).pickBlockDataTop(rng, data, coordinate, z);
|
||||
verify(decorator, times(usedBody ? 1 : 0)).pickBlockData(rng, runtime, coordinate, z);
|
||||
verify(decorator, times(usedTop ? 1 : 0)).pickBlockDataTop(rng, runtime, coordinate, z);
|
||||
assertEquals(controlRng.nextLong(), rng.nextLong());
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -592,7 +592,7 @@ public class HydrologyVegetationTest {
|
||||
for (int lz = 0; lz < 16; lz++) {
|
||||
int x = (chunkX << 4) + lx;
|
||||
int z = (chunkZ << 4) + lz;
|
||||
vegetation.decorate(chunk, lx, lz, x, z, role(x, z), this, data);
|
||||
vegetation.decorate(chunk, lx, lz, x, z, role(x, z), this, data.standalonePackRuntime());
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
@@ -664,7 +664,7 @@ public class HydrologyVegetationTest {
|
||||
for (int lz = 0; lz < 16; lz++) {
|
||||
int x = (chunkX << 4) + lx;
|
||||
int z = (chunkZ << 4) + lz;
|
||||
vegetation.decorate(chunk, lx, lz, x, z, role(x, z), this, data);
|
||||
vegetation.decorate(chunk, lx, lz, x, z, role(x, z), this, data.standalonePackRuntime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
@@ -18,13 +18,13 @@ public class IrisDecoratorHeightTest {
|
||||
when(generator.fit(eq(1), eq(2), anyDouble(), anyDouble())).thenReturn(2);
|
||||
IrisDecorator decorator = new IrisDecorator() {
|
||||
@Override
|
||||
public CNG getHeightGenerator(RNG rng, IrisData data) {
|
||||
public CNG getHeightGenerator(RNG rng, PackRuntime runtime) {
|
||||
return generator;
|
||||
}
|
||||
};
|
||||
decorator.setStackMin(1);
|
||||
decorator.setStackMax(2);
|
||||
|
||||
assertEquals(2, decorator.getHeight(new RNG(1L), 0, 0, mock(IrisData.class)));
|
||||
assertEquals(2, decorator.getHeight(new RNG(1L), 0, 0, PackRuntime.standalone(null)));
|
||||
}
|
||||
}
|
||||
+13
-9
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
@@ -21,6 +22,7 @@ public class IrisDecoratorPaletteSelectionTest {
|
||||
@Test
|
||||
public void multipleTopEntriesVaryEvenWhenTheBodyPaletteIsASingleBlock() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
PackRuntime runtime = PackRuntime.standalone(data);
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisDecorator decorator = spy(new IrisDecorator().setChance(1D));
|
||||
NativeBlockState body = mock(NativeBlockState.class);
|
||||
@@ -32,13 +34,13 @@ public class IrisDecoratorPaletteSelectionTest {
|
||||
RNG rng = new RNG(37L);
|
||||
doReturn(new KList<>(body)).when(decorator).getBlockData(data);
|
||||
doReturn(tops).when(decorator).getBlockDataTops(data);
|
||||
doReturn(chance).when(decorator).getGenerator(rng, data);
|
||||
doReturn(variance).when(decorator).getVarianceGenerator(rng, data);
|
||||
doReturn(chance).when(decorator).getGenerator(rng, runtime);
|
||||
doReturn(variance).when(decorator).getVarianceGenerator(rng, runtime);
|
||||
doReturn(second).when(variance).fit(tops, 23D, 9D, 17D);
|
||||
doReturn(first).when(variance).fit(tops, 24D, 9D, 17D);
|
||||
|
||||
assertSame(second, decorator.getBlockDataForTop(biome, rng, 17D, 9D, 23D, data));
|
||||
assertSame(first, decorator.getBlockDataForTop(biome, rng, 17D, 9D, 24D, data));
|
||||
assertSame(second, decorator.getBlockDataForTop(biome, rng, 17D, 9D, 23D, runtime));
|
||||
assertSame(first, decorator.getBlockDataForTop(biome, rng, 17D, 9D, 24D, runtime));
|
||||
verify(variance).fit(tops, 23D, 9D, 17D);
|
||||
verify(variance).fit(tops, 24D, 9D, 17D);
|
||||
}
|
||||
@@ -46,6 +48,7 @@ public class IrisDecoratorPaletteSelectionTest {
|
||||
@Test
|
||||
public void aSingleTopEntryDoesNotBuildOrSampleTheVarianceGenerator() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
PackRuntime runtime = PackRuntime.standalone(data);
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisDecorator decorator = spy(new IrisDecorator().setChance(1D));
|
||||
NativeBlockState firstBody = mock(NativeBlockState.class);
|
||||
@@ -54,16 +57,17 @@ public class IrisDecoratorPaletteSelectionTest {
|
||||
RNG rng = new RNG(37L);
|
||||
doReturn(new KList<>(firstBody, secondBody)).when(decorator).getBlockData(data);
|
||||
doReturn(new KList<>(top)).when(decorator).getBlockDataTops(data);
|
||||
doReturn(mock(CNG.class)).when(decorator).getGenerator(rng, data);
|
||||
doReturn(mock(CNG.class)).when(decorator).getGenerator(rng, runtime);
|
||||
|
||||
assertSame(top, decorator.getBlockDataForTop(biome, rng, 17D, 9D, 23D, data));
|
||||
verify(decorator, never()).getVarianceGenerator(rng, data);
|
||||
assertSame(top, decorator.getBlockDataForTop(biome, rng, 17D, 9D, 23D, runtime));
|
||||
verify(decorator, never()).getVarianceGenerator(rng, runtime);
|
||||
verify(decorator, times(1)).getBlockDataTops(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bodySamplingResolvesPaletteOnceAndPreservesCoordinatesAndRngConsumption() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
PackRuntime runtime = PackRuntime.standalone(data);
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisDecorator decorator = spy(new IrisDecorator());
|
||||
NativeBlockState first = mock(NativeBlockState.class);
|
||||
@@ -73,13 +77,13 @@ public class IrisDecoratorPaletteSelectionTest {
|
||||
RNG rng = new RNG(37L);
|
||||
RNG control = new RNG(37L);
|
||||
doReturn(palette).when(decorator).getBlockData(data);
|
||||
doReturn(variance).when(decorator).getVarianceGenerator(rng, data);
|
||||
doReturn(variance).when(decorator).getVarianceGenerator(rng, runtime);
|
||||
|
||||
for (int x = -8; x < 8; x++) {
|
||||
for (int y = 0; y < 4; y++) {
|
||||
double z = x * 3D - 2D;
|
||||
NativeBlockState expected = variance.fit(palette, z, y, x);
|
||||
assertSame(expected, decorator.getBlockData100(biome, rng, x, y, z, data));
|
||||
assertSame(expected, decorator.getBlockData100(biome, rng, x, y, z, runtime));
|
||||
}
|
||||
}
|
||||
verify(decorator, times(64)).getBlockData(data);
|
||||
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -113,6 +114,8 @@ public class IrisDecoratorSeedCohesionTest {
|
||||
|
||||
private Fixture(long seed, IrisDecorator decorator, IrisData data) {
|
||||
when(engine.getData()).thenReturn(data);
|
||||
PackRuntime runtime = PackRuntime.forEngine(engine, data);
|
||||
when(engine.getPackRuntime()).thenReturn(runtime);
|
||||
when(engine.getHeight()).thenReturn(32);
|
||||
when(engine.getSeedManager().getComponent()).thenReturn(seed);
|
||||
when(engine.getAllBiomes()).thenReturn(new KList<>(biome));
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -26,7 +27,7 @@ public class IrisDecoratorVarianceGeneratorTest {
|
||||
}
|
||||
|
||||
private double[] sampleSharedVarianceStyleGeneratorAfterVarianceBuilt() {
|
||||
decorator.getVarianceGenerator(new RNG(WORLD_SEED), packData);
|
||||
decorator.getVarianceGenerator(new RNG(WORLD_SEED), PackRuntime.of(packData.getEngine(), packData));
|
||||
return sampleSharedVarianceStyleGenerator(decorator.getVariance());
|
||||
}
|
||||
|
||||
|
||||
+52
-13
@@ -1,6 +1,9 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedManager;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.block.VectorMap;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
@@ -24,6 +27,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
@@ -163,17 +167,52 @@ public class IrisDepositTuningTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clumpCachesAreScopedByWorldSeedAndSize() {
|
||||
IrisDepositGenerator.ClumpCacheKey firstWorld =
|
||||
new IrisDepositGenerator.ClumpCacheKey(41L, 4, 8);
|
||||
IrisDepositGenerator.ClumpCacheKey secondWorld =
|
||||
new IrisDepositGenerator.ClumpCacheKey(42L, 4, 8);
|
||||
IrisDepositGenerator.ClumpCacheKey largerVein =
|
||||
new IrisDepositGenerator.ClumpCacheKey(41L, 8, 16);
|
||||
public void clumpVariantsAreScopedByWorldSeedAndSize() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisDepositGenerator generator = paletteGenerator(data).setMinSize(4).setMaxSize(8);
|
||||
DepositRuntime firstWorld = PackRuntime.forEngine(engineWithDepositSeed(41L), data).deposit(generator);
|
||||
DepositRuntime secondWorld = PackRuntime.forEngine(engineWithDepositSeed(42L), data).deposit(generator);
|
||||
DepositRuntime sameSeedWorld = PackRuntime.forEngine(engineWithDepositSeed(41L), data).deposit(generator);
|
||||
|
||||
assertNotEquals(firstWorld, secondWorld);
|
||||
assertNotEquals(firstWorld, largerVein);
|
||||
assertEquals(firstWorld, new IrisDepositGenerator.ClumpCacheKey(41L, 4, 8));
|
||||
assertSame(firstWorld.clumps(), firstWorld.clumps());
|
||||
assertSame(firstWorld.scaledClumps(4, 8), firstWorld.scaledClumps(4, 8));
|
||||
assertEquals(blocks(firstWorld.clumps()), blocks(sameSeedWorld.clumps()));
|
||||
assertNotEquals(blocks(firstWorld.clumps()), blocks(secondWorld.clumps()));
|
||||
assertNotEquals(blocks(firstWorld.scaledClumps(4, 8)), blocks(firstWorld.scaledClumps(8, 16)));
|
||||
assertNotEquals(blocks(firstWorld.clumps()), blocks(firstWorld.scaledClumps(4, 8)));
|
||||
}
|
||||
|
||||
private static IrisDepositGenerator paletteGenerator(IrisData data) {
|
||||
IrisDepositGenerator generator = new IrisDepositGenerator();
|
||||
for (String key : new String[]{"minecraft:iron_ore", "minecraft:gold_ore", "minecraft:copper_ore"}) {
|
||||
IrisBlockData block = mock(IrisBlockData.class);
|
||||
NativeBlockState state = mock(NativeBlockState.class);
|
||||
when(block.getBlockData(data)).thenReturn(state);
|
||||
when(state.key()).thenReturn(key);
|
||||
generator.getPalette().add(block);
|
||||
}
|
||||
return generator;
|
||||
}
|
||||
|
||||
private static Engine engineWithDepositSeed(long depositSeed) {
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(seeds.getDeposit()).thenReturn(depositSeed);
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
return engine;
|
||||
}
|
||||
|
||||
private static List<String> blocks(KList<IrisObject> clumps) {
|
||||
List<String> blocks = new ArrayList<>();
|
||||
for (IrisObject clump : clumps) {
|
||||
VectorMap<NativeBlockState>.Cursor cursor = clump.getBlocks().cursor();
|
||||
while (cursor.next()) {
|
||||
blocks.add(cursor.key().getBlockX() + "," + cursor.key().getBlockY() + ","
|
||||
+ cursor.key().getBlockZ() + "=" + cursor.value().key());
|
||||
}
|
||||
blocks.add("|");
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -237,7 +276,7 @@ public class IrisDepositTuningTest {
|
||||
generator.setMinSize(size).setMaxSize(size);
|
||||
for (long seed = 0; seed < 300; seed++) {
|
||||
RNG built = new RNG(seed);
|
||||
IrisObject clump = generator.getClump(null, built, data);
|
||||
IrisObject clump = generator.getClump(PackRuntime.standalone(data), built);
|
||||
RNG sampled = new RNG(seed);
|
||||
IrisDepositGenerator.ClumpFootprint footprint = generator.sampleClumpFootprint(sampled, data);
|
||||
assertNotNull(footprint);
|
||||
@@ -269,7 +308,7 @@ public class IrisDepositTuningTest {
|
||||
generator.setMinSize(size).setMaxSize(size);
|
||||
for (long seed = 0; seed < 300; seed++) {
|
||||
RNG built = new RNG(seed);
|
||||
IrisObject clump = generator.getClump(null, built, data);
|
||||
IrisObject clump = generator.getClump(PackRuntime.standalone(data), built);
|
||||
long expectedNext = built.nextLong();
|
||||
List<String> expected = new ArrayList<>();
|
||||
VectorMap<NativeBlockState>.Cursor cursor = clump.getBlocks().cursor();
|
||||
@@ -325,7 +364,7 @@ public class IrisDepositTuningTest {
|
||||
for (int size : new int[]{0, 1, 3, 4, 9, 17, 25, 64}) {
|
||||
generator.setMinSize(size).setMaxSize(size);
|
||||
for (long seed = 0; seed < 300; seed++) {
|
||||
IrisObject clump = generator.getClump(null, new RNG(seed), data);
|
||||
IrisObject clump = generator.getClump(PackRuntime.standalone(data), new RNG(seed));
|
||||
List<String> expected = new ArrayList<>();
|
||||
VectorMap<NativeBlockState>.Cursor cursor = clump.getBlocks().cursor();
|
||||
while (cursor.next()) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class IrisOreBandsTest {
|
||||
}
|
||||
for (int x = -3; x <= 3; x++) {
|
||||
assertSame("trial " + trial + " y " + y + " x " + x,
|
||||
scan(ores, x, y, 5 - x), bands.generate(x, y, 5 - x, RNG_SOURCE, null, null));
|
||||
scan(ores, x, y, 5 - x), bands.generate(x, y, 5 - x, RNG_SOURCE, PackRuntime.standalone(null)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,14 +79,14 @@ public class IrisOreBandsTest {
|
||||
int y = index % 101;
|
||||
int z = 400 - index * 11;
|
||||
NativeBlockState expected = reference.noise(x, y, z) > threshold ? null : ore;
|
||||
assertSame(expected, flat.generate(x, y, z, RNG_SOURCE, null));
|
||||
assertSame(expected, flat.generate(x, y, z, RNG_SOURCE, PackRuntime.standalone(null)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static NativeBlockState scan(KList<IrisOreGenerator> ores, int x, int y, int z) {
|
||||
for (IrisOreGenerator ore : ores) {
|
||||
NativeBlockState state = ore.generate(x, y, z, RNG_SOURCE, null);
|
||||
NativeBlockState state = ore.generate(x, y, z, RNG_SOURCE, PackRuntime.standalone(null));
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
@@ -110,10 +110,10 @@ public class IrisOreBandsTest {
|
||||
ores.add(generator(1D, 57D, 1D, 2L));
|
||||
ores.add(generator(58D, 58D, 1D, 3L));
|
||||
IrisOreBands bands = IrisOreBands.of(ores);
|
||||
assertSame(scan(ores, 0, 0, 0), bands.generate(0, 0, 0, RNG_SOURCE, null, null));
|
||||
assertSame(scan(ores, 0, 30, 0), bands.generate(0, 30, 0, RNG_SOURCE, null, null));
|
||||
assertSame(scan(ores, 0, 58, 0), bands.generate(0, 58, 0, RNG_SOURCE, null, null));
|
||||
assertNull(bands.contains(59) ? bands.generate(0, 59, 0, RNG_SOURCE, null, null) : null);
|
||||
assertSame(scan(ores, 0, 0, 0), bands.generate(0, 0, 0, RNG_SOURCE, PackRuntime.standalone(null)));
|
||||
assertSame(scan(ores, 0, 30, 0), bands.generate(0, 30, 0, RNG_SOURCE, PackRuntime.standalone(null)));
|
||||
assertSame(scan(ores, 0, 58, 0), bands.generate(0, 58, 0, RNG_SOURCE, PackRuntime.standalone(null)));
|
||||
assertNull(bands.contains(59) ? bands.generate(0, 59, 0, RNG_SOURCE, PackRuntime.standalone(null)) : null);
|
||||
}
|
||||
private static final class FixedPalette extends IrisMaterialPalette {
|
||||
private final NativeBlockState state;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class IrisOreGeneratorTest {
|
||||
Fixture fixture = new Fixture(0.0);
|
||||
fixture.generator.setThreshold(0.0);
|
||||
|
||||
assertNull(fixture.generator.generate(2, 40, 3, fixture.rng, null));
|
||||
assertNull(fixture.generator.generate(2, 40, 3, fixture.rng, PackRuntime.standalone(null)));
|
||||
verifyNoInteractions(fixture.noise, fixture.style);
|
||||
}
|
||||
|
||||
@@ -35,12 +35,12 @@ public class IrisOreGeneratorTest {
|
||||
Fixture fixture = new Fixture(0.5);
|
||||
fixture.generator.setThreshold(0.5);
|
||||
|
||||
assertSame(fixture.ore, fixture.generator.generate(2, 30, 3, fixture.rng, null));
|
||||
assertSame(fixture.ore, fixture.generator.generate(2, 80, 3, fixture.rng, null));
|
||||
assertNull(fixture.generator.generate(2, 29, 3, fixture.rng, null));
|
||||
assertNull(fixture.generator.generate(2, 81, 3, fixture.rng, null));
|
||||
assertSame(fixture.ore, fixture.generator.generate(2, 30, 3, fixture.rng, PackRuntime.standalone(null)));
|
||||
assertSame(fixture.ore, fixture.generator.generate(2, 80, 3, fixture.rng, PackRuntime.standalone(null)));
|
||||
assertNull(fixture.generator.generate(2, 29, 3, fixture.rng, PackRuntime.standalone(null)));
|
||||
assertNull(fixture.generator.generate(2, 81, 3, fixture.rng, PackRuntime.standalone(null)));
|
||||
fixture.generator.setThreshold(0.49);
|
||||
assertNull(fixture.generator.generate(2, 40, 3, fixture.rng, null));
|
||||
assertNull(fixture.generator.generate(2, 40, 3, fixture.rng, PackRuntime.standalone(null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ public class IrisOreGeneratorTest {
|
||||
Fixture fixture = new Fixture(1.0);
|
||||
fixture.generator.setThreshold(1.0);
|
||||
|
||||
assertSame(fixture.ore, fixture.generator.generate(2, 40, 3, fixture.rng, null));
|
||||
assertSame(fixture.ore, fixture.generator.generate(2, 40, 3, fixture.rng, PackRuntime.standalone(null)));
|
||||
}
|
||||
|
||||
private static final class Fixture {
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
@@ -36,7 +37,7 @@ public class IrisOreSeedCohesionTest {
|
||||
for (int i = SEEDS.length - 1; i >= 0; i--) {
|
||||
IrisOreGenerator cold = generator();
|
||||
long[] expected = sample(cold, new RNG(SEEDS[i]), data, false);
|
||||
shared.warm(new RNG(SEEDS[(i + 1) % SEEDS.length]), data);
|
||||
shared.warm(new RNG(SEEDS[(i + 1) % SEEDS.length]), PackRuntime.of(data.getEngine(), data));
|
||||
assertArrayEquals(expected, sample(shared, new RNG(SEEDS[i]), data, true));
|
||||
RNG consumed = new RNG(SEEDS[i]);
|
||||
for (int draw = 0; draw < 128; draw++) {
|
||||
@@ -93,7 +94,7 @@ public class IrisOreSeedCohesionTest {
|
||||
for (int index = 0; index < SAMPLES; index++) {
|
||||
int sample = reverse ? SAMPLES - index - 1 : index;
|
||||
NativeBlockState block = generator.generate(sample * 13 - 901,
|
||||
sample % 257, sample * 7 - 713, rng, data);
|
||||
sample % 257, sample * 7 - 713, rng, PackRuntime.of(data.getEngine(), data));
|
||||
output[sample] = block == null ? 0L : block.key().hashCode();
|
||||
}
|
||||
return output;
|
||||
|
||||
+11
-10
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.testsupport.MockPackData;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.mantle.EngineMantle;
|
||||
@@ -70,9 +71,9 @@ public class IrisShoreLineDecoratorTest {
|
||||
output, fixture.biome, FLUID_HEIGHT, output.getHeight());
|
||||
|
||||
assertSame(targetAir, output.get(0, FLUID_HEIGHT + 1, 0));
|
||||
verify(fixture.decorator).passesChanceGate(any(), anyDouble(), anyDouble(), eq(fixture.data));
|
||||
verify(fixture.decorator).passesChanceGate(any(), anyDouble(), anyDouble(), MockPackData.runtimeOf(fixture.data));
|
||||
verify(fixture.decorator, never()).getBlockData100(
|
||||
eq(fixture.biome), any(), anyDouble(), anyDouble(), anyDouble(), eq(fixture.data));
|
||||
eq(fixture.biome), any(), anyDouble(), anyDouble(), anyDouble(), MockPackData.runtimeOf(fixture.data));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,7 +89,7 @@ public class IrisShoreLineDecoratorTest {
|
||||
|
||||
assertSame(targetAir, output.get(0, FLUID_HEIGHT + 1, 0));
|
||||
verify(fixture.decorator, never()).getBlockData100(
|
||||
eq(fixture.biome), any(), anyDouble(), anyDouble(), anyDouble(), eq(fixture.data));
|
||||
eq(fixture.biome), any(), anyDouble(), anyDouble(), anyDouble(), MockPackData.runtimeOf(fixture.data));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -199,13 +200,13 @@ public class IrisShoreLineDecoratorTest {
|
||||
when(fixture.decorator.isStacking()).thenReturn(true);
|
||||
when(fixture.decorator.isScaleStack()).thenReturn(false);
|
||||
when(fixture.decorator.getStackMax()).thenReturn(2);
|
||||
when(fixture.decorator.getHeight(any(), anyDouble(), anyDouble(), eq(fixture.data))).thenReturn(2);
|
||||
when(fixture.decorator.getHeight(any(), anyDouble(), anyDouble(), MockPackData.runtimeOf(fixture.data))).thenReturn(2);
|
||||
when(fixture.decorator.getTopThreshold()).thenReturn(1D);
|
||||
when(fixture.decorator.getBlockDataArray(fixture.data)).thenReturn(new NativeBlockState[0]);
|
||||
when(fixture.decorator.getBlockDataTopsArray(fixture.data))
|
||||
.thenReturn(new NativeBlockState[]{waterloggedTop});
|
||||
when(fixture.decorator.getBlockDataForTop(
|
||||
eq(fixture.biome), any(), anyDouble(), anyDouble(), anyDouble(), eq(fixture.data)))
|
||||
eq(fixture.biome), any(), anyDouble(), anyDouble(), anyDouble(), MockPackData.runtimeOf(fixture.data)))
|
||||
.thenReturn(waterloggedTop);
|
||||
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, FLUID_HEIGHT + 3, 1);
|
||||
@@ -239,7 +240,7 @@ public class IrisShoreLineDecoratorTest {
|
||||
SeedManager seedManager = mock(SeedManager.class);
|
||||
IrisDimension dimension = mock(IrisDimension.class);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
IrisBiome biome = mock(IrisBiome.class);
|
||||
IrisDecorator decorator = mock(IrisDecorator.class);
|
||||
IrisSlopeClip slope = mock(IrisSlopeClip.class);
|
||||
@@ -263,11 +264,11 @@ public class IrisShoreLineDecoratorTest {
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(biome.getDecoratorBucket(IrisDecorationPart.SHORE_LINE))
|
||||
.thenReturn(new IrisDecorator[]{decorator});
|
||||
when(decorator.passesChanceGate(any(), anyDouble(), anyDouble(), eq(data))).thenReturn(true);
|
||||
when(decorator.passesChanceGate(any(), anyDouble(), anyDouble(), MockPackData.runtimeOf(data))).thenReturn(true);
|
||||
when(decorator.isForcePlace()).thenReturn(forcePlace);
|
||||
when(decorator.getSlopeCondition()).thenReturn(slope);
|
||||
when(slope.isDefault()).thenReturn(true);
|
||||
when(decorator.getBlockData100(eq(biome), any(), anyDouble(), anyDouble(), anyDouble(), eq(data)))
|
||||
when(decorator.getBlockData100(eq(biome), any(), anyDouble(), anyDouble(), anyDouble(), MockPackData.runtimeOf(data)))
|
||||
.thenReturn(decorant);
|
||||
|
||||
return new Fixture(new IrisShoreLineDecorator(engine), data, biome, decorator, decorant);
|
||||
@@ -282,10 +283,10 @@ public class IrisShoreLineDecoratorTest {
|
||||
when(fixture.decorator.isStacking()).thenReturn(true);
|
||||
when(fixture.decorator.isScaleStack()).thenReturn(true);
|
||||
when(fixture.decorator.getAbsoluteMaxStack()).thenReturn(3);
|
||||
when(fixture.decorator.getHeight(any(), anyDouble(), anyDouble(), eq(fixture.data))).thenReturn(100);
|
||||
when(fixture.decorator.getHeight(any(), anyDouble(), anyDouble(), MockPackData.runtimeOf(fixture.data))).thenReturn(100);
|
||||
when(fixture.decorator.getTopThreshold()).thenReturn(0.9D);
|
||||
when(fixture.decorator.getBlockDataForTop(eq(fixture.biome), any(), anyDouble(), anyDouble(),
|
||||
anyDouble(), eq(fixture.data))).thenReturn(top);
|
||||
anyDouble(), MockPackData.runtimeOf(fixture.data))).thenReturn(top);
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(1, 64, 1);
|
||||
for (int y = FLUID_HEIGHT + 1; y < output.getHeight(); y++) {
|
||||
output.set(0, y, 0, airState());
|
||||
|
||||
+5
-4
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
@@ -122,13 +123,13 @@ public class IrisSugarCanePlacementTest {
|
||||
int world = -16 + local;
|
||||
switch (placement) {
|
||||
case FLOATING_SINGLE -> DecoratorCore.placeFloatingSimple(decorator, local, local, world, world,
|
||||
3, 4, output, new RNG(1L), null, mantle);
|
||||
3, 4, output, new RNG(1L), PackRuntime.standalone(null), mantle);
|
||||
case FLOATING_STACK -> DecoratorCore.placeFloatingStacked(decorator, local, local, world, world,
|
||||
3, 4, output, new RNG(1L), null, mantle);
|
||||
3, 4, output, new RNG(1L), PackRuntime.standalone(null), mantle);
|
||||
case CEILING_SINGLE -> DecoratorCore.placeSingleAt(decorator, local, local, world, 4, world,
|
||||
output, new RNG(1L), null, false, mantle);
|
||||
output, new RNG(1L), PackRuntime.standalone(null), false, mantle);
|
||||
case CEILING_STACK -> DecoratorCore.placeStackDown(decorator, local, local, world, world,
|
||||
4, 0, output, new RNG(1L), null, 2, new DecoratorCore.PlaceOpts(), mantle);
|
||||
4, 0, output, new RNG(1L), PackRuntime.standalone(null), 2, new DecoratorCore.PlaceOpts(), mantle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ public class HydrologyVegetationSourceTest {
|
||||
return decorators;
|
||||
}
|
||||
};
|
||||
new HydrologyVegetation(3L, null).decorate(chunk, 8, 8, 8, 8, WaterRole.SHORE, water, data);
|
||||
new HydrologyVegetation(3L, null).decorate(chunk, 8, 8, 8, 8, WaterRole.SHORE, water, data.standalonePackRuntime());
|
||||
return ((PlantBlockState) chunk.get(8, 61, 8)).block();
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.testsupport.MockPackData;
|
||||
import art.arcane.iris.generation.runtime.EngineBackgroundTasks.BackgroundTaskDrain;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.decoration.IrisOreGenerator;
|
||||
@@ -75,7 +76,7 @@ public class IrisEngineGenerationCacheWarmTest {
|
||||
Fixture fixture = fixture();
|
||||
AtomicReference<Callable<Void>> queued = new AtomicReference<>();
|
||||
IllegalStateException expected = new IllegalStateException("cache warm failed");
|
||||
IrisData data = mock(IrisData.class);
|
||||
IrisData data = MockPackData.create();
|
||||
IrisOreGenerator ore = mock(IrisOreGenerator.class);
|
||||
IrisBiome biome = new IrisBiome();
|
||||
biome.setLoadKey("failing-ore");
|
||||
@@ -83,7 +84,7 @@ public class IrisEngineGenerationCacheWarmTest {
|
||||
when(fixture.engine().getData()).thenReturn(data);
|
||||
when(fixture.engine().getSeedManager()).thenReturn(mock(SeedManager.class));
|
||||
when(fixture.engine().getAllBiomes()).thenReturn(new KList<>(biome));
|
||||
doThrow(expected).when(ore).warm(any(RNG.class), same(data));
|
||||
doThrow(expected).when(ore).warm(any(RNG.class), MockPackData.runtimeOf(data));
|
||||
try (MockedStatic<J> scheduling = scheduler(queued);
|
||||
MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
fixture.engine().prepareGenerationCaches(IrisEngine.InitializationMode.WORLD_CREATION, System.nanoTime());
|
||||
|
||||
+5
-5
@@ -82,7 +82,7 @@ public class IrisDepositModifierContextTest {
|
||||
public void workerPreparationFailurePropagatesAfterAllScopesClose() throws Exception {
|
||||
try (Fixture fixture = new Fixture(mock(IrisEngine.class, RETURNS_DEEP_STUBS), true)) {
|
||||
GenerationClosedException failure = new GenerationClosedException("worker clump preparation failed");
|
||||
doThrow(failure).when(fixture.dimensionDeposit).getClump(any(), any(), any());
|
||||
doThrow(failure).when(fixture.dimensionDeposit).getClump(any(), any());
|
||||
assertSame(failure, assertThrows(GenerationClosedException.class, () ->
|
||||
fixture.modifier.modify(32, -48, Hunk.newArrayHunk(16, 16, 16), true, fixture.context)));
|
||||
verify(fixture.chunk).release();
|
||||
@@ -94,7 +94,7 @@ public class IrisDepositModifierContextTest {
|
||||
@Test
|
||||
public void contentFailureInOneClumpSkipsItAndTheChunkContinues() throws Exception {
|
||||
try (Fixture fixture = new Fixture(mock(IrisEngine.class, RETURNS_DEEP_STUBS), true)) {
|
||||
doThrow(new IllegalArgumentException("bad clump")).when(fixture.dimensionDeposit).getClump(any(), any(), any());
|
||||
doThrow(new IllegalArgumentException("bad clump")).when(fixture.dimensionDeposit).getClump(any(), any());
|
||||
fixture.modifier.modify(32, -48, Hunk.newArrayHunk(16, 16, 16), true, fixture.context);
|
||||
verify(fixture.chunk).release();
|
||||
assertNull(IrisContext.get());
|
||||
@@ -127,7 +127,7 @@ public class IrisDepositModifierContextTest {
|
||||
RejectedExecutionException secondWorker = new RejectedExecutionException("second worker failure");
|
||||
when(fixture.dimensionDeposit.getMinPerChunk()).thenReturn(200);
|
||||
when(fixture.dimensionDeposit.getMaxPerChunk()).thenReturn(200);
|
||||
doThrow(firstWorker, secondWorker).when(fixture.dimensionDeposit).getClump(any(), any(), any());
|
||||
doThrow(firstWorker, secondWorker).when(fixture.dimensionDeposit).getClump(any(), any());
|
||||
assertSame(firstWorker, assertThrows(GenerationClosedException.class, () ->
|
||||
fixture.modifier.modify(32, -48, Hunk.newArrayHunk(16, 16, 16), true, fixture.context)));
|
||||
assertEquals(1, firstWorker.getSuppressed().length);
|
||||
@@ -154,7 +154,7 @@ public class IrisDepositModifierContextTest {
|
||||
|
||||
verify(generator, times(4)).getPerClumpSpawnChance();
|
||||
verify(rng, times(1)).i(0, 5);
|
||||
verify(generator, never()).getClump(any(), any(), any());
|
||||
verify(generator, never()).getClump(any(), any());
|
||||
}
|
||||
|
||||
private static final class Fixture implements AutoCloseable {
|
||||
@@ -222,7 +222,7 @@ public class IrisDepositModifierContextTest {
|
||||
assertEquals(71L, IrisContext.require().getGenerationSessionId());
|
||||
completed.incrementAndGet();
|
||||
return clump;
|
||||
}).when(generator).getClump(any(), any(), any());
|
||||
}).when(generator).getClump(any(), any());
|
||||
}
|
||||
when(dimensionDeposit.getMinPerChunk()).thenReturn(9);
|
||||
when(dimensionDeposit.getMaxPerChunk()).thenReturn(9);
|
||||
|
||||
+1
-1
@@ -359,7 +359,7 @@ public class IrisDepositModifierOrderingTest {
|
||||
clump.getBlocks().put(new IrisBlockVector(x, 0, z), replacement);
|
||||
}
|
||||
}
|
||||
when(generator.getClump(any(), any(), any())).thenAnswer(invocation -> {
|
||||
when(generator.getClump(any(), any())).thenAnswer(invocation -> {
|
||||
if (reverse && name.equals("dimension")) {
|
||||
assertTrue(regionReady.await(10, TimeUnit.SECONDS));
|
||||
} else if (reverse && name.equals("region")) {
|
||||
|
||||
+5
-2
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.stage;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.testsupport.KeyedBlockState;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
@@ -277,6 +278,8 @@ public class IrisDepositModifierParityTest {
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getDimensionStackContext()).thenReturn(null);
|
||||
}
|
||||
PackRuntime runtime = PackRuntime.forEngine(engine, engine.getData());
|
||||
when(engine.getPackRuntime()).thenReturn(runtime);
|
||||
when(engine.getCaveBiome(anyInt(), anyInt(), anyInt(), any())).thenAnswer(invocation -> {
|
||||
caveBiomeLookups.incrementAndGet();
|
||||
int x = invocation.getArgument(0);
|
||||
@@ -564,9 +567,9 @@ public class IrisDepositModifierParityTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject getClump(Engine engine, RNG rng, IrisData data) {
|
||||
public IrisObject getClump(PackRuntime runtime, RNG rng) {
|
||||
clumps.incrementAndGet();
|
||||
return super.getClump(engine, rng, data);
|
||||
return super.getClump(runtime, rng);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ public class IrisDepositModifierPoolGuardTest {
|
||||
clump.getBlocks().put(new IrisBlockVector(x, 0, z), gravel);
|
||||
}
|
||||
}
|
||||
when(generator.getClump(any(), any(), any())).thenReturn(clump);
|
||||
when(generator.getClump(any(), any())).thenReturn(clump);
|
||||
return generator;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -359,7 +359,7 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
|
||||
private NativeBlockState scan(KList<IrisOreGenerator> ores, int x, int y, int z) {
|
||||
for (IrisOreGenerator ore : ores) {
|
||||
NativeBlockState state = ore.generate(x, y, z, rng, data);
|
||||
NativeBlockState state = ore.generate(x, y, z, rng, PackRuntime.standalone(data));
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -196,12 +196,6 @@ public class PackRuntimeStateGateTest {
|
||||
);
|
||||
|
||||
private static final List<Entry> PENDING_MIGRATION = List.of(
|
||||
pending("art.arcane.iris.generation.decoration.IrisDecorator", "generators", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.decoration.IrisDecorator", "recentGenerators", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.decoration.IrisDepositGenerator", "objects", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.decoration.IrisDepositGenerator", "scaledObjects", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.decoration.IrisOreGenerator", "chanceCache", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.decoration.IrisOreGenerator", "recentChance", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.structure.object.IrisObjectPlacement", "surfaceWarpCache", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.structure.object.IrisObjectReplace", "replaceGen", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.world.entity.IrisEffect", "latch", Kind.RUNTIME),
|
||||
@@ -229,8 +223,6 @@ public class PackRuntimeStateGateTest {
|
||||
pending("art.arcane.iris.world.history.TransitionBandIndex", "lastRegion", Kind.THREAD),
|
||||
pending("art.arcane.iris.world.history.TransitionBoundarySampler", "cache", Kind.THREAD),
|
||||
pending("art.arcane.iris.world.history.TransitionDisplacementField", "local", Kind.THREAD),
|
||||
pending("art.arcane.iris.generation.decoration.IrisDecorator$GeneratorKey", "engine", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.decoration.IrisOreGenerator$ChanceKey", "engine", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.structure.object.IrisObjectPlacement$SurfaceWarpCacheKey", "engine", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.bake.ChunkBakeCache", "SPARSE", Kind.SCRATCH),
|
||||
pending("art.arcane.iris.generation.context.IrisContext", "OVERFLOW", Kind.SCRATCH),
|
||||
|
||||
@@ -114,7 +114,7 @@ public class IrisStructureStrataTest {
|
||||
when(biome.getSurfaceOreBands()).thenReturn(IrisOreBands.EMPTY);
|
||||
when(biome.getUndergroundOreBands()).thenReturn(bands);
|
||||
when(bands.contains(anyInt())).thenReturn(true);
|
||||
when(bands.generate(eq(3), eq(40 - MIN_HEIGHT), eq(5), any(RNG.class), eq(data), any())).thenReturn(coal);
|
||||
when(bands.generate(eq(3), eq(40 - MIN_HEIGHT), eq(5), any(RNG.class), MockPackData.runtimeOf(data))).thenReturn(coal);
|
||||
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
|
||||
Reference in new issue
Block a user