From 7f1f1e025ea6b0e58c041b6f11a207ebbd6e18f3 Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 9 Feb 2024 13:48:56 +0100 Subject: [PATCH] feat: configurable accounting for bedrock layer when setting components (#4266) - Add configuration option to force plot components to be set only above bedrock level - Account for build height < gen height where it is not wanted for components to be set at/below bedrock --- .../core/generator/ClassicPlotManager.java | 6 +++--- .../core/generator/ClassicPlotWorld.java | 12 ++++++++++++ .../com/plotsquared/core/plot/PlotArea.java | 18 ++++++++++++++++++ Core/src/main/resources/lang/messages_en.json | 1 + 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java index 335602ac2..bfb15d823 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java @@ -143,7 +143,7 @@ public class ClassicPlotManager extends SquarePlotManager { classicPlotWorld, plot.getRegions(), blocks, - classicPlotWorld.getMinBuildHeight(), + classicPlotWorld.getMinComponentHeight(), classicPlotWorld.getMaxBuildHeight() - 1, actor, queue @@ -204,7 +204,7 @@ public class ClassicPlotManager extends SquarePlotManager { classicPlotWorld, plot.getRegions(), blocks, - classicPlotWorld.getMinBuildHeight(), + classicPlotWorld.getMinComponentHeight(), classicPlotWorld.PLOT_HEIGHT - 1, actor, queue @@ -379,7 +379,7 @@ public class ClassicPlotManager extends SquarePlotManager { } } - int yStart = classicPlotWorld.getMinBuildHeight() + (classicPlotWorld.PLOT_BEDROCK ? 1 : 0); + int yStart = classicPlotWorld.getMinComponentHeight(); if (!plot.isMerged(Direction.NORTH)) { int z = bot.getZ(); for (int x = bot.getX(); x < top.getX(); x++) { diff --git a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java index 733931f6e..298315724 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java @@ -52,6 +52,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { public BlockBucket ROAD_BLOCK = new BlockBucket(BlockTypes.QUARTZ_BLOCK); public boolean PLOT_BEDROCK = true; public boolean PLACE_TOP_BLOCK = true; + public boolean COMPONENT_BELOW_BEDROCK = false; public ClassicPlotWorld( final @NonNull String worldName, @@ -129,6 +130,9 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { ), new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, TranslatableCaption.of("setup.bedrock_boolean"), ConfigurationUtil.BOOLEAN + ), + new ConfigurationNode("world.component_below_bedrock", this.COMPONENT_BELOW_BEDROCK, TranslatableCaption.of( + "setup.component_below_bedrock_boolean"), ConfigurationUtil.BOOLEAN )}; } @@ -150,6 +154,14 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { this.PLACE_TOP_BLOCK = config.getBoolean("wall.place_top_block"); this.WALL_HEIGHT = Math.min(getMaxGenHeight() - (PLACE_TOP_BLOCK ? 1 : 0), config.getInt("wall.height")); this.CLAIMED_WALL_BLOCK = createCheckedBlockBucket(config.getString("wall.block_claimed"), CLAIMED_WALL_BLOCK); + this.COMPONENT_BELOW_BEDROCK = config.getBoolean("world.component_below_bedrock"); + } + + @Override + public int getMinComponentHeight() { + return COMPONENT_BELOW_BEDROCK && getMinGenHeight() >= getMinBuildHeight() + ? getMinGenHeight() + (PLOT_BEDROCK ? 1 : 0) + : getMinBuildHeight(); } int schematicStartHeight() { diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index ad6861da1..aeeb1ab02 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -1452,6 +1452,24 @@ public abstract class PlotArea implements ComponentLike { this.defaultHome = defaultHome; } + /** + * Get the maximum height that changes to plot components (wall filling, air, all etc.) may operate to + * + * @since TODO + */ + public int getMaxComponentHeight() { + return this.maxBuildHeight; + } + + /** + * Get the minimum height that changes to plot components (wall filling, air, all etc.) may operate to + * + * @since TODO + */ + public int getMinComponentHeight() { + return this.minBuildHeight; + } + /** * Get the maximum height players may build in. Exclusive. */ diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 2e9f85b6d..a0d4e42d1 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -166,6 +166,7 @@ "setup.wall_height": "Wall height", "setup.min_gen_height": "Minimum height from which to generate (for 1.18+ can be negative).", "setup.bedrock_boolean": "Whether a bedrock layer under the plot should be generated or not", + "setup.component_below_bedrock_boolean": "Whether a component change e.g. /plot set walls should edit the bedrock layer or below", "setup.singleplotarea_void_world": "Void world", "plotareatype.plot_area_type_normal": "Standard plot generation", "plotareatype.plot_area_type_augmented": "Plot generation with vanilla terrain",