Added Top Threshold option to decorators

- Added topThreshold option to decorators. Allows stacked blocks to start using the top palette for x percent of the stack
This commit is contained in:
StrangeOne101 2021-07-10 17:33:32 +12:00
parent 4a5794ad5f
commit 13a5482f91
6 changed files with 29 additions and 12 deletions

View File

@ -30,9 +30,13 @@ public class IrisCeilingDecorator extends IrisEngineDecorator
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
stack = Math.min(max + 1, stack);
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++)
{
data.set(x, height-i, z, i == 0 ? decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()) : decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
double threshold = (((double)i) / (double)(stack - 1));
data.set(x, height-i, z, threshold >= decorator.getTopThreshold() ? top : fill);
}
}
}

View File

@ -1,6 +1,5 @@
package com.volmit.iris.generator.decorator;
import com.volmit.iris.Iris;
import com.volmit.iris.object.DecorationPart;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisDecorator;
@ -31,12 +30,14 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
stack = Math.min(stack, getDimension().getFluidHeight() - height + 2);
//Iris.info("Stack at " + realX + "," + realZ + " is " + stack);
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++)
{
data.set(x, height+i, z, i == stack-1 ? top : fill);
double threshold = ((double)i) / (stack - 1);
data.set(x, height+i, z, threshold >= decorator.getTopThreshold() ? top : fill);
}
}
}

View File

@ -30,9 +30,12 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), 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++)
{
data.set(x, getDimension().getFluidHeight()+1+i, z, i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData()));
double threshold = ((double)i) / (stack - 1);
data.set(x, getDimension().getFluidHeight()+1+i, z, threshold >= decorator.getTopThreshold() ? top : fill);
}
}
}

View File

@ -36,9 +36,13 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), 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++)
{
data.set(x, height+1+i, z, i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData()));
double threshold = ((double)i) / (stack - 1);
data.set(x, height+1+i, z, threshold >= decorator.getTopThreshold() ? top : fill);
}
}
}

View File

@ -70,15 +70,13 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
}
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), 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++)
{
bd = i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData());
if(bd == null && i == stack-1)
{
bd = decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData());
}
double threshold = ((double)i) / (stack - 1);
bd = threshold >= decorator.getTopThreshold() ? top : fill;
if(bd == null)
{

View File

@ -72,6 +72,13 @@ public class IrisDecorator
@Desc("The palette of blocks used at the very top of a 'stackMax' of higher than 1. For example, bamboo tops.")
private KList<IrisBlockData> topPalette = new KList<IrisBlockData>();
@DependsOn("topPalette")
@MinNumber(0.01)
@MaxNumber(1.0)
@DontObfuscate
@Desc("When the stack passes the top threshold, the top palette will start being used instead of the normal palette.")
private double topThreshold = 1.0;
private final transient AtomicCache<CNG> layerGenerator = new AtomicCache<>();
private final transient AtomicCache<CNG> varianceGenerator = new AtomicCache<>();
private final transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();