9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00

Cleanup sources

This commit is contained in:
Daniel Mills
2021-08-03 01:40:35 -04:00
parent 51a056b3d7
commit 43d7dfde4c
11 changed files with 59 additions and 92 deletions

View File

@@ -91,7 +91,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
for (int ig = 0; ig < data.get(i).size() / 8; ig++) {
Chunk c = data.get(i).getRandom();
Chunk c = data.get(i).getRandom();
IrisBiome biome = getEngine().getSurfaceBiome(c);
IrisRegion region = getEngine().getRegion(c);
spawnIn(c, biome, region, i, maxGroups);
@@ -111,25 +111,25 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
//@builder
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));
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
}

View File

@@ -413,13 +413,11 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
IrisEngineData getEngineData();
default IrisBiome getSurfaceBiome(Chunk c)
{
return getSurfaceBiome((c.getX()<<4) + 8, (c.getZ()<<4) + 8);
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);
default IrisRegion getRegion(Chunk c) {
return getRegion((c.getX() << 4) + 8, (c.getZ() << 4) + 8);
}
}

View File

@@ -25,7 +25,6 @@ import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.data.B;
import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.engine.interpolation.InterpolationMethod;
import com.volmit.iris.engine.jigsaw.PlannedStructure;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.common.IObjectPlacer;
@@ -198,18 +197,17 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
}
@ChunkCoordinates
default KList<IrisFeaturePositional> getFeaturesInChunk(int x, int z)
{
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())) {
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())) {
if (i.shouldFilter((x << 4) + 8, (z << 4) + 8, getEngine().getFramework().getComplex().getRng(), getData())) {
pos.add(i);
}
}
@@ -567,8 +565,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
}, null, getData());
if(p.usesFeatures())
{
if (p.usesFeatures()) {
if (p.isVacuum()) {
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD());
@@ -588,8 +585,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
rw.getFeatures().add(new IrisFeaturePositional(xx, zz, f));
}
for(IrisFeaturePotential j : p.getAddFeatures())
{
for (IrisFeaturePotential j : p.getAddFeatures()) {
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD());
@@ -629,8 +625,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
}, null, getData());
if(objectPlacement.usesFeatures())
{
if (objectPlacement.usesFeatures()) {
if (objectPlacement.isVacuum()) {
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD());
@@ -650,8 +645,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
rw.getFeatures().add(new IrisFeaturePositional(xx, zz, f));
}
for(IrisFeaturePotential j : objectPlacement.getAddFeatures())
{
for (IrisFeaturePotential j : objectPlacement.getAddFeatures()) {
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD());
@@ -952,8 +946,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
}
@ChunkCoordinates
default KList<IrisFeaturePositional> getFeaturesInChunk(Chunk c)
{
default KList<IrisFeaturePositional> getFeaturesInChunk(Chunk c) {
return getFeaturesInChunk(c.getX(), c.getZ());
}
}

View File

@@ -21,11 +21,9 @@ 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;
@@ -41,14 +39,7 @@ 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
@@ -87,9 +78,8 @@ public class IrisEntitySpawn implements IRare {
int z = (c.getZ() * 16) + rng.i(15);
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);
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();
@@ -97,7 +87,7 @@ public class IrisEntitySpawn implements IRare {
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()) {
if (i.getCeiling() >= gen.getHeight() || i.getFloor() < 0 || i.getCeiling() - 2 <= i.getFloor()) {
continue;
}
@@ -108,18 +98,17 @@ public class IrisEntitySpawn implements IRare {
yield r.getRandom(rng);
}
case UNDERWATER, BEACH -> new Location(c.getWorld(), x, rng.i(h+1, hf), z);
case UNDERWATER, BEACH -> new Location(c.getWorld(), x, rng.i(h + 1, hf), z);
};
if(l != null)
{
if (l != null) {
spawn100(gen, l);
s++;
}
}
}
return s>0;
return s > 0;
}
public IrisEntity getRealEntity(Engine g) {

View File

@@ -218,8 +218,7 @@ public class IrisObjectPlacement {
return getMode().equals(ObjectPlaceMode.VACUUM);
}
public boolean usesFeatures()
{
public boolean usesFeatures() {
return isVacuum() || getAddFeatures().isNotEmpty();
}

View File

@@ -26,7 +26,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.Location;
import org.bukkit.World;
@EqualsAndHashCode(callSuper = true)
@@ -52,24 +51,22 @@ public class IrisSpawner extends IrisRegistrant {
@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(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) {