diff --git a/src/main/java/com/volmit/iris/core/commands/CommandIris.java b/src/main/java/com/volmit/iris/core/commands/CommandIris.java index 45a360f8f..92f9784a5 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -39,6 +39,7 @@ import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.jobs.QueueJob; import org.bukkit.Chunk; +import org.bukkit.World; import java.io.File; import java.util.concurrent.ExecutionException; @@ -252,4 +253,40 @@ public class CommandIris implements DecreeExecutor { sender().sendMessage(C.RED + "You must be in an Iris World to use regen!"); } } + + @Decree(description = "Update the pack of a world (UNSAFE!)", name = "^world", aliases = "update-world") + public void updateWorld( + @Param(description = "The world to update", contextual = true) + World world, + @Param(description = "The pack to install into the world", contextual = true, aliases = "dimension") + IrisDimension pack, + @Param(description = "Make sure to make a backup & read the warnings first!", defaultValue = "false", aliases = "c") + boolean confirm, + @Param(description = "Should Iris download the pack again for you", defaultValue = "false", name = "fresh-download", aliases = {"fresh", "new"}) + boolean freshDownload + ) { + if (!confirm) { + sender().sendMessage(new String[]{ + C.RED + "You should always make a backup before using this", + C.YELLOW + "Issues caused by this can be, but are not limited to:", + C.YELLOW + " - Broken chunks (cut-offs) between old and new chunks (before & after the update)", + C.YELLOW + " - Regenerated chunks that do not fit in with the old chunks", + C.YELLOW + " - Structures not spawning again when regenerating", + C.YELLOW + " - Caves not lining up", + C.YELLOW + " - Terrain layers not lining up", + C.RED + "Now that you are aware of the risks, and have made a back-up:", + C.RED + "/iris ^world confirm=true" + }); + return; + } + + File folder = world.getWorldFolder(); + folder.mkdirs(); + + if (freshDownload) { + Iris.service(StudioSVC.class).downloadSearch(sender(), pack.getLoadKey(), false, true); + } + + Iris.service(StudioSVC.class).installIntoWorld(sender(), pack.getLoadKey(), folder); + } } diff --git a/src/main/java/com/volmit/iris/core/commands/CommandStudio.java b/src/main/java/com/volmit/iris/core/commands/CommandStudio.java index b99055c39..2c06be6c4 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandStudio.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandStudio.java @@ -658,7 +658,7 @@ public class CommandStudio implements DecreeExecutor { player().setGameMode(GameMode.SPECTATOR); } - @Decree(description = "Update your dimension project") + @Decree(description = "Update your dimension projects VSCode workspace") public void update( @Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld") IrisDimension dimension diff --git a/src/main/java/com/volmit/iris/core/project/IrisProject.java b/src/main/java/com/volmit/iris/core/project/IrisProject.java index b46bcb6f9..8e2735f60 100644 --- a/src/main/java/com/volmit/iris/core/project/IrisProject.java +++ b/src/main/java/com/volmit/iris/core/project/IrisProject.java @@ -525,9 +525,9 @@ public class IrisProject { public void compile(VolmitSender sender) { IrisData data = IrisData.get(getPath()); - KList jobs = new KList(); - KList files = new KList(); - KList objects = new KList(); + KList jobs = new KList<>(); + KList files = new KList<>(); + KList objects = new KList<>(); files(getPath(), files); filesObjects(getPath(), objects); diff --git a/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java b/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java index 1c6a10cbe..35c1ad505 100644 --- a/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java +++ b/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java @@ -87,7 +87,7 @@ public class MantleObjectComponent extends IrisMantleComponent { @BlockCoordinates private void placeObject(MantleWriter writer, RNG rng, int x, int z, IrisObjectPlacement objectPlacement) { - for (int i = 0; i < objectPlacement.getDensity(); i++) { + for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) { IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng)); if (v == null) { return; @@ -104,7 +104,7 @@ public class MantleObjectComponent extends IrisMantleComponent { @BlockCoordinates private Set guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) { Set f = new KSet<>(); - for (int i = 0; i < objectPlacement.getDensity(); i++) { + for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) { IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng)); if (v == null) { continue; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java index 923054d9b..92cde98c2 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java @@ -62,7 +62,6 @@ public class IrisObjectPlacement { private IrisObjectRotation rotation = new IrisObjectRotation(); @Desc("Limit the max height or min height of placement.") private IrisObjectLimit clamp = new IrisObjectLimit(); - @MinNumber(0) @MaxNumber(1) @Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.") @@ -74,6 +73,8 @@ public class IrisObjectPlacement { @MinNumber(1) @Desc("If the chance check passes, place this many in a single chunk") private int density = 1; + @Desc("If the chance check passes, and you specify this, it picks a number in the range based on noise, and 'density' is ignored.") + private IrisStyledRange densityStyle = null; @MaxNumber(64) @MinNumber(0) @Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.") @@ -164,18 +165,6 @@ public class IrisObjectPlacement { return getSurfaceWarp(rng, data).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z); } - public int getTriesForChunk(RNG random) { - if (chance <= 0) { - return 0; - } - - if (chance >= 1 || random.nextDouble() < chance) { - return density; - } - - return 0; - } - public IrisObject getObject(DataProvider g, RNG random) { if (place.isEmpty()) { return null; @@ -194,6 +183,21 @@ public class IrisObjectPlacement { return false; } + public int getDensity() { + if (densityStyle == null) { + return density; + } + return densityStyle.getMid(); + } + + public int getDensity(RNG rng, double x, double z, IrisData data) { + if (densityStyle == null) { + return density; + } + + return (int) Math.round(densityStyle.get(rng, x, z, data)); + } + private TableCache getCache(IrisData manager) { return cache.aquire(() -> { TableCache tc = new TableCache();