Skip to content

Commit

Permalink
feat: configurable accounting for bedrock layer when setting components
Browse files Browse the repository at this point in the history
  • Loading branch information
dordsor21 committed Dec 12, 2023
1 parent 4a45729 commit d85e3f4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public boolean setAll(
classicPlotWorld,
plot.getRegions(),
blocks,
classicPlotWorld.getMinBuildHeight(),
classicPlotWorld.getMinComponentHeight(),
classicPlotWorld.getMaxBuildHeight() - 1,
actor,
queue
Expand Down Expand Up @@ -204,7 +204,7 @@ public boolean setMain(
classicPlotWorld,
plot.getRegions(),
blocks,
classicPlotWorld.getMinBuildHeight(),
classicPlotWorld.getMinComponentHeight(),
classicPlotWorld.PLOT_HEIGHT - 1,
actor,
queue
Expand Down Expand Up @@ -379,7 +379,7 @@ public boolean setWallFilling(
}
}

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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -129,6 +130,9 @@ public ConfigurationNode[] getSettingNodes() {
),
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
)};
}

Expand All @@ -150,6 +154,14 @@ public void loadConfiguration(ConfigurationSection config) {
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 && PLOT_BEDROCK && getMinGenHeight() >= getMinBuildHeight()
? getMinGenHeight() + 1
: getMinBuildHeight();
}

int schematicStartHeight() {
Expand Down
14 changes: 14 additions & 0 deletions Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,20 @@ protected void setDefaultHome(BlockLoc defaultHome) {
this.defaultHome = defaultHome;
}

/**
* Get the maximum height that changes to plot components (wall filling, air, all etc.) may operate to
*/
public int getMixComponentHeight() {
return this.maxBuildHeight;
}

/**
* Get the minimum height that changes to plot components (wall filling, air, all etc.) may operate to
*/
public int getMinComponentHeight() {
return this.minBuildHeight;
}

/**
* Get the maximum height players may build in. Exclusive.
*/
Expand Down
1 change: 1 addition & 0 deletions Core/src/main/resources/lang/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"setup.wall_height": "<gold>Wall height</gold>",
"setup.min_gen_height": "<gold>Minimum height from which to generate (for 1.18+ can be negative).</gold>",
"setup.bedrock_boolean": "<gold>Whether a bedrock layer under the plot should be generated or not</gold>",
"setup.component_below_bedrock_boolean": "<gold>Whether a component change e.g. /plot set walls should edit the bedrock layer or below</gold>",
"setup.singleplotarea_void_world": "<gold>Void world</gold>",
"plotareatype.plot_area_type_normal": "<gray>Standard plot generation</gray>",
"plotareatype.plot_area_type_augmented": "<gray>Plot generation with vanilla terrain</gray>",
Expand Down

0 comments on commit d85e3f4

Please sign in to comment.