mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 10:39:07 +00:00
Fix vacuum
This commit is contained in:
@@ -52,7 +52,7 @@ public class CommandIrisWhatFeatures extends MortarCommand {
|
||||
|
||||
if (IrisToolbelt.isIrisWorld(c.getWorld())) {
|
||||
int m = 1;
|
||||
for (IrisFeaturePositional i : IrisToolbelt.access(c.getWorld()).getEngine().getMantle().getFeaturesInChunk(c)) {
|
||||
for (IrisFeaturePositional i : IrisToolbelt.access(c.getWorld()).getEngine().getMantle().forEachFeature(c)) {
|
||||
sender.sendMessage("#" + m++ + " " + new JSONObject(new Gson().toJson(i)).toString(4));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -76,6 +76,7 @@ public class IrisComplex implements DataProvider {
|
||||
private ProceduralStream<Double> overlayStream;
|
||||
private ProceduralStream<Double> heightFluidStream;
|
||||
private ProceduralStream<Integer> trueHeightStream;
|
||||
private ProceduralStream<Integer> trueHeightStreamNoFeatures;
|
||||
private ProceduralStream<Double> slopeStream;
|
||||
private ProceduralStream<Integer> topSurfaceStream;
|
||||
private ProceduralStream<RNG> rngStream;
|
||||
@@ -217,16 +218,12 @@ public class IrisComplex implements DataProvider {
|
||||
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D(cacheSize);
|
||||
slopeStream = heightStream.slope(3).cache2D(cacheSize);
|
||||
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
||||
if (engine.getDimension().hasFeatures(engine)) {
|
||||
AtomicDouble str = new AtomicDouble(1D);
|
||||
for (IrisFeaturePositional i : engine.getMantle().forEachFeature(x, z)) {
|
||||
str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng, getData())));
|
||||
}
|
||||
|
||||
return str.get();
|
||||
AtomicDouble str = new AtomicDouble(1D);
|
||||
for (IrisFeaturePositional i : engine.getMantle().forEachFeature(x, z)) {
|
||||
str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng, getData())));
|
||||
}
|
||||
|
||||
return 1D;
|
||||
return str.get();
|
||||
});
|
||||
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
||||
b -> focus)).convertAware2D((b, x, z) -> {
|
||||
@@ -343,6 +340,38 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
return m;
|
||||
}, Interpolated.INT).cache2D(cacheSize);
|
||||
|
||||
trueHeightStreamNoFeatures = ProceduralStream.of((x, z) -> {
|
||||
int rx = (int) Math.round(engine.modifyX(x));
|
||||
int rz = (int) Math.round(engine.modifyZ(z));
|
||||
int heightf = (int) Math.round(getHeightStreamNoFeatures().get(rx, rz));
|
||||
int m = heightf;
|
||||
|
||||
if (engine.getDimension().isCarved(getData(), rx, m, rz, ((IrisTerrainNormalActuator) engine.getTerrainActuator()).getRng(), heightf)) {
|
||||
m--;
|
||||
|
||||
while (engine.getDimension().isCarved(getData(), rx, m, rz, ((IrisTerrainNormalActuator) engine.getTerrainActuator()).getRng(), heightf)) {
|
||||
m--;
|
||||
}
|
||||
}
|
||||
|
||||
if (engine.getDimension().isCaves()) {
|
||||
KList<CaveResult> caves = ((IrisCaveModifier) engine.getCaveModifier()).genCaves(rx, rz, 0, 0, null);
|
||||
boolean again = true;
|
||||
|
||||
while (again) {
|
||||
again = false;
|
||||
for (CaveResult i : caves) {
|
||||
if (i.getCeiling() > m && i.getFloor() < m) {
|
||||
m = i.getFloor();
|
||||
again = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}, Interpolated.INT).cache2D(cacheSize);
|
||||
baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> {
|
||||
UUID d = regionIDStream.get(x, z);
|
||||
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
||||
@@ -427,9 +456,7 @@ public class IrisComplex implements DataProvider {
|
||||
AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z));
|
||||
|
||||
if (features) {
|
||||
List<IrisFeaturePositional> p = engine.getMantle().forEachFeature(x, z);
|
||||
|
||||
for (IrisFeaturePositional i : p) {
|
||||
for (IrisFeaturePositional i : engine.getMantle().forEachFeature(x, z)) {
|
||||
noise.set(i.filter(x, z, noise.get(), rng, getData()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,10 +417,8 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
} else {
|
||||
getMantle().generateMatter(x >> 4, z >> 4, multicore);
|
||||
burst().burst(multicore,
|
||||
() -> getTerrainActuator().actuate(x, z, vblocks, multicore),
|
||||
() -> getBiomeActuator().actuate(x, z, vbiomes, multicore)
|
||||
);
|
||||
getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
getBiomeActuator().actuate(x, z, vbiomes, multicore);
|
||||
burst().burst(multicore,
|
||||
() -> getCaveModifier().modify(x, z, vblocks, multicore),
|
||||
() -> getDecorantActuator().actuate(x, z, blocks, multicore),
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -206,6 +207,8 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
post.clear();
|
||||
burst().burst(multicore, px);
|
||||
}
|
||||
|
||||
getMantle().flag(x, z, MantleFlag.REAL, true);
|
||||
}
|
||||
|
||||
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, Consumer<Runnable> post, MantleChunk mc) {
|
||||
@@ -246,10 +249,6 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
default KList<IrisFeaturePositional> forEachFeature(double x, double z) {
|
||||
KList<IrisFeaturePositional> pos = new KList<>();
|
||||
|
||||
if (!getEngine().getDimension().hasFeatures(getEngine())) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) {
|
||||
if (i.shouldFilter(x, z, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(i);
|
||||
|
||||
@@ -64,9 +64,12 @@ public class MantleFeatureComponent extends IrisMantleComponent {
|
||||
}
|
||||
|
||||
private void placeZone(MantleWriter writer, RNG rng, int cx, int cz, IrisFeaturePotential i) {
|
||||
int x = (cx << 4) + rng.nextInt(16);
|
||||
int z = (cz << 4) + rng.nextInt(16);
|
||||
writer.setData(x, 0, z, new IrisFeaturePositional(x, z, i.getZone()));
|
||||
if(i.hasZone(rng, cx, cz))
|
||||
{
|
||||
int x = (cx << 4) + rng.nextInt(16);
|
||||
int z = (cz << 4) + rng.nextInt(16);
|
||||
writer.setData(x, 0, z, new IrisFeaturePositional(x, z, i.getZone()));
|
||||
}
|
||||
}
|
||||
|
||||
private KList<IrisFeaturePotential> getFeatures() {
|
||||
|
||||
@@ -118,6 +118,6 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
new IrisFeaturePositional(position.getX(), position.getZ(), structure.getFeature()));
|
||||
}
|
||||
|
||||
post.accept(() -> new PlannedStructure(structure, position, rng).place(writer, getMantle(), post));
|
||||
new PlannedStructure(structure, position, rng).place(writer, getMantle(), post);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,40 +90,31 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
if (v == null) {
|
||||
return;
|
||||
}
|
||||
int xx = rng.i(x, x + 16);
|
||||
int zz = rng.i(z, z + 16);
|
||||
int xx = rng.i(x, x + 15);
|
||||
int zz = rng.i(z, z + 15);
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
|
||||
Runnable r = () -> {
|
||||
int h = v.place(xx, -1, zz, writer, objectPlacement, rng,
|
||||
(b) -> writer.setData(b.getX(), b.getY(), b.getZ(),
|
||||
v.getLoadKey() + "@" + id), null, getData());
|
||||
|
||||
if (objectPlacement.usesFeatures()) {
|
||||
if (objectPlacement.isVacuum()) {
|
||||
int h = v.place(xx, -1, zz, writer, objectPlacement, rng,
|
||||
(b) -> writer.setData(b.getX(), b.getY(), b.getZ(),
|
||||
v.getLoadKey() + "@" + id), null, getData());
|
||||
if (objectPlacement.usesFeatures() && h >= 0) {
|
||||
if (objectPlacement.isVacuum()) {
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
IrisFeature f = new IrisFeature();
|
||||
f.setConvergeToHeight(h);
|
||||
f.setBlockRadius(a);
|
||||
f.setInterpolationRadius(objectPlacement.getVacuumInterpolationRadius());
|
||||
f.setInterpolator(objectPlacement.getVacuumInterpolationMethod());
|
||||
f.setStrength(1D);
|
||||
writer.setData(xx, 0, zz, new IrisFeaturePositional(xx, zz, f));
|
||||
}
|
||||
|
||||
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);
|
||||
writer.setData(xx, 0, zz, new IrisFeaturePositional(xx, zz, f));
|
||||
}
|
||||
|
||||
for (IrisFeaturePotential j : objectPlacement.getAddFeatures()) {
|
||||
if (j.hasZone(rng, xx >> 4, zz >> 4)) {
|
||||
writer.setData(xx, 0, zz, new IrisFeaturePositional(xx, zz, j.getZone()));
|
||||
}
|
||||
for (IrisFeaturePotential j : objectPlacement.getAddFeatures()) {
|
||||
if (j.hasZone(rng, xx >> 4, zz >> 4)) {
|
||||
writer.setData(xx, 0, zz, new IrisFeaturePositional(xx, zz, j.getZone()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (objectPlacement.usesFeatures()) {
|
||||
r.run();
|
||||
} else {
|
||||
post.accept(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,41 +519,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
return changed;
|
||||
}
|
||||
|
||||
public boolean hasFeatures(DataProvider data) {
|
||||
return featuresUsed.aquire(() -> {
|
||||
if (getFeatures().isNotEmpty() || getSpecificFeatures().isNotEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (IrisRegion i : getAllRegions(data)) {
|
||||
if (i.getFeatures().isNotEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
if (j.isVacuum()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisBiome j : i.getAllBiomes(data)) {
|
||||
if (j.getFeatures().isNotEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement k : i.getObjects()) {
|
||||
if (k.isVacuum()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iris.verbose("Not using parallax noise features (they arent used in this dimension)");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "dimensions";
|
||||
|
||||
@@ -25,7 +25,8 @@ public enum MantleFlag {
|
||||
UPDATE,
|
||||
JIGSAW,
|
||||
FEATURE,
|
||||
INITIAL_SPAWNED;
|
||||
INITIAL_SPAWNED,
|
||||
REAL;
|
||||
|
||||
static StateList getStateList() {
|
||||
return new StateList(MantleFlag.values());
|
||||
|
||||
Reference in New Issue
Block a user