From 69a029a555d043753233e3374b33ab3dabb1bd51 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 6 Apr 2019 01:54:02 +1100 Subject: [PATCH 1/3] Fix plot schematic y --- .../bukkit/util/BukkitHybridUtils.java | 2 +- .../plotsquared/plot/generator/HybridGen.java | 2 +- .../plot/generator/HybridPlotManager.java | 7 ++++- .../plot/generator/HybridPlotWorld.java | 31 ++++++++++++++----- .../plot/generator/HybridUtils.java | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitHybridUtils.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitHybridUtils.java index 068bbd89b..dace8ab26 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitHybridUtils.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitHybridUtils.java @@ -112,7 +112,7 @@ public class BukkitHybridUtils extends HybridUtils { } int minY; if (Settings.Schematics.PASTE_ON_TOP) { - minY = Math.min(hpw.PLOT_HEIGHT, hpw.ROAD_HEIGHT); + minY = hpw.SCHEM_Y; } else { minY = 1; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java index 8c6f2c765..66a32db4c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java @@ -17,7 +17,7 @@ public class HybridGen extends IndependentPlotGenerator { short relativeZ, int x, int z, boolean isRoad) { int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT); if (isRoad || Settings.Schematics.PASTE_ON_TOP) { - minY = Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT); + minY = world.SCHEM_Y; } else { minY = 1; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java index 52dc99f82..631b4ad45 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java @@ -78,7 +78,12 @@ public class HybridPlotManager extends ClassicPlotManager { private void createSchemAbs(HybridPlotWorld hpw, LocalBlockQueue queue, Location pos1, Location pos2, boolean clear) { int size = hpw.SIZE; - int minY = Math.min(hpw.PLOT_HEIGHT, hpw.ROAD_HEIGHT); + int minY; + if (Settings.Schematics.PASTE_ON_TOP) { + minY = hpw.SCHEM_Y; + } else { + minY = 1; + } for (int x = pos1.getX(); x <= pos2.getX(); x++) { short absX = (short) ((x - hpw.ROAD_OFFSET_X) % size); if (absX < 0) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java index 8ee998111..621fff1bc 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java @@ -30,10 +30,12 @@ public class HybridPlotWorld extends ClassicPlotWorld { private static AffineTransform transform = new AffineTransform().rotateY(90); public boolean ROAD_SCHEMATIC_ENABLED; public boolean PLOT_SCHEMATIC = false; + public int PLOT_SCHEMATIC_HEIGHT = -1; public short PATH_WIDTH_LOWER; public short PATH_WIDTH_UPPER; public HashMap G_SCH; private Location SIGN_LOCATION; + public int SCHEM_Y; public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) { @@ -143,7 +145,23 @@ public class HybridPlotWorld extends ClassicPlotWorld { Schematic schematic3 = SchematicHandler.manager.getSchematic(schematic3File); int shift = this.ROAD_WIDTH / 2; int oddshift = (this.ROAD_WIDTH & 1) == 0 ? 0 : 1; - int minY = Math.min(PLOT_HEIGHT, ROAD_HEIGHT); + + SCHEM_Y = Math.min(PLOT_HEIGHT, ROAD_HEIGHT); + int plotY = PLOT_HEIGHT - SCHEM_Y; + int roadY = ROAD_HEIGHT - SCHEM_Y; + + if (schematic3.getClipboard().getDimensions().getY() == 256) { + SCHEM_Y = 0; + plotY = 0; + roadY = ROAD_HEIGHT; + } + + if (schematic1.getClipboard().getDimensions().getY() == 256) { + SCHEM_Y = 0; + plotY = Math.min(plotY, PLOT_HEIGHT); + roadY = 0; + } + if (schematic3 != null) { this.PLOT_SCHEMATIC = true; BlockArrayClipboard blockArrayClipboard3 = schematic3.getClipboard(); @@ -168,8 +186,6 @@ public class HybridPlotWorld extends ClassicPlotWorld { centerShiftX = (PLOT_WIDTH - w3) / 2; } - int startY = minY - PLOT_HEIGHT; - BlockVector3 min = blockArrayClipboard3.getMinimumPoint(); for (short x = 0; x < w3; x++) { for (short z = 0; z < l3; z++) { @@ -177,7 +193,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ())); if (!id.getBlockType().getMaterial().isAir()) { addOverlayBlock((short) (x + shift + oddshift + centerShiftX), - (short) (y + startY), (short) (z + shift + oddshift + centerShiftZ), + (short) (y + plotY), (short) (z + shift + oddshift + centerShiftZ), id, false, h3); } } @@ -234,16 +250,15 @@ public class HybridPlotWorld extends ClassicPlotWorld { short w2 = (short) d2.getX(); short l2 = (short) d2.getZ(); short h2 = (short) d2.getY(); - int startY = minY - ROAD_HEIGHT; BlockVector3 min = blockArrayClipboard2.getMinimumPoint(); for (short x = 0; x < w2; x++) { for (short z = 0; z < l2; z++) { for (short y = 0; y < h2; y++) { BaseBlock id = blockArrayClipboard2.getFullBlock(BlockVector3.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ())); if (!id.getBlockType().getMaterial().isAir()) { - addOverlayBlock((short) (x - shift), (short) (y + startY), + addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z + shift + oddshift), id, false, h1); - addOverlayBlock((short) (z + shift + oddshift), (short) (y + startY), + addOverlayBlock((short) (z + shift + oddshift), (short) (y + roadY), (short) (shift - x + (oddshift - 1)), id, true, h1); } } @@ -255,7 +270,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { for (short y = 0; y < h2; y++) { BaseBlock id = blockArrayClipboard1.getFullBlock(BlockVector3.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ())); if (!id.getBlockType().getMaterial().isAir()) { - addOverlayBlock((short) (x - shift), (short) (y + startY), + addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z - shift), id, false, h2); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java index 7214f409c..207ef87d5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java @@ -343,7 +343,7 @@ public abstract class HybridUtils { } if (condition) { BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); - int minY = Math.min(plotWorld.PLOT_HEIGHT, plotWorld.ROAD_HEIGHT); + int minY = plotWorld.SCHEM_Y; int maxY = Math.max(extend, blocks.length); if (blocks != null) { for (int y = 0; y < maxY; y++) { From c71fe00741df87a13e95d35c9f3eb6eb2c41806f Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 6 Apr 2019 02:07:14 +1100 Subject: [PATCH 2/3] Missed this as well --- .../plotsquared/plot/generator/HybridUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java index 207ef87d5..2db5ec0b1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.generator; import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.Captions; +import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.listener.WEExtent; @@ -344,6 +345,7 @@ public abstract class HybridUtils { if (condition) { BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); int minY = plotWorld.SCHEM_Y; + if (Settings.Schematics.PASTE_ON_TOP) minY = 1; int maxY = Math.max(extend, blocks.length); if (blocks != null) { for (int y = 0; y < maxY; y++) { From 3e3951a3e759b420f229bc323a3d3788f9265248 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 6 Apr 2019 02:07:39 +1100 Subject: [PATCH 3/3] *negate --- .../plotsquared/plot/generator/HybridUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java index 2db5ec0b1..a3d9bc186 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java @@ -345,7 +345,7 @@ public abstract class HybridUtils { if (condition) { BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); int minY = plotWorld.SCHEM_Y; - if (Settings.Schematics.PASTE_ON_TOP) minY = 1; + if (!Settings.Schematics.PASTE_ON_TOP) minY = 1; int maxY = Math.max(extend, blocks.length); if (blocks != null) { for (int y = 0; y < maxY; y++) {