Tweak feature iteration

This commit is contained in:
Daniel Mills 2021-07-31 08:18:00 -04:00
parent dff88403b5
commit 302f54971d
3 changed files with 46 additions and 53 deletions

View File

@ -138,7 +138,7 @@ public class IrisBoardManager implements BoardProvider, Listener {
if (engine != null) { if (engine != null) {
v.add("&7&m------------------"); v.add("&7&m------------------");
KList<IrisFeaturePositional> f = new KList<>(); KList<IrisFeaturePositional> f = new KList<>();
engine.getFramework().getEngineParallax().forEachFeature(x, z, f::add); f.add(engine.getFramework().getEngineParallax().forEachFeature(x, z));
v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight()); v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight());
v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
v.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiome(x, y, z).getName()); v.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiome(x, y, z).getName());

View File

@ -205,8 +205,11 @@ public class IrisComplex implements DataProvider {
objectChanceStream = ProceduralStream.ofDouble((x, z) -> { objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
if (engine.getDimension().hasFeatures(engine)) { if (engine.getDimension().hasFeatures(engine)) {
AtomicDouble str = new AtomicDouble(1D); AtomicDouble str = new AtomicDouble(1D);
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i) for(IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z))
-> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng)))); {
str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng)));
}
return str.get(); return str.get();
} }
@ -409,8 +412,12 @@ public class IrisComplex implements DataProvider {
} }
AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z)); AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z));
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
-> noise.set(i.filter(x, z, noise.get(), rng))); for(IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z))
{
noise.set(i.filter(x, z, noise.get(), rng));
}
return Math.min(engine.getHeight(), Math.max(noise.get(), 0)); return Math.min(engine.getHeight(), Math.max(noise.get(), 0));
} }

View File

@ -198,21 +198,8 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
} }
} }
@BlockCoordinates
default void forEachFeature(double x, double z, Consumer<IrisFeaturePositional> f) {
if (!getEngine().getDimension().hasFeatures(getEngine())) {
return;
}
for (IrisFeaturePositional ipf : forEachFeature(x, z)) {
f.accept(ipf);
}
}
@BlockCoordinates @BlockCoordinates
default KList<IrisFeaturePositional> forEachFeature(double x, double z) { default KList<IrisFeaturePositional> forEachFeature(double x, double z) {
synchronized (getEngine())
{
KList<IrisFeaturePositional> pos = new KList<>(); KList<IrisFeaturePositional> pos = new KList<>();
if (!getEngine().getDimension().hasFeatures(getEngine())) { if (!getEngine().getDimension().hasFeatures(getEngine())) {
@ -251,7 +238,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
return pos; return pos;
} }
}
@ChunkCoordinates @ChunkCoordinates
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")