9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00

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]";
}
}