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

@ -22,7 +22,6 @@ import com.volmit.iris.core.*;
import com.volmit.iris.core.command.CommandIris; import com.volmit.iris.core.command.CommandIris;
import com.volmit.iris.core.command.PermissionIris; import com.volmit.iris.core.command.PermissionIris;
import com.volmit.iris.core.command.world.CommandLocate; import com.volmit.iris.core.command.world.CommandLocate;
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
import com.volmit.iris.core.link.IrisPapiExpansion; import com.volmit.iris.core.link.IrisPapiExpansion;
import com.volmit.iris.core.link.MultiverseCoreLink; import com.volmit.iris.core.link.MultiverseCoreLink;
import com.volmit.iris.core.link.OraxenLink; import com.volmit.iris.core.link.OraxenLink;

View File

@ -30,7 +30,6 @@ import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
public class CommandIrisStudioExplorerGenerator extends MortarCommand { public class CommandIrisStudioExplorerGenerator extends MortarCommand {
@ -73,7 +72,6 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
} }
Supplier<Function2<Double, Double, Double>> l = () -> { Supplier<Function2<Double, Double, Double>> l = () -> {
long seed = 12345; long seed = 12345;
IrisGenerator generator; IrisGenerator generator;
@ -84,8 +82,7 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
generator = IrisData.loadAnyGenerator(args[0]); generator = IrisData.loadAnyGenerator(args[0]);
} }
if(generator == null) if (generator == null) {
{
return (x, z) -> 0D; return (x, z) -> 0D;
} }
@ -94,7 +91,6 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
}; };
NoiseExplorerGUI.launch(l, "Custom Generator"); NoiseExplorerGUI.launch(l, "Custom Generator");
return true; return true;

View File

@ -42,7 +42,6 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, Listener { public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, Listener {
@ -108,8 +107,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List
} }
@EventHandler @EventHandler
public void on(IrisEngineHotloadEvent e) public void on(IrisEngineHotloadEvent e) {
{
generator = loader.get(); generator = loader.get();
} }

View File

@ -195,8 +195,7 @@ public class ResourceLoader<T extends IrisRegistrant> {
} }
} }
public Stream<T> streamAll(Stream<String> s) public Stream<T> streamAll(Stream<String> s) {
{
return s.map(this::load); return s.map(this::load);
} }

View File

@ -91,7 +91,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
} }
for (int ig = 0; ig < data.get(i).size() / 8; ig++) { 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); IrisBiome biome = getEngine().getSurfaceBiome(c);
IrisRegion region = getEngine().getRegion(c); IrisRegion region = getEngine().getRegion(c);
spawnIn(c, biome, region, i, maxGroups); spawnIn(c, biome, region, i, maxGroups);
@ -111,25 +111,25 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
//@builder //@builder
spawnRandomly(Stream.concat(Stream.concat( spawnRandomly(Stream.concat(Stream.concat(
getData().getSpawnerLoader() getData().getSpawnerLoader()
.loadAll(getDimension().getEntitySpawners()) .loadAll(getDimension().getEntitySpawners())
.shuffleCopy(RNG.r).stream().filter(this::canSpawn), .shuffleCopy(RNG.r).stream().filter(this::canSpawn),
getData().getSpawnerLoader().streamAll(getEngine().getFramework().getEngineParallax() getData().getSpawnerLoader().streamAll(getEngine().getFramework().getEngineParallax()
.getFeaturesInChunk(c).stream() .getFeaturesInChunk(c).stream()
.flatMap((o) -> o.getFeature().getEntitySpawners().stream())) .flatMap((o) -> o.getFeature().getEntitySpawners().stream()))
.filter(this::canSpawn)) .filter(this::canSpawn))
.filter((i) -> i.isValid(biome)) .filter((i) -> i.isValid(biome))
.flatMap(this::stream), .flatMap(this::stream),
Stream.concat(getData().getSpawnerLoader() Stream.concat(getData().getSpawnerLoader()
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners()) .loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
.shuffleCopy(RNG.r).stream().filter(this::canSpawn) .shuffleCopy(RNG.r).stream().filter(this::canSpawn)
.flatMap(this::stream), .flatMap(this::stream),
getData().getSpawnerLoader() getData().getSpawnerLoader()
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners()) .loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
.shuffleCopy(RNG.r).stream().filter(this::canSpawn) .shuffleCopy(RNG.r).stream().filter(this::canSpawn)
.flatMap(this::stream))) .flatMap(this::stream)))
.collect(Collectors.toList())) .collect(Collectors.toList()))
.popRandom(RNG.r, max).forEach((i) -> spawn(c, id, i)); .popRandom(RNG.r, max).forEach((i) -> spawn(c, id, i));
//@done //@done
} }

View File

@ -413,13 +413,11 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
IrisEngineData getEngineData(); IrisEngineData getEngineData();
default IrisBiome getSurfaceBiome(Chunk c) default IrisBiome getSurfaceBiome(Chunk c) {
{ return getSurfaceBiome((c.getX() << 4) + 8, (c.getZ() << 4) + 8);
return getSurfaceBiome((c.getX()<<4) + 8, (c.getZ()<<4) + 8);
} }
default IrisRegion getRegion(Chunk c) default IrisRegion getRegion(Chunk c) {
{ return getRegion((c.getX() << 4) + 8, (c.getZ() << 4) + 8);
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.B;
import com.volmit.iris.engine.data.DataProvider; import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.hunk.Hunk; 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.jigsaw.PlannedStructure;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.common.IObjectPlacer; import com.volmit.iris.engine.object.common.IObjectPlacer;
@ -198,18 +197,17 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
} }
@ChunkCoordinates @ChunkCoordinates
default KList<IrisFeaturePositional> getFeaturesInChunk(int x, int z) default KList<IrisFeaturePositional> getFeaturesInChunk(int x, int z) {
{
KList<IrisFeaturePositional> pos = new KList<>(); KList<IrisFeaturePositional> pos = new KList<>();
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) { 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); pos.add(i);
} }
} }
for (IrisFeaturePositional i : getParallaxAccess().getMetaR(x, z).getFeatures()) { 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); pos.add(i);
} }
} }
@ -567,8 +565,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
}, null, getData()); }, null, getData());
if(p.usesFeatures()) if (p.usesFeatures()) {
{
if (p.isVacuum()) { if (p.isVacuum()) {
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4); ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD()); 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)); 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); ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD()); double a = Math.max(v.getW(), v.getD());
@ -629,8 +625,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
}, null, getData()); }, null, getData());
if(objectPlacement.usesFeatures()) if (objectPlacement.usesFeatures()) {
{
if (objectPlacement.isVacuum()) { if (objectPlacement.isVacuum()) {
ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4); ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD()); 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)); 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); ParallaxChunkMeta rw = getParallaxAccess().getMetaRW(xx >> 4, zz >> 4);
double a = Math.max(v.getW(), v.getD()); double a = Math.max(v.getW(), v.getD());
@ -952,8 +946,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
} }
@ChunkCoordinates @ChunkCoordinates
default KList<IrisFeaturePositional> getFeaturesInChunk(Chunk c) default KList<IrisFeaturePositional> getFeaturesInChunk(Chunk c) {
{
return getFeaturesInChunk(c.getX(), c.getZ()); 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.Iris;
import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.cache.AtomicCache; 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.Engine;
import com.volmit.iris.engine.framework.EngineFramework; import com.volmit.iris.engine.framework.EngineFramework;
import com.volmit.iris.engine.modifier.IrisCaveModifier; 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.Desc;
import com.volmit.iris.engine.object.annotations.MinNumber; import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource; import com.volmit.iris.engine.object.annotations.RegistryListResource;
@ -41,14 +39,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; 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.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@ -87,9 +78,8 @@ public class IrisEntitySpawn implements IRare {
int z = (c.getZ() * 16) + rng.i(15); int z = (c.getZ() * 16) + rng.i(15);
int h = gen.getHeight(x, z, true); int h = gen.getHeight(x, z, true);
int hf = gen.getHeight(x, z, false); int hf = gen.getHeight(x, z, false);
Location l = switch(getReferenceSpawner().getGroup()) Location l = switch (getReferenceSpawner().getGroup()) {
{ case NORMAL -> new Location(c.getWorld(), x, hf + 1, z);
case NORMAL -> new Location(c.getWorld(), x, hf+1, z);
case CAVE -> { case CAVE -> {
IrisComplex comp = gen.getFramework().getComplex(); IrisComplex comp = gen.getFramework().getComplex();
EngineFramework frame = gen.getFramework(); EngineFramework frame = gen.getFramework();
@ -97,7 +87,7 @@ public class IrisEntitySpawn implements IRare {
KList<Location> r = new KList<>(); KList<Location> r = new KList<>();
if (cave != null) { if (cave != null) {
for (CaveResult i : ((IrisCaveModifier) frame.getCaveModifier()).genCaves(x, z)) { 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; continue;
} }
@ -108,18 +98,17 @@ public class IrisEntitySpawn implements IRare {
yield r.getRandom(rng); 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); spawn100(gen, l);
s++; s++;
} }
} }
} }
return s>0; return s > 0;
} }
public IrisEntity getRealEntity(Engine g) { public IrisEntity getRealEntity(Engine g) {

View File

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

View File

@ -26,7 +26,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -52,24 +51,22 @@ public class IrisSpawner extends IrisRegistrant {
@Desc("Where should these spawns be placed") @Desc("Where should these spawns be placed")
private IrisSpawnGroup group = IrisSpawnGroup.NORMAL; private IrisSpawnGroup group = IrisSpawnGroup.NORMAL;
public boolean isValid(IrisBiome biome) public boolean isValid(IrisBiome biome) {
{ return switch (group) {
return switch (group) case NORMAL -> switch (biome.getInferredType()) {
{ case SHORE, SEA, CAVE, RIVER, LAKE, DEFER -> false;
case NORMAL -> switch(biome.getInferredType()) { case LAND -> true;
case SHORE, SEA, CAVE, RIVER, LAKE, DEFER -> false; };
case LAND -> true; case CAVE -> true;
}; case UNDERWATER -> switch (biome.getInferredType()) {
case CAVE -> true; case SHORE, LAND, CAVE, RIVER, LAKE, DEFER -> false;
case UNDERWATER -> switch(biome.getInferredType()) { case SEA -> true;
case SHORE, LAND, CAVE, RIVER, LAKE, DEFER -> false; };
case SEA -> true; case BEACH -> switch (biome.getInferredType()) {
}; case SHORE -> true;
case BEACH -> switch(biome.getInferredType()) { case LAND, CAVE, RIVER, LAKE, SEA, DEFER -> false;
case SHORE -> true; };
case LAND, CAVE, RIVER, LAKE, SEA, DEFER -> false; };
};
};
} }
public boolean isValid(World world) { public boolean isValid(World world) {

View File

@ -114,8 +114,7 @@ public class RNG extends Random {
} }
public double d(double lowerBound, double upperBound) { public double d(double lowerBound, double upperBound) {
if(lowerBound > upperBound) if (lowerBound > upperBound) {
{
return M.lerp(upperBound, lowerBound, nextDouble()); return M.lerp(upperBound, lowerBound, nextDouble());
} }