Added scaleStack property to decorators

- Added scaleStack to decorators. It allows the size of the stack to scale to the size of the cave, using stackMin and stackMax as a min/max percentage
- Fixed stacks missing a block in size when the top block isn't defined
- Changed decorator stacks of a single block to place the top block instead of the body
- Fixed tab sound playing to other players
This commit is contained in:
StrangeOne101 2021-07-27 00:04:17 +12:00
parent 5fabec6a42
commit 21ce09a5b5
8 changed files with 47 additions and 11 deletions

View File

@ -118,11 +118,12 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
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()); 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));
@ -131,7 +132,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
if (solid) { if (solid) {
if (emptyFor > 0) { if (emptyFor > 0) {
if (liquid) { if (liquid) {
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, cave, k + 1, liquidFor + lastSolid - 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); getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k + liquidFor + 1, emptyFor - liquidFor + lastSolid);
} else { } else {
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, lastSolid); getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, lastSolid);

View File

@ -44,11 +44,19 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
} }
} 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()) {
int maxStack = max - height;
stack = (int) Math.ceil((double)maxStack * ((double)stack / 100));
} else stack = Math.min(max + 1, stack);
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
if (stack == 1) {
data.set(x, height, z, top);
return;
}
for (int i = 0; i < stack; i++) { for (int i = 0; i < stack; i++) {
if (height - i < 0 || height - i > getEngine().getHeight()) { if (height - i < 0 || height - i > getEngine().getHeight()) {
continue; continue;

View File

@ -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;
@ -44,11 +45,19 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
} }
} 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(stack, max - height + 2); if (decorator.isScaleStack()) {
int maxStack = max - height;
stack = (int)Math.ceil((double)maxStack * ((double)stack / 100));
} else stack = Math.min(stack, max - height);
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
if (stack == 1) {
data.set(x, height, z, top);
return;
}
for (int i = 0; i < stack; i++) { for (int i = 0; i < stack; i++) {
if (height + i > max || height + i > getEngine().getHeight()) { if (height + i > max || height + i > getEngine().getHeight()) {
continue; continue;

View File

@ -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;
@ -44,7 +45,10 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
} }
} 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));
}
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(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++) {

View File

@ -49,7 +49,10 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, 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 - height, stack); 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()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());

View File

@ -77,10 +77,18 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
} }
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(height - max, stack); if (decorator.isScaleStack()) {
int maxStack = max - height;
stack = (int) Math.ceil((double)maxStack * ((double)stack / 100));
} else stack = Math.min(height - max, stack);
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
if (stack == 1) {
data.set(x, height, z, top);
return;
}
for (int i = 0; i < stack; i++) { for (int i = 0; i < stack; i++) {
double threshold = ((double) i) / (stack - 1); double threshold = ((double) i) / (stack - 1);
bd = threshold >= decorator.getTopThreshold() ? top : fill; bd = threshold >= decorator.getTopThreshold() ? top : fill;

View File

@ -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)
@ -168,7 +171,7 @@ public class IrisDecorator {
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) { public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) {
if (getBlockDataTops(data).isEmpty()) { if (getBlockDataTops(data).isEmpty()) {
return null; return getBlockData100(b, rng, x, z, data);
} }
double xx = x / style.getZoom(); double xx = x / style.getZoom();

View File

@ -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;