Decor Updates

- Fixed decorators using the same RNG when picking from a pool of blocks as it used to place it. This caused it to only use pool entries above the placement chance threshold. (E.g. a flower pool with a 0.15 chance to place will only use the first 0.15 of the pool of flowers since the RNG is the same)
- Removed `zoom`, `verticalZoom` and `varianceZoom` properties from decorators. Zooms can be done inside the individual styles instead.
- WIP Tab Completion (Create command only rn)

Dev notes:
It's very important from now on that in decorators, the X and Z remain switched when getting noise so that the result of the noise is not exactly the same as the noise that choose if the decor should be placed or not
This commit is contained in:
StrangeOne101 2021-07-09 23:21:55 +12:00
parent b4f866be03
commit f1dfb1c952
5 changed files with 89 additions and 42 deletions

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)
@ -101,7 +85,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());
}
public CNG getHeightGenerator(RNG rng, IrisDataManager data)
@ -123,7 +107,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 +124,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 +134,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), zz, xx); //X and Z must be switched
}
return null;
@ -169,8 +153,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 +162,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), zz, xx).clone(); //X and Z must be switched
}
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data)
@ -188,8 +172,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 +182,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), zz, xx); //X and Z must be switched
}
return null;

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<?>>();