mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Cave Decorator Changes
- Surface decorators are no longer placed below liquids in caves - SEA_FLOOR and SEA_SURFACE decorators now function within caves relative to the cave liquid - Fixed stacked decorators going above the height of caves and the map
This commit is contained in:
parent
f8ae842971
commit
64f361d4b1
@ -18,12 +18,14 @@
|
||||
|
||||
package com.volmit.iris.engine.actuator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.decorator.*;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||
import com.volmit.iris.engine.framework.EngineDecorator;
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisCaveLayer;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
@ -31,10 +33,12 @@ import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
private static final Predicate<BlockData> PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA);
|
||||
private static BiPredicate<BlockData, Integer> PREDICATE_CAVELIQUID = (d, i) -> false;
|
||||
private final RNG rng;
|
||||
@Getter
|
||||
private final EngineDecorator surfaceDecorator;
|
||||
@ -57,6 +61,21 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
|
||||
shoreLineDecorator = new IrisShoreLineDecorator(getEngine());
|
||||
seaFloorDecorator = new IrisSeaFloorDecorator(getEngine());
|
||||
|
||||
PREDICATE_CAVELIQUID = (b, y) -> {
|
||||
for (IrisCaveLayer layer : getEngine().getDimension().getCaveLayers()) {
|
||||
if (!layer.getFluid().hasFluid(getData())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (layer.getFluid().isInverseHeight() && y >= layer.getFluid().getFluidHeight()) {
|
||||
if (b.matches(layer.getFluid().getFluid(getData()))) return true;
|
||||
} else if (!layer.getFluid().isInverseHeight() && y <= layer.getFluid().getFluidHeight()) {
|
||||
if (b.matches(layer.getFluid().getFluid(getData()))) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@ -71,10 +90,12 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
int j, realX, realZ, height;
|
||||
IrisBiome biome, cave;
|
||||
|
||||
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
for (j = 0; j < output.getDepth(); j++) {
|
||||
boolean solid;
|
||||
boolean solid, liquid;
|
||||
int emptyFor = 0;
|
||||
int liquidFor = 0;
|
||||
int lastSolid = 0;
|
||||
realX = (int) Math.round(modX(x + i));
|
||||
realZ = (int) Math.round(modZ(z + j));
|
||||
@ -90,12 +111,12 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
getShoreLineDecorator().decorate(i, j,
|
||||
realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)),
|
||||
realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)),
|
||||
output, biome, height, getEngine().getHeight() - height);
|
||||
output, biome, height, getEngine().getHeight());
|
||||
} else if (height == getDimension().getFluidHeight() + 1) {
|
||||
getSeaSurfaceDecorator().decorate(i, j,
|
||||
realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)),
|
||||
realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)),
|
||||
output, biome, height, getEngine().getHeight() - getDimension().getFluidHeight());
|
||||
output, biome, height, getEngine().getHeight());
|
||||
} else if (height < getDimension().getFluidHeight()) {
|
||||
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight());
|
||||
}
|
||||
@ -105,16 +126,24 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
if (cave != null && cave.getDecorators().isNotEmpty()) {
|
||||
for (int k = height; k > 0; k--) {
|
||||
solid = PREDICATE_SOLID.test(output.get(i, k, j));
|
||||
liquid = PREDICATE_CAVELIQUID.test(output.get(i, k + 1, j), k + 1);
|
||||
|
||||
if (solid) {
|
||||
if (emptyFor > 0) {
|
||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
|
||||
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
||||
if (liquid) {
|
||||
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, cave, k + 1, liquidFor + lastSolid - emptyFor);
|
||||
getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k + liquidFor + 1, emptyFor - liquidFor + lastSolid);
|
||||
} else {
|
||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
|
||||
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
||||
}
|
||||
emptyFor = 0;
|
||||
liquidFor = 0;
|
||||
}
|
||||
lastSolid = k;
|
||||
} else {
|
||||
emptyFor++;
|
||||
if (liquid) liquidFor++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,36 +35,30 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
if (height <= getDimension().getFluidHeight()) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
}
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
stack = Math.min(stack, max - height + 1);
|
||||
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
if (height + i > max || height + i > getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
stack = Math.min(stack, getDimension().getFluidHeight() - height + 2);
|
||||
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
if (height - i < 0 || height - i > getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (height + i > getDimension().getFluidHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, height + i, z, threshold >= decorator.getTopThreshold() ? top : fill);
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, height + i, z, threshold >= decorator.getTopThreshold() ? top : fill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
data.set(x, getDimension().getFluidHeight() + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
}
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
@ -48,12 +48,12 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
for (int i = 0; i < stack; i++) {
|
||||
if (height - i < 0 || height - i > getEngine().getHeight()) {
|
||||
if (height + i >= max || height + i >= getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, getDimension().getFluidHeight() + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill);
|
||||
data.set(x, height + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
|
||||
stack = Math.min(max - height + 1, stack);
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
|
@ -73,10 +73,11 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
|
||||
} else {
|
||||
if (height < getDimension().getFluidHeight()) {
|
||||
max = getDimension().getFluidHeight() - height;
|
||||
max = getDimension().getFluidHeight();
|
||||
}
|
||||
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
stack = Math.min(height - max + 1, stack);
|
||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user