Allow restoration of road schematic height calculation behaviour from pre 6.1.4 (#3444)

This commit is contained in:
Jordan 2022-01-14 10:46:04 +01:00 committed by GitHub
parent d14d2caa2d
commit 9a85080bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 23 deletions

View File

@ -417,6 +417,12 @@ public class Settings extends Config {
" - This will still only paste a schematic with a plot's bounds.",
" - If a schematic is too big, it will cut off, and if too small, will not full the plot."})
public static boolean PASTE_MISMATCHES = true;
@Comment({"If the wall height should be taken into account when calculating the road schematic paste height",
" - If true, will use the lower of wall and road height.",
" - If true, will ensure correct schematic behaviour (no parts are cut off).",
" - Set to false if you experience the road being set one block too low",
" (only for road schematics created pre 6.1.4)."})
public static boolean USE_WALL_IN_ROAD_SCHEM_HEIGHT = true;
}

View File

@ -506,10 +506,7 @@ public class ClassicPlotManager extends SquarePlotManager {
Location.at(
classicPlotWorld.getWorldName(),
sx,
Math.min(
classicPlotWorld.PLOT_HEIGHT,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT)
) + 1,
classicPlotWorld.schematicStartHeight() + 1,
sz + 1
),
Location.at(classicPlotWorld.getWorldName(), ex, maxY, ez - 1), BlockTypes.AIR.getDefaultState()
@ -584,10 +581,7 @@ public class ClassicPlotManager extends SquarePlotManager {
Location.at(
classicPlotWorld.getWorldName(),
sx + 1,
Math.min(
classicPlotWorld.PLOT_HEIGHT,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT)
) + 1,
classicPlotWorld.schematicStartHeight() + 1,
sz
),
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
@ -682,10 +676,7 @@ public class ClassicPlotManager extends SquarePlotManager {
Location.at(
classicPlotWorld.getWorldName(),
sx,
Math.min(
classicPlotWorld.PLOT_HEIGHT,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT)
) + 1,
classicPlotWorld.schematicStartHeight() + 1,
sz
),
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
@ -725,10 +716,7 @@ public class ClassicPlotManager extends SquarePlotManager {
Location.at(
classicPlotWorld.getWorldName(),
sx,
Math.min(
classicPlotWorld.PLOT_HEIGHT,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT)
) + 1,
classicPlotWorld.schematicStartHeight() + 1,
sz
),
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
@ -767,10 +755,7 @@ public class ClassicPlotManager extends SquarePlotManager {
Location.at(
classicPlotWorld.getWorldName(),
sx,
Math.min(
classicPlotWorld.PLOT_HEIGHT,
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT)
) + 1,
classicPlotWorld.schematicStartHeight() + 1,
sz
),
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),

View File

@ -28,6 +28,7 @@ package com.plotsquared.core.generator;
import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.inject.annotations.WorldConfig;
@ -138,4 +139,12 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
this.PLACE_TOP_BLOCK = config.getBoolean("wall.place_top_block");
}
int schematicStartHeight() {
int plotRoadMin = Math.min(PLOT_HEIGHT, ROAD_HEIGHT);
if (!Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT) {
return plotRoadMin;
}
return Math.min(WALL_HEIGHT, plotRoadMin);
}
}

View File

@ -253,9 +253,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
int shift = this.ROAD_WIDTH / 2;
int oddshift = (this.ROAD_WIDTH & 1) == 0 ? 0 : 1;
SCHEM_Y = Math.min(PLOT_HEIGHT, Math.min(WALL_HEIGHT, ROAD_HEIGHT));
SCHEM_Y = schematicStartHeight();
int plotY = PLOT_HEIGHT - SCHEM_Y;
int roadY = Math.min(ROAD_HEIGHT, WALL_HEIGHT) - SCHEM_Y;
int minRoadWall = Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT ? Math.min(ROAD_HEIGHT, WALL_HEIGHT) : ROAD_HEIGHT;
int roadY = minRoadWall - SCHEM_Y;
if (schematic3 != null) {
if (schematic3.getClipboard().getDimensions().getY() == 256) {
@ -350,6 +351,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
short w1 = (short) d1.getX();
short l1 = (short) d1.getZ();
short h1 = (short) d1.getY();
// Workaround for schematic height issue if proper calculation of road schematic height is disabled
if (!Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT) {
h1 += Math.max(ROAD_HEIGHT - WALL_HEIGHT, 0);
}
BlockVector3 min = blockArrayClipboard1.getMinimumPoint();
for (short x = 0; x < w1; x++) {
@ -383,6 +388,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
short w2 = (short) d2.getX();
short l2 = (short) d2.getZ();
short h2 = (short) d2.getY();
// Workaround for schematic height issue if proper calculation of road schematic height is disabled
if (!Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT) {
h2 += Math.max(ROAD_HEIGHT - WALL_HEIGHT, 0);
}
min = blockArrayClipboard2.getMinimumPoint();
for (short x = 0; x < w2; x++) {
for (short z = 0; z < l2; z++) {

View File

@ -504,7 +504,10 @@ public class HybridUtils {
Location top = plot.getTopAbs();
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
PlotManager plotManager = plotworld.getPlotManager();
int schemY = Math.min(plotworld.PLOT_HEIGHT, Math.min(plotworld.WALL_HEIGHT, plotworld.ROAD_HEIGHT));
// Do not use plotworld#schematicStartHeight() here as we want to restore the pre 6.1.4 way of doing it if
// USE_WALL_IN_ROAD_SCHEM_HEIGHT is false
int schemY = Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT ?
Math.min(plotworld.PLOT_HEIGHT, Math.min(plotworld.WALL_HEIGHT, plotworld.ROAD_HEIGHT)) : plotworld.ROAD_HEIGHT;
int sx = bot.getX() - plotworld.ROAD_WIDTH + 1;
int sz = bot.getZ() + 1;
int sy = Settings.Schematics.PASTE_ROAD_ON_TOP ? schemY : plot.getArea().getMinBuildHeight();