mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-06 15:56:27 +00:00
Spawners in objects closes
This commit is contained in:
@@ -21,6 +21,7 @@ package com.volmit.iris.engine;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.*;
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
@@ -113,6 +114,7 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
effects = new IrisEngineEffects(this);
|
||||
art = J.ar(effects::tickRandomPlayer, 0);
|
||||
J.a(this::computeBiomeMaxes);
|
||||
Iris.callEvent(new IrisEngineHotloadEvent(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -289,6 +291,7 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
|
||||
@Override
|
||||
public void hotload() {
|
||||
Iris.callEvent(new IrisEngineHotloadEvent(this));
|
||||
getEngineData().getStatistics().hotloaded();
|
||||
cacheId = RNG.r.nextInt();
|
||||
}
|
||||
|
||||
@@ -91,7 +91,10 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
for (int ig = 0; ig < data.get(i).size() / 8; ig++) {
|
||||
spawnIn(data.get(i).getRandom(), i, maxGroups);
|
||||
Chunk c = data.get(i).getRandom();
|
||||
IrisBiome biome = getEngine().getSurfaceBiome(c);
|
||||
IrisRegion region = getEngine().getRegion(c);
|
||||
spawnIn(c, biome, region, i, maxGroups);
|
||||
spawnCooldowns.put(i, M.ms());
|
||||
}
|
||||
}
|
||||
@@ -101,25 +104,32 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnIn(Chunk c, UUID id, int max) {
|
||||
private void spawnIn(Chunk c, IrisBiome biome, IrisRegion region, UUID id, int max) {
|
||||
if (c.getEntities().length > 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
//@builder
|
||||
puffen(Stream.concat(getData().getSpawnerLoader().loadAll(getDimension().getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap(this::stream),
|
||||
Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap(this::stream),
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap(this::stream)))
|
||||
.collect(Collectors.toList()))
|
||||
.popRandom(RNG.r, max).forEach((i) -> spawn(c, id, i));
|
||||
spawnRandomly(Stream.concat(Stream.concat(
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getDimension().getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn),
|
||||
getData().getSpawnerLoader().streamAll(getEngine().getFramework().getEngineParallax()
|
||||
.getFeaturesInChunk(c).stream()
|
||||
.flatMap((o) -> o.getFeature().getEntitySpawners().stream()))
|
||||
.filter(this::canSpawn))
|
||||
.filter((i) -> i.isValid(biome))
|
||||
.flatMap(this::stream),
|
||||
Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap(this::stream),
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap(this::stream)))
|
||||
.collect(Collectors.toList()))
|
||||
.popRandom(RNG.r, max).forEach((i) -> spawn(c, id, i));
|
||||
//@done
|
||||
}
|
||||
|
||||
@@ -138,7 +148,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
return s.getSpawns().stream();
|
||||
}
|
||||
|
||||
private KList<IrisEntitySpawn> puffen(List<IrisEntitySpawn> types) {
|
||||
private KList<IrisEntitySpawn> spawnRandomly(List<IrisEntitySpawn> types) {
|
||||
KList<IrisEntitySpawn> rarityTypes = new KList<>();
|
||||
int totalRarity = 0;
|
||||
for (IrisEntitySpawn i : types) {
|
||||
@@ -153,7 +163,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
public boolean canSpawn(IrisSpawner i) {
|
||||
return i.isValid(getEngine().getWorld().realWorld()) && getCooldown(i).canSpawn(i.getMaximumRate());
|
||||
return i.isValid(getEngine().getWorld().realWorld())
|
||||
&& getCooldown(i).canSpawn(i.getMaximumRate());
|
||||
}
|
||||
|
||||
private IrisEngineSpawnerCooldown getCooldown(IrisSpawner i) {
|
||||
|
||||
@@ -174,7 +174,12 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
default int getHeight(int x, int z) {
|
||||
return getFramework().getEngineParallax().getHighest(x, z, getData(), true);
|
||||
return getHeight(x, z, true);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default int getHeight(int x, int z, boolean ignoreFluid) {
|
||||
return getFramework().getEngineParallax().getHighest(x, z, getData(), ignoreFluid);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@@ -407,4 +412,14 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
IrisBiome getFocus();
|
||||
|
||||
IrisEngineData getEngineData();
|
||||
|
||||
default IrisBiome getSurfaceBiome(Chunk c)
|
||||
{
|
||||
return getSurfaceBiome((c.getX()<<4) + 8, (c.getZ()<<4) + 8);
|
||||
}
|
||||
|
||||
default IrisRegion getRegion(Chunk c)
|
||||
{
|
||||
return getRegion((c.getX()<<4) + 8, (c.getZ()<<4) + 8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,26 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
}
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default KList<IrisFeaturePositional> getFeaturesInChunk(int x, int z)
|
||||
{
|
||||
KList<IrisFeaturePositional> pos = new KList<>();
|
||||
|
||||
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) {
|
||||
if (i.shouldFilter((x<<4) + 8, (z<<4) + 8, getEngine().getFramework().getComplex().getRng(), getData())) {
|
||||
pos.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisFeaturePositional i : getParallaxAccess().getMetaR(x, z).getFeatures()) {
|
||||
if (i.shouldFilter((x<<4) + 8, (z<<4) + 8, getEngine().getFramework().getComplex().getRng(), getData())) {
|
||||
pos.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default KList<IrisFeaturePositional> forEachFeature(double x, double z) {
|
||||
KList<IrisFeaturePositional> pos = new KList<>();
|
||||
@@ -456,10 +476,10 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
return placeAfter;
|
||||
}
|
||||
|
||||
default void generateParallaxSurface(RNG rng, int x, int z, IrisBiome biome, IrisRegion region, boolean vacuum) {
|
||||
default void generateParallaxSurface(RNG rng, int x, int z, IrisBiome biome, IrisRegion region, boolean useFeatures) {
|
||||
|
||||
for (IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
||||
if (i.isVacuum() != vacuum) {
|
||||
if (i.usesFeatures() != useFeatures) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -477,7 +497,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement i : region.getSurfaceObjects()) {
|
||||
if (i.isVacuum() != vacuum) {
|
||||
if (i.usesFeatures() != useFeatures) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -495,7 +515,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
}
|
||||
}
|
||||
|
||||
default void generateParallaxMutations(RNG rng, int x, int z, boolean vacuum) {
|
||||
default void generateParallaxMutations(RNG rng, int x, int z, boolean useFeatures) {
|
||||
if (getEngine().getDimension().getMutations().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -512,7 +532,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
|
||||
if (k.getRealSideA(this).contains(sa.getLoadKey()) && k.getRealSideB(this).contains(sb.getLoadKey())) {
|
||||
for (IrisObjectPlacement m : k.getObjects()) {
|
||||
if (m.isVacuum() != vacuum) {
|
||||
if (m.usesFeatures() != useFeatures) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -547,16 +567,43 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
|
||||
}, null, getData());
|
||||
|
||||
if (p.isVacuum()) {
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
IrisFeature f = new IrisFeature();
|
||||
f.setConvergeToHeight(h - (v.getH() >> 1));
|
||||
f.setBlockRadius(a);
|
||||
f.setInterpolationRadius(a / 4);
|
||||
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
||||
f.setStrength(1D);
|
||||
getParallaxAccess().getMetaRW(xx >> 4, zz >> 4).getFeatures().add(new IrisFeaturePositional(xx, zz, f));
|
||||
if(p.usesFeatures())
|
||||
{
|
||||
if (p.isVacuum()) {
|
||||
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
IrisFeature f = new IrisFeature();
|
||||
f.setConvergeToHeight(h - (v.getH() >> 1));
|
||||
f.setBlockRadius(a);
|
||||
f.setInterpolationRadius(p.getVacuumInterpolationRadius());
|
||||
f.setInterpolator(p.getVacuumInterpolationMethod());
|
||||
f.setStrength(1D);
|
||||
|
||||
for (IrisFeaturePositional j : rw.getFeatures()) {
|
||||
if (j.getX() == xx && j.getZ() == zz) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rw.getFeatures().add(new IrisFeaturePositional(xx, zz, f));
|
||||
}
|
||||
|
||||
for(IrisFeaturePotential j : p.getAddFeatures())
|
||||
{
|
||||
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
|
||||
for (IrisFeaturePositional k : rw.getFeatures()) {
|
||||
if (k.getX() == xx && k.getZ() == zz) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rw.getFeatures().add(new IrisFeaturePositional(xx, zz, j.getZone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
default void place(RNG rng, int x, int forceY, int z, IrisObjectPlacement objectPlacement) {
|
||||
@@ -582,23 +629,40 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
|
||||
}, null, getData());
|
||||
|
||||
if (objectPlacement.isVacuum()) {
|
||||
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
IrisFeature f = new IrisFeature();
|
||||
f.setConvergeToHeight(h - (v.getH() >> 1));
|
||||
f.setBlockRadius(a);
|
||||
f.setInterpolationRadius(objectPlacement.getVacuumInterpolationRadius());
|
||||
f.setInterpolator(objectPlacement.getVacuumInterpolationMethod());
|
||||
f.setStrength(1D);
|
||||
if(objectPlacement.usesFeatures())
|
||||
{
|
||||
if (objectPlacement.isVacuum()) {
|
||||
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
IrisFeature f = new IrisFeature();
|
||||
f.setConvergeToHeight(h - (v.getH() >> 1));
|
||||
f.setBlockRadius(a);
|
||||
f.setInterpolationRadius(objectPlacement.getVacuumInterpolationRadius());
|
||||
f.setInterpolator(objectPlacement.getVacuumInterpolationMethod());
|
||||
f.setStrength(1D);
|
||||
|
||||
for (IrisFeaturePositional j : rw.getFeatures()) {
|
||||
if (j.getX() == xx && j.getZ() == zz) {
|
||||
continue placing;
|
||||
for (IrisFeaturePositional j : rw.getFeatures()) {
|
||||
if (j.getX() == xx && j.getZ() == zz) {
|
||||
continue placing;
|
||||
}
|
||||
}
|
||||
|
||||
rw.getFeatures().add(new IrisFeaturePositional(xx, zz, f));
|
||||
}
|
||||
|
||||
rw.getFeatures().add(new IrisFeaturePositional(xx, zz, f));
|
||||
for(IrisFeaturePotential j : objectPlacement.getAddFeatures())
|
||||
{
|
||||
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
|
||||
for (IrisFeaturePositional k : rw.getFeatures()) {
|
||||
if (k.getX() == xx && k.getZ() == zz) {
|
||||
continue placing;
|
||||
}
|
||||
}
|
||||
|
||||
rw.getFeatures().add(new IrisFeaturePositional(xx, zz, j.getZone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -886,4 +950,10 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
default void close() {
|
||||
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default KList<IrisFeaturePositional> getFeaturesInChunk(Chunk c)
|
||||
{
|
||||
return getFeaturesInChunk(c.getX(), c.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
public KList<Runnable> place(IObjectPlacer placer, EngineParallaxManager e) {
|
||||
Iris.info("PLACED JIGSAW");
|
||||
KList<Runnable> after = new KList<>();
|
||||
IrisObjectPlacement options = new IrisObjectPlacement();
|
||||
options.getRotation().setEnabled(false);
|
||||
|
||||
@@ -105,6 +105,10 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
}
|
||||
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz) {
|
||||
return genCaves(wxx, wzz, 0, 0, null);
|
||||
}
|
||||
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data) {
|
||||
if (!getDimension().isCaves()) {
|
||||
return EMPTY;
|
||||
|
||||
@@ -38,10 +38,8 @@ public enum InferredType {
|
||||
RIVER,
|
||||
|
||||
@Desc("Represents any lake biome type")
|
||||
|
||||
LAKE,
|
||||
|
||||
@Desc("Defers the type to whatever another biome type that already exists is.")
|
||||
|
||||
DEFER
|
||||
}
|
||||
|
||||
@@ -19,13 +19,20 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.data.B;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisPostModifier;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.common.CaveResult;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -34,7 +41,14 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Slab;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@@ -65,19 +79,47 @@ public class IrisEntitySpawn implements IRare {
|
||||
|
||||
public boolean spawn(Engine gen, Chunk c, RNG rng) {
|
||||
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
|
||||
int s = 0;
|
||||
|
||||
if (spawns > 0) {
|
||||
for (int i = 0; i < spawns; i++) {
|
||||
for (int id = 0; id < spawns; id++) {
|
||||
int x = (c.getX() * 16) + rng.i(15);
|
||||
int z = (c.getZ() * 16) + rng.i(15);
|
||||
int h = c.getWorld().getHighestBlockYAt(x, z);
|
||||
spawn100(gen, new Location(c.getWorld(), x, h, z));
|
||||
}
|
||||
int h = gen.getHeight(x, z, true);
|
||||
int hf = gen.getHeight(x, z, false);
|
||||
Location l = switch(getReferenceSpawner().getGroup())
|
||||
{
|
||||
case NORMAL -> new Location(c.getWorld(), x, hf+1, z);
|
||||
case CAVE -> {
|
||||
IrisComplex comp = gen.getFramework().getComplex();
|
||||
EngineFramework frame = gen.getFramework();
|
||||
IrisBiome cave = comp.getCaveBiomeStream().get(x, z);
|
||||
KList<Location> r = new KList<>();
|
||||
if (cave != null) {
|
||||
for (CaveResult i : ((IrisCaveModifier) frame.getCaveModifier()).genCaves(x, z)) {
|
||||
if (i.getCeiling() >= gen.getHeight() || i.getFloor() < 0 || i.getCeiling()-2 <= i.getFloor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
r.add(new Location(c.getWorld(), x, i.getFloor(), z));
|
||||
}
|
||||
}
|
||||
|
||||
yield r.getRandom(rng);
|
||||
}
|
||||
|
||||
case UNDERWATER, BEACH -> new Location(c.getWorld(), x, rng.i(h+1, hf), z);
|
||||
};
|
||||
|
||||
if(l != null)
|
||||
{
|
||||
spawn100(gen, l);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return s>0;
|
||||
}
|
||||
|
||||
public IrisEntity getRealEntity(Engine g) {
|
||||
|
||||
@@ -98,8 +98,8 @@ public class IrisExpression extends IrisRegistrant {
|
||||
}
|
||||
|
||||
g[m++] = x;
|
||||
g[m++] = -1;
|
||||
g[m] = z;
|
||||
g[m++] = z;
|
||||
g[m] = -1;
|
||||
|
||||
return expression().evaluate(g);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -81,6 +82,11 @@ public class IrisFeature {
|
||||
@Desc("Fracture the radius ring with additional noise")
|
||||
private IrisGeneratorStyle fractureRadius = null;
|
||||
|
||||
@RegistryListResource(IrisSpawner.class)
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Within this noise feature, use the following spawners")
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
|
||||
private transient AtomicCache<Double> actualRadius = new AtomicCache<>();
|
||||
|
||||
public double getActualRadius() {
|
||||
|
||||
@@ -210,10 +210,15 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public double getHeight(double rx, double rz, long superSeed) {
|
||||
return getHeight(rx, 0, rz, superSeed);
|
||||
return getHeight(rx, 0, rz, superSeed, true);
|
||||
}
|
||||
|
||||
|
||||
public double getHeight(double rx, double ry, double rz, long superSeed) {
|
||||
return getHeight(rx, ry, rz, superSeed, false);
|
||||
}
|
||||
|
||||
public double getHeight(double rx, double ry, double rz, long superSeed, boolean no3d) {
|
||||
if (composite.isEmpty()) {
|
||||
Iris.warn("Useless Generator: Composite is empty in " + getLoadKey());
|
||||
return 0;
|
||||
@@ -235,7 +240,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
double v = multiplicitive ? h * opacity : (h / tp) * opacity;
|
||||
|
||||
if (Double.isNaN(v)) {
|
||||
Iris.warn("Nan value on gen: " + getLoadKey() + ": H = " + h + " TP = " + tp + " OPACITY = " + opacity + " ZOOM = " + zoom);
|
||||
v = 0;
|
||||
}
|
||||
|
||||
v = hasCliffs() ? cliff(rx, rz, v, superSeed + 294596 + hc) : v;
|
||||
|
||||
@@ -58,6 +58,10 @@ public class IrisObjectPlacement {
|
||||
@Desc("Limit the max height or min height of placement.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@ArrayType(min = 1, type = IrisFeaturePotential.class)
|
||||
@Desc("Place additional noise features in the object's place location")
|
||||
private KList<IrisFeaturePotential> addFeatures = new KList<>();
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.")
|
||||
@@ -161,6 +165,7 @@ public class IrisObjectPlacement {
|
||||
p.setWarp(warp);
|
||||
p.setBore(bore);
|
||||
p.setMeld(meld);
|
||||
p.setAddFeatures(addFeatures.copy());
|
||||
p.setWaterloggable(waterloggable);
|
||||
p.setOnwater(onwater);
|
||||
p.setSmartBore(smartBore);
|
||||
@@ -213,6 +218,11 @@ public class IrisObjectPlacement {
|
||||
return getMode().equals(ObjectPlaceMode.VACUUM);
|
||||
}
|
||||
|
||||
public boolean usesFeatures()
|
||||
{
|
||||
return isVacuum() || getAddFeatures().isNotEmpty();
|
||||
}
|
||||
|
||||
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
|
||||
|
||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 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 com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Terrain modes are used to decide the generator type currently used")
|
||||
public enum IrisSpawnGroup {
|
||||
@Desc("Spawns on the terrain surface")
|
||||
NORMAL,
|
||||
|
||||
@Desc("Spawns in cave-air and low light level areas")
|
||||
CAVE,
|
||||
|
||||
@Desc("Spawns underwater")
|
||||
UNDERWATER,
|
||||
|
||||
@Desc("Spawns in beaches")
|
||||
BEACH
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -48,6 +49,29 @@ public class IrisSpawner extends IrisRegistrant {
|
||||
@Desc("The maximum rate this spawner can fire")
|
||||
private IrisRate maximumRate = new IrisRate();
|
||||
|
||||
@Desc("Where should these spawns be placed")
|
||||
private IrisSpawnGroup group = IrisSpawnGroup.NORMAL;
|
||||
|
||||
public boolean isValid(IrisBiome biome)
|
||||
{
|
||||
return switch (group)
|
||||
{
|
||||
case NORMAL -> switch(biome.getInferredType()) {
|
||||
case SHORE, SEA, CAVE, RIVER, LAKE, DEFER -> false;
|
||||
case LAND -> true;
|
||||
};
|
||||
case CAVE -> true;
|
||||
case UNDERWATER -> switch(biome.getInferredType()) {
|
||||
case SHORE, LAND, CAVE, RIVER, LAKE, DEFER -> false;
|
||||
case SEA -> true;
|
||||
};
|
||||
case BEACH -> switch(biome.getInferredType()) {
|
||||
case SHORE -> true;
|
||||
case LAND, CAVE, RIVER, LAKE, SEA, DEFER -> false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isValid(World world) {
|
||||
return timeBlock.isWithin(world) && weather.is(world);
|
||||
}
|
||||
|
||||
@@ -20,82 +20,103 @@ package com.volmit.iris.engine.parallax;
|
||||
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.object.tile.TileData;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface ParallaxAccess {
|
||||
@BlockCoordinates
|
||||
default BlockData getBlock(int x, int y, int z) {
|
||||
return getBlocksR(x >> 4, z >> 4).get(x & 15, y, z & 15);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default void setBlock(int x, int y, int z, BlockData d) {
|
||||
getBlocksRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default TileData<? extends TileState> getTile(int x, int y, int z) {
|
||||
return getTilesR(x >> 4, z >> 4).get(x & 15, y, z & 15);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default void setTile(int x, int y, int z, TileData<? extends TileState> d) {
|
||||
getTilesRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default String getObject(int x, int y, int z) {
|
||||
return getObjectsR(x >> 4, z >> 4).get(x & 15, y, z & 15);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default void setObject(int x, int y, int z, String d) {
|
||||
getObjectsRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default String getEntity(int x, int y, int z) {
|
||||
return getEntitiesR(x >> 4, z >> 4).get(x & 15, y, z & 15);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default void setEntity(int x, int y, int z, String d) {
|
||||
getEntitiesRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default Boolean isUpdate(int x, int y, int z) {
|
||||
return getUpdatesR(x >> 4, z >> 4).get(x & 15, y, z & 15);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default void updateBlock(int x, int y, int z) {
|
||||
setUpdate(x, y, z, true);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default void setUpdate(int x, int y, int z, boolean d) {
|
||||
getUpdatesRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default boolean isParallaxGenerated(int x, int z) {
|
||||
return getMetaR(x, z).isParallaxGenerated();
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default boolean isChunkGenerated(int x, int z) {
|
||||
return getMetaR(x, z).isGenerated();
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default boolean isFeatureGenerated(int x, int z) {
|
||||
return getMetaR(x, z).isFeatureGenerated();
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void setParallaxGenerated(int x, int z) {
|
||||
setParallaxGenerated(x, z, true);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void setChunkGenerated(int x, int z) {
|
||||
setChunkGenerated(x, z, true);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void setFeatureGenerated(int x, int z) {
|
||||
setFeatureGenerated(x, z, true);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void setParallaxGenerated(int x, int z, boolean v) {
|
||||
getMetaRW(x, z).setParallaxGenerated(v);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void maxMin(int x, int z, int value) {
|
||||
ParallaxChunkMeta meat = getMetaRW(x, z);
|
||||
|
||||
@@ -112,36 +133,50 @@ public interface ParallaxAccess {
|
||||
}
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void setChunkGenerated(int x, int z, boolean v) {
|
||||
getMetaRW(x, z).setGenerated(v);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void setFeatureGenerated(int x, int z, boolean v) {
|
||||
getMetaRW(x, z).setFeatureGenerated(v);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<TileData<? extends TileState>> getTilesR(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<TileData<? extends TileState>> getTilesRW(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<BlockData> getBlocksR(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<BlockData> getBlocksRW(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<String> getObjectsR(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<String> getObjectsRW(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<String> getEntitiesRW(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<String> getEntitiesR(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<Boolean> getUpdatesR(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
Hunk<Boolean> getUpdatesRW(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
ParallaxChunkMeta getMetaR(int x, int z);
|
||||
|
||||
@ChunkCoordinates
|
||||
ParallaxChunkMeta getMetaRW(int x, int z);
|
||||
|
||||
void cleanup(long regionIdle, long chunkIdle);
|
||||
@@ -156,6 +191,7 @@ public interface ParallaxAccess {
|
||||
|
||||
int getChunkCount();
|
||||
|
||||
@ChunkCoordinates
|
||||
default void delete(int x, int z) {
|
||||
getUpdatesRW(x, z).empty(false);
|
||||
getBlocksRW(x, z).empty(null);
|
||||
|
||||
Reference in New Issue
Block a user