mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
commit
d477121790
@ -18,12 +18,14 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.actuator;
|
package com.volmit.iris.engine.actuator;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.decorator.*;
|
import com.volmit.iris.engine.decorator.*;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||||
import com.volmit.iris.engine.framework.EngineDecorator;
|
import com.volmit.iris.engine.framework.EngineDecorator;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
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.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
@ -31,10 +33,12 @@ import lombok.Getter;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
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 final Predicate<BlockData> PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA);
|
||||||
|
private BiPredicate<BlockData, Integer> PREDICATE_CAVELIQUID = null;
|
||||||
private final RNG rng;
|
private final RNG rng;
|
||||||
@Getter
|
@Getter
|
||||||
private final EngineDecorator surfaceDecorator;
|
private final EngineDecorator surfaceDecorator;
|
||||||
@ -57,6 +61,23 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
|||||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
|
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
|
||||||
shoreLineDecorator = new IrisShoreLineDecorator(getEngine());
|
shoreLineDecorator = new IrisShoreLineDecorator(getEngine());
|
||||||
seaFloorDecorator = new IrisSeaFloorDecorator(getEngine());
|
seaFloorDecorator = new IrisSeaFloorDecorator(getEngine());
|
||||||
|
|
||||||
|
//Can't be created without an instance of the actuator due to referencing the engine
|
||||||
|
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
|
@BlockCoordinates
|
||||||
@ -71,10 +92,12 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
|||||||
int j, realX, realZ, height;
|
int j, realX, realZ, height;
|
||||||
IrisBiome biome, cave;
|
IrisBiome biome, cave;
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < output.getWidth(); i++) {
|
for (int i = 0; i < output.getWidth(); i++) {
|
||||||
for (j = 0; j < output.getDepth(); j++) {
|
for (j = 0; j < output.getDepth(); j++) {
|
||||||
boolean solid;
|
boolean solid, liquid;
|
||||||
int emptyFor = 0;
|
int emptyFor = 0;
|
||||||
|
int liquidFor = 0;
|
||||||
int lastSolid = 0;
|
int lastSolid = 0;
|
||||||
realX = (int) Math.round(modX(x + i));
|
realX = (int) Math.round(modX(x + i));
|
||||||
realZ = (int) Math.round(modZ(z + j));
|
realZ = (int) Math.round(modZ(z + j));
|
||||||
@ -90,31 +113,40 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
|||||||
getShoreLineDecorator().decorate(i, j,
|
getShoreLineDecorator().decorate(i, j,
|
||||||
realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)),
|
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)),
|
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) {
|
} else if (height == getDimension().getFluidHeight() + 1) {
|
||||||
getSeaSurfaceDecorator().decorate(i, j,
|
getSeaSurfaceDecorator().decorate(i, j,
|
||||||
realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)),
|
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)),
|
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()) {
|
} else if (height < getDimension().getFluidHeight()) {
|
||||||
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight());
|
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
|
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
|
||||||
|
|
||||||
|
|
||||||
if (cave != null && cave.getDecorators().isNotEmpty()) {
|
if (cave != null && cave.getDecorators().isNotEmpty()) {
|
||||||
for (int k = height; k > 0; k--) {
|
for (int k = height; k > 0; k--) {
|
||||||
solid = PREDICATE_SOLID.test(output.get(i, k, j));
|
solid = PREDICATE_SOLID.test(output.get(i, k, j));
|
||||||
|
liquid = PREDICATE_CAVELIQUID.test(output.get(i, k + 1, j), k + 1);
|
||||||
|
|
||||||
if (solid) {
|
if (solid) {
|
||||||
if (emptyFor > 0) {
|
if (emptyFor > 0) {
|
||||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
|
if (liquid) {
|
||||||
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, cave, k + 1, liquidFor + lastSolid - emptyFor + 1);
|
||||||
|
getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k + liquidFor + 1, emptyFor - liquidFor + lastSolid);
|
||||||
|
} else {
|
||||||
|
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, lastSolid);
|
||||||
|
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
||||||
|
}
|
||||||
emptyFor = 0;
|
emptyFor = 0;
|
||||||
|
liquidFor = 0;
|
||||||
}
|
}
|
||||||
lastSolid = k;
|
lastSolid = k;
|
||||||
} else {
|
} else {
|
||||||
emptyFor++;
|
emptyFor++;
|
||||||
|
if (liquid) liquidFor++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,22 +40,29 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
|||||||
if (decorator != null) {
|
if (decorator != null) {
|
||||||
if (!decorator.isStacking()) {
|
if (!decorator.isStacking()) {
|
||||||
if (height >= 0 || height < getEngine().getHeight()) {
|
if (height >= 0 || height < getEngine().getHeight()) {
|
||||||
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||||
stack = Math.min(max + 1, stack);
|
if (decorator.isScaleStack()) {
|
||||||
|
stack = (int) Math.ceil((double)max * ((double)stack / 100));
|
||||||
|
} else stack = Math.min(max, stack);
|
||||||
|
|
||||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
if (stack == 1) {
|
||||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < stack; i++) {
|
for (int i = 0; i < stack; i++) {
|
||||||
if (height - i < 0 || height - i > getEngine().getHeight()) {
|
int h = height - i;
|
||||||
|
if (h < getEngine().getMinHeight()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double threshold = (((double) i) / (double) (stack - 1));
|
double threshold = (((double) i) / (double) (stack - 1));
|
||||||
data.set(x, height - i, z, threshold >= decorator.getTopThreshold() ? top : fill);
|
data.set(x, h, z, threshold >= decorator.getTopThreshold() ?
|
||||||
|
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||||
|
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.decorator;
|
package com.volmit.iris.engine.decorator;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.cache.Cache;
|
import com.volmit.iris.engine.cache.Cache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
@ -35,36 +36,38 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
|||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
@Override
|
@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) {
|
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, height, realZ, getData()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||||
|
if (decorator.isScaleStack()) {
|
||||||
|
int maxStack = max - height;
|
||||||
|
stack = (int)Math.ceil((double)maxStack * ((double)stack / 100));
|
||||||
|
} else stack = Math.min(stack, max - height);
|
||||||
|
|
||||||
if (decorator != null) {
|
if (stack == 1) {
|
||||||
if (!decorator.isStacking()) {
|
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||||
if (height >= 0 || height < getEngine().getHeight()) {
|
return;
|
||||||
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < stack; i++) {
|
||||||
|
int h = height + i;
|
||||||
|
if (h > max || h > 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());
|
double threshold = ((double) i) / (stack - 1);
|
||||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
data.set(x, h, z, threshold >= decorator.getTopThreshold() ?
|
||||||
|
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||||
for (int i = 0; i < stack; i++) {
|
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()));
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.decorator;
|
package com.volmit.iris.engine.decorator;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.cache.Cache;
|
import com.volmit.iris.engine.cache.Cache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
@ -40,20 +41,30 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
|||||||
if (decorator != null) {
|
if (decorator != null) {
|
||||||
if (!decorator.isStacking()) {
|
if (!decorator.isStacking()) {
|
||||||
if (height >= 0 || height < getEngine().getHeight()) {
|
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, height, realZ, getData()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||||
|
if (decorator.isScaleStack()) {
|
||||||
|
int maxStack = max - height;
|
||||||
|
stack = (int) Math.ceil((double)maxStack * ((double)stack / 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack == 1) {
|
||||||
|
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
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++) {
|
for (int i = 0; i < stack; i++) {
|
||||||
if (height - i < 0 || height - i > getEngine().getHeight()) {
|
int h = height + i;
|
||||||
|
if (h >= max || h >= getEngine().getHeight()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double threshold = ((double) i) / (stack - 1);
|
double threshold = ((double) i) / (stack - 1);
|
||||||
data.set(x, getDimension().getFluidHeight() + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill);
|
data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ?
|
||||||
|
decorator.getBlockDataForTop(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()) :
|
||||||
|
decorator.getBlockData100(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,16 +46,25 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
|||||||
|
|
||||||
if (decorator != null) {
|
if (decorator != null) {
|
||||||
if (!decorator.isStacking()) {
|
if (!decorator.isStacking()) {
|
||||||
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
|
||||||
} else {
|
} else {
|
||||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||||
|
if (decorator.isScaleStack()) {
|
||||||
|
int maxStack = max - height;
|
||||||
|
stack = (int)Math.ceil((double)maxStack * ((double)stack / 100));
|
||||||
|
} else stack = Math.min(max - height, stack);
|
||||||
|
|
||||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
if (stack == 1) {
|
||||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < stack; i++) {
|
for (int i = 0; i < stack; i++) {
|
||||||
|
int h = height + i;
|
||||||
double threshold = ((double) i) / (stack - 1);
|
double threshold = ((double) i) / (stack - 1);
|
||||||
data.set(x, height + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill);
|
data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ?
|
||||||
|
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||||
|
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
|||||||
|
|
||||||
if (decorator != null) {
|
if (decorator != null) {
|
||||||
if (!decorator.isStacking()) {
|
if (!decorator.isStacking()) {
|
||||||
bd = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
bd = decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData());
|
||||||
|
|
||||||
if (!underwater) {
|
if (!underwater) {
|
||||||
if (!canGoOn(bd, bdx)) {
|
if (!canGoOn(bd, bdx)) {
|
||||||
@ -73,16 +73,26 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (height < getDimension().getFluidHeight()) {
|
if (height < getDimension().getFluidHeight()) {
|
||||||
max = getDimension().getFluidHeight() - height;
|
max = getDimension().getFluidHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||||
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
|
if (decorator.isScaleStack()) {
|
||||||
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
int maxStack = max - height;
|
||||||
|
stack = (int) Math.ceil((double)maxStack * ((double)stack / 100));
|
||||||
|
} else stack = Math.min(height - max, stack);
|
||||||
|
|
||||||
|
if (stack == 1) {
|
||||||
|
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < stack; i++) {
|
for (int i = 0; i < stack; i++) {
|
||||||
|
int h = height + i;
|
||||||
double threshold = ((double) i) / (stack - 1);
|
double threshold = ((double) i) / (stack - 1);
|
||||||
bd = threshold >= decorator.getTopThreshold() ? top : fill;
|
bd = threshold >= decorator.getTopThreshold() ?
|
||||||
|
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||||
|
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData());
|
||||||
|
|
||||||
if (bd == null) {
|
if (bd == null) {
|
||||||
break;
|
break;
|
||||||
|
@ -49,7 +49,6 @@ public class PlannedPiece {
|
|||||||
private IrisDataManager data;
|
private IrisDataManager data;
|
||||||
private KList<IrisJigsawPieceConnector> connected;
|
private KList<IrisJigsawPieceConnector> connected;
|
||||||
private boolean dead = false;
|
private boolean dead = false;
|
||||||
private int rotationKey;
|
|
||||||
private AxisAlignedBB box;
|
private AxisAlignedBB box;
|
||||||
private PlannedStructure structure;
|
private PlannedStructure structure;
|
||||||
|
|
||||||
@ -58,11 +57,14 @@ public class PlannedPiece {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, int rx, int ry, int rz) {
|
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, int rx, int ry, int rz) {
|
||||||
|
this(structure, position, piece, IrisObjectRotation.of(rx * 90D, ry * 90D, rz * 90D));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, IrisObjectRotation rot) {
|
||||||
this.structure = structure;
|
this.structure = structure;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
rotationKey = (rz * 100) + (rx * 10) + ry;
|
|
||||||
this.data = piece.getLoader();
|
this.data = piece.getLoader();
|
||||||
this.rotation = IrisObjectRotation.of(rx * 90D, ry * 90D, rz * 90D);
|
this.setRotation(rot);
|
||||||
this.object = structure.rotated(piece, rotation);
|
this.object = structure.rotated(piece, rotation);
|
||||||
this.piece = rotation.rotateCopy(piece);
|
this.piece = rotation.rotateCopy(piece);
|
||||||
this.piece.setLoadKey(piece.getLoadKey());
|
this.piece.setLoadKey(piece.getLoadKey());
|
||||||
@ -76,7 +78,7 @@ public class PlannedPiece {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return piece.getLoadKey() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")[rot:" + rotationKey + "]";
|
return piece.getLoadKey() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")[rot:" + rotation.toString() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBB getBox() {
|
public AxisAlignedBB getBox() {
|
||||||
|
@ -211,6 +211,12 @@ public class PlannedStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea) {
|
private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea) {
|
||||||
|
if (!piece.getPiece().getPlacementOptions().getRotation().isEnabled()) {
|
||||||
|
if (generateRotatedPiece(piece, pieceConnector, idea, 0, 0, 0)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KList<Integer> forder1 = new KList<Integer>().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng);
|
KList<Integer> forder1 = new KList<Integer>().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng);
|
||||||
KList<Integer> forder2 = new KList<Integer>().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng);
|
KList<Integer> forder2 = new KList<Integer>().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng);
|
||||||
|
|
||||||
@ -238,8 +244,10 @@ public class PlannedStructure {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, int x, int y, int z) {
|
private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, IrisObjectRotation rotation) {
|
||||||
PlannedPiece test = new PlannedPiece(this, piece.getPosition(), idea, x, y, z);
|
if (!idea.getPlacementOptions().getRotation().isEnabled()) rotation = piece.getRotation(); //Inherit parent rotation
|
||||||
|
|
||||||
|
PlannedPiece test = new PlannedPiece(this, piece.getPosition(), idea, rotation);
|
||||||
|
|
||||||
for (IrisJigsawPieceConnector j : test.getPiece().getConnectors().shuffleCopy(rng)) {
|
for (IrisJigsawPieceConnector j : test.getPiece().getConnectors().shuffleCopy(rng)) {
|
||||||
if (generatePositionedPiece(piece, pieceConnector, test, j)) {
|
if (generatePositionedPiece(piece, pieceConnector, test, j)) {
|
||||||
@ -250,6 +258,10 @@ public class PlannedStructure {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, int x, int y, int z) {
|
||||||
|
return generateRotatedPiece(piece, pieceConnector, idea, IrisObjectRotation.of(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean generatePositionedPiece(PlannedPiece piece,
|
private boolean generatePositionedPiece(PlannedPiece piece,
|
||||||
IrisJigsawPieceConnector pieceConnector,
|
IrisJigsawPieceConnector pieceConnector,
|
||||||
PlannedPiece test,
|
PlannedPiece test,
|
||||||
|
@ -56,17 +56,20 @@ public class IrisDecorator {
|
|||||||
@DependsOn({"stackMin", "stackMax"})
|
@DependsOn({"stackMin", "stackMax"})
|
||||||
@MinNumber(1)
|
@MinNumber(1)
|
||||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||||
|
|
||||||
@Desc("The minimum repeat stack height (setting to 3 would stack 3 of <block> on top of each other")
|
@Desc("The minimum repeat stack height (setting to 3 would stack 3 of <block> on top of each other")
|
||||||
private int stackMin = 1;
|
private int stackMin = 1;
|
||||||
|
|
||||||
@DependsOn({"stackMin", "stackMax"})
|
@DependsOn({"stackMin", "stackMax"})
|
||||||
@MinNumber(1)
|
@MinNumber(1)
|
||||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||||
|
|
||||||
@Desc("The maximum repeat stack height")
|
@Desc("The maximum repeat stack height")
|
||||||
private int stackMax = 1;
|
private int stackMax = 1;
|
||||||
|
|
||||||
|
@DependsOn({"stackMin", "stackMax"})
|
||||||
|
@Desc("Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height" +
|
||||||
|
"\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height")
|
||||||
|
private boolean scaleStack = false;
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@MinNumber(0)
|
@MinNumber(0)
|
||||||
@MaxNumber(1)
|
@MaxNumber(1)
|
||||||
@ -145,17 +148,19 @@ public class IrisDecorator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getBlockData100(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) {
|
public BlockData getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisDataManager data) {
|
||||||
if (getBlockData(data).isEmpty()) {
|
if (getBlockData(data).isEmpty()) {
|
||||||
Iris.warn("Empty Block Data for " + b.getName());
|
Iris.warn("Empty Block Data for " + b.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
double xx = x;
|
double xx = x;
|
||||||
|
double yy = y;
|
||||||
double zz = z;
|
double zz = z;
|
||||||
|
|
||||||
if (!getVarianceGenerator(rng, data).isStatic()) {
|
if (!getVarianceGenerator(rng, data).isStatic()) {
|
||||||
xx = x / style.getZoom();
|
xx = x / style.getZoom();
|
||||||
|
yy = y / style.getZoom();
|
||||||
zz = z / style.getZoom();
|
zz = z / style.getZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,23 +168,23 @@ public class IrisDecorator {
|
|||||||
return getBlockData(data).get(0);
|
return getBlockData(data).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x).clone(); //X and Z must be switched
|
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, y, x).clone(); //X and Z must be switched
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) {
|
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisDataManager data) {
|
||||||
if (getBlockDataTops(data).isEmpty()) {
|
if (getBlockDataTops(data).isEmpty()) {
|
||||||
return null;
|
return getBlockData100(b, rng, x, y, z, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
double xx = x / style.getZoom();
|
double xx = x / style.getZoom();
|
||||||
double zz = z / style.getZoom();
|
double zz = z / style.getZoom();
|
||||||
|
|
||||||
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) {
|
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||||
if (getBlockData(data).size() == 1) {
|
if (getBlockData(data).size() == 1) {
|
||||||
return getBlockDataTops(data).get(0);
|
return getBlockDataTops(data).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), z, x); //X and Z must be switched
|
return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), z, y, x); //X and Z must be switched
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -72,7 +72,7 @@ public abstract class MortarCommand implements ICommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) {
|
if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||||
sender.player().getWorld().playSound(sender.player().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f);
|
sender.player().playSound(sender.player().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user