Merge pull request #408 from StrangeOne101/1.17

Decorator Updates
This commit is contained in:
Dan 2021-07-10 23:20:59 -04:00 committed by GitHub
commit 18d8f07242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 210 additions and 90 deletions

View File

@ -52,6 +52,7 @@ public class IrisComplex implements DataProvider
private ProceduralStream<IrisDecorator> terrainCaveSurfaceDecoration;
private ProceduralStream<IrisDecorator> terrainCaveCeilingDecoration;
private ProceduralStream<IrisDecorator> seaSurfaceDecoration;
private ProceduralStream<IrisDecorator> seaFloorDecoration;
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
private ProceduralStream<BlockData> rockStream;
private ProceduralStream<BlockData> fluidStream;
@ -191,6 +192,8 @@ public class IrisComplex implements DataProvider
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SHORE_LINE));
seaSurfaceDecoration = trueBiomeStream
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_SURFACE));
seaFloorDecoration = trueBiomeStream
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_FLOOR));
trueHeightStream = ProceduralStream.of((x, z) -> {
int rx = (int) Math.round(engine.modifyX(x));
int rz = (int) Math.round(engine.modifyZ(z));

View File

@ -1,5 +1,6 @@
package com.volmit.iris.generator.actuator;
import com.volmit.iris.generator.decorator.IrisSeaFloorDecorator;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG;
@ -28,6 +29,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
@Getter
private final EngineDecorator seaSurfaceDecorator;
@Getter
private final EngineDecorator seaFloorDecorator;
@Getter
private final EngineDecorator shoreLineDecorator;
private final boolean shouldRay;
@ -39,6 +42,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
ceilingDecorator = new IrisCeilingDecorator(getEngine());
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
shoreLineDecorator = new IrisShoreLineDecorator(getEngine());
seaFloorDecorator = new IrisSeaFloorDecorator(getEngine());
}
@Override
@ -49,9 +53,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
}
PrecisionStopwatch p = PrecisionStopwatch.start();
boolean solid;
int emptyFor = 0;
int lastSolid = 0;
int j, realX, realZ, height;
IrisBiome biome, cave;
@ -59,6 +61,9 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
{
for(j = 0; j < output.getDepth(); j++)
{
boolean solid;
int emptyFor = 0;
int lastSolid = 0;
realX = (int) Math.round(modX(x + i));
realZ = (int) Math.round(modZ(z + j));
height = (int) Math.round(getComplex().getHeightStream().get(realX, realZ));
@ -77,10 +82,16 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
realZ, (int) Math.round(modZ(z + j+1)), (int) Math.round(modZ(z + j-1)),
output, biome, height, getEngine().getHeight() - height);
}
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());
}
else if(height < getDimension().getFluidHeight())
{
getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, getDimension().getFluidHeight(), getEngine().getHeight() - getDimension().getFluidHeight());
getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight());
}
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
@ -93,18 +104,16 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
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);
emptyFor = 0;
}
lastSolid = k;
}
else {
emptyFor++;
}
if(solid && emptyFor > 0)
else
{
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid, emptyFor);
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
emptyFor = 0;
emptyFor++;
}
}
}

View File

@ -22,16 +22,21 @@ public class IrisCeilingDecorator extends IrisEngineDecorator
{
if(!decorator.isStacking())
{
data.set(x, height-1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
}
else
{
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
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-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) / (double)(stack - 1));
data.set(x, height - i, z, threshold >= decorator.getTopThreshold() ? top : fill);
}
}
}

View File

@ -0,0 +1,46 @@
package com.volmit.iris.generator.decorator;
import com.volmit.iris.object.DecorationPart;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisDecorator;
import com.volmit.iris.scaffold.cache.Cache;
import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.hunk.Hunk;
import org.bukkit.block.data.BlockData;
public class IrisSeaFloorDecorator extends IrisEngineDecorator
{
public IrisSeaFloorDecorator(Engine engine) {
super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
}
@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);
if(decorator != null)
{
if(!decorator.isStacking())
{
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, 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++)
{
double threshold = ((double)i) / (stack - 1);
data.set(x, height+i, z, threshold >= decorator.getTopThreshold() ? top : fill);
}
}
}
}
}
}

View File

@ -16,8 +16,6 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
@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);
if(decorator != null)
@ -26,16 +24,16 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
{
data.set(x, getDimension().getFluidHeight()+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
}
else
{
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
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

@ -32,14 +32,17 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator
{
data.set(x, height+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
}
else
{
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
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

@ -62,23 +62,21 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
data.set(x, height+1, z, bd);
}
else {
else
{
if (height < getDimension().getFluidHeight())
{
max = getDimension().getFluidHeight() - height;
}
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
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

@ -2,6 +2,7 @@ package com.volmit.iris.manager.command.world;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.generator.IrisWorldManager;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.manager.link.MultiverseCoreLink;
import com.volmit.iris.nms.INMS;
@ -15,6 +16,8 @@ import org.bukkit.World;
import org.bukkit.WorldCreator;
import java.io.File;
import java.util.Locale;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceArray;
@ -31,7 +34,56 @@ public class CommandIrisCreate extends MortarCommand
@Override
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
if (args.length == 0 || args[args.length - 1].equals("")) { //They are about to type a new argument
list.addAll(getBase(args));
return;
}
String[] split = args[args.length - 1].split("\\Q=\\E");
if (split.length == 0) { //They haven't typed the = yet so just keep the options there
list.addAll(getBase(args));
return;
}
String pre = split[0].toLowerCase();
if (pre.equals("type")) {
for (String s : Iris.proj.getListing(true).keySet()) {
list.add("type=" + s);
}
if (!list.contains("type=overworld")) {
list.contains("type=overworld");
}
} else if (pre.equals("seed")) {
list.add("seed=1337");
list.add("seed=" + new Random().nextInt());
list.add("seed=random");
} else if (pre.equals("pregen")) {
list.add("500");
list.add("1000");
list.add("2000");
list.add("5k");
list.add("10k");
list.add("25k");
}
}
private KList<String> getBase(String[] args) {
KList<String> list = new KList<>();
boolean seed = true;
boolean type = true;
boolean pregen = true;
for (String s : args) {
if (s.toLowerCase().startsWith("seed=")) seed = false;
else if (s.toLowerCase().startsWith("type=")) type = false;
else if (s.toLowerCase().startsWith("pregen=")) pregen = false;
}
if (seed) list.add("seed=");
if (type) list.add("type=");
if (pregen) list.add("pregen=");
return list;
}
@Override
@ -42,17 +94,17 @@ public class CommandIrisCreate extends MortarCommand
sender.sendMessage("/iris create <NAME> [type=overworld] [seed=1337] [pregen=5000]");
return true;
}
Random random = new Random();
String worldName = args[0];
String type = IrisSettings.get().getGenerator().getDefaultWorldType();
long seed = 1337;
AtomicInteger pregen = new AtomicInteger(0);
long seed = random.nextLong(); //Random seed when creating a world
AtomicInteger pregen = new AtomicInteger(256);
boolean multiverse = Iris.linkMultiverseCore.supported();
for(String i : args)
{
type = i.startsWith("type=") ? i.split("\\Q=\\E")[1] : type;
seed = i.startsWith("seed=") ? Long.valueOf(i.split("\\Q=\\E")[1]) : seed;
seed = i.startsWith("seed=") ? (i.split("\\Q=\\E")[1].equalsIgnoreCase("random") ? random.nextLong() : Long.valueOf(i.split("\\Q=\\E")[1])) : seed;
pregen.set(i.startsWith("pregen=") ? getVal(i.split("\\Q=\\E")[1]) : pregen.get());
}
@ -61,8 +113,6 @@ public class CommandIrisCreate extends MortarCommand
IrisDimension dim;
File folder = new File(worldName);
Runnable onDone = () -> {
sender.sendMessage(worldName + " Spawn Area generated.");
@ -88,10 +138,12 @@ public class CommandIrisCreate extends MortarCommand
if(pregen.get() > 0)
{
b.set(false);
sender.sendMessage("Pregenerating " + worldName + " " + pregen + " x " + pregen);
int size = pregen.get();
size *= 2;
sender.sendMessage("Pregenerating " + worldName + " " + size + " x " + size);
sender.sendMessage("Expect server lag during this time. Use '/iris pregen stop' to cancel");
new Pregenerator(world.get(), pregen.get(), () ->
new Pregenerator(world.get(), size, () ->
{
b.set(true);
});
@ -119,7 +171,6 @@ public class CommandIrisCreate extends MortarCommand
};
if(multiverse)
{
dim = IrisDataManager.loadAnyDimension(type);
@ -148,7 +199,6 @@ public class CommandIrisCreate extends MortarCommand
world.set(Bukkit.getWorld(worldName));
onDone.run();
}
else
{
if(folder.exists())
@ -195,7 +245,12 @@ public class CommandIrisCreate extends MortarCommand
}
});
world.set(INMS.get().createWorld(wc));
World w = INMS.get().createWorld(wc);
world.set(w);
J.a(() -> {
new Pregenerator(w, pregen.get() * 2);
});
done.set(true);
});

View File

@ -104,7 +104,7 @@ public class CommandIrisPregen extends MortarCommand
}
}
try {
new Pregenerator(world, getVal(args[0]));
new Pregenerator(world, getVal(args[0]) * 2);
} catch (NumberFormatException e){
sender.sendMessage("Invalid argument in command");
return true;
@ -120,7 +120,7 @@ public class CommandIrisPregen extends MortarCommand
else
{
if (args.length < 1){
sender.sendMessage("Please specify the size of the pregen and the name of the world. E.g. /ir pregen 5k world");
sender.sendMessage("Please specify the radius of the pregen and the name of the world. E.g. /ir pregen 5k world");
return true;
}
if (args.length < 2){
@ -129,7 +129,7 @@ public class CommandIrisPregen extends MortarCommand
}
World world = Bukkit.getWorld(args[1]);
try {
new Pregenerator(world, getVal(args[0]));
new Pregenerator(world, getVal(args[0]) * 2);
} catch (NumberFormatException e){
sender.sendMessage("Invalid argument in command");
return true;
@ -166,6 +166,6 @@ public class CommandIrisPregen extends MortarCommand
@Override
protected String getArgsUsage()
{
return "[width]";
return "[radius]";
}
}

View File

@ -18,6 +18,10 @@ public enum DecorationPart
@DontObfuscate
SEA_SURFACE,
@Desc("Targets the sea floor (entire placement must be bellow sea level)")
@DontObfuscate
SEA_FLOOR,
@Desc("Decorates on cave & carving ceilings or underside of overhangs")
@DontObfuscate
CEILING,

View File

@ -54,22 +54,6 @@ public class IrisDecorator
@Desc("The maximum repeat stack height")
private int stackMax = 1;
@MinNumber(0.0001)
@DontObfuscate
@Desc("The zoom is for zooming in or out wispy dispersions. Makes patches bigger the higher this zoom value is")
private double zoom = 1;
@MinNumber(0.0001)
@DontObfuscate
@Desc("The zoom is for zooming in or out variance. Makes patches have more or less of one type.")
private double varianceZoom = 1;
@DependsOn({"stackMin", "stackMax"})
@MinNumber(0.0001)
@DontObfuscate
@Desc("The vertical zoom is for wispy stack heights. Zooming this in makes stack heights more slowly change over a distance")
private double verticalZoom = 1;
@Required
@MinNumber(0)
@MaxNumber(1)
@ -88,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<>();
@ -101,7 +92,7 @@ public class IrisDecorator
return stackMin;
}
return getHeightGenerator(rng, data).fit(stackMin, stackMax, x / verticalZoom, z / verticalZoom);
return getHeightGenerator(rng, data).fit(stackMin, stackMax, x / heightVariance.getZoom(), z / heightVariance.getZoom()) + 1;
}
public CNG getHeightGenerator(RNG rng, IrisDataManager data)
@ -123,7 +114,7 @@ public class IrisDecorator
variance.create(
rng.nextParallelRNG((int) (getBlockData(data).size())))
.scale(1D / varianceZoom));
.scale(1D / variance.getZoom()));
}
public KList<IrisBlockData> add(String b)
@ -140,8 +131,8 @@ public class IrisDecorator
return null;
}
double xx = x / getZoom();
double zz = z / getZoom();
double xx = x / style.getZoom();
double zz = z / style.getZoom();
if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance)
{
@ -150,7 +141,7 @@ public class IrisDecorator
return getBlockData(data).get(0);
}
return getVarianceGenerator(rng, data).fit(getBlockData(data), xx, zz);
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x); //X and Z must be switched
}
return null;
@ -169,8 +160,8 @@ public class IrisDecorator
if(!getVarianceGenerator(rng, data).isStatic())
{
xx = x / getZoom();
zz = z / getZoom();
xx = x / style.getZoom();
zz = z / style.getZoom();
}
if(getBlockData(data).size() == 1)
@ -178,7 +169,7 @@ public class IrisDecorator
return getBlockData(data).get(0);
}
return getVarianceGenerator(rng, data).fit(getBlockData(data), xx, zz).clone();
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x).clone(); //X and Z must be switched
}
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data)
@ -188,8 +179,8 @@ public class IrisDecorator
return null;
}
double xx = x / getZoom();
double zz = z / getZoom();
double xx = x / style.getZoom();
double zz = z / style.getZoom();
if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance)
{
@ -198,7 +189,7 @@ public class IrisDecorator
return getBlockDataTops(data).get(0);
}
return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), xx, zz);
return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), z, x); //X and Z must be switched
}
return null;
@ -214,9 +205,11 @@ public class IrisDecorator
BlockData bx = i.getBlockData(data);
if(bx != null)
{
for (int n = 0; n < i.getWeight(); n++) {
blockData.add(bx);
}
}
}
return blockData;
});
@ -232,9 +225,11 @@ public class IrisDecorator
BlockData bx = i.getBlockData(data);
if(bx != null)
{
for (int n = 0; n < i.getWeight(); n++) {
blockDataTops.add(bx);
}
}
}
return blockDataTops;
});

View File

@ -106,6 +106,10 @@ public class V
return null;
}
public Object getSelf() {
return o;
}
public Object invoke(String method, Object... parameters)
{
KList<Class<?>> par = new KList<Class<?>>();