From 835d72063e04461f1e8afb41a8ff17e70c62e2d6 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Mon, 8 Jun 2015 19:14:01 -0700 Subject: [PATCH] Fix clearing and deleting not restoring plot schematic --- .../plot/generator/HybridGen.java | 32 ++++++++----------- .../plot/generator/HybridPop.java | 31 ++++++++---------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index f0881b794..63453db53 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -170,17 +170,17 @@ public class HybridGen extends PlotGenerator { } } } + + int sx = (short) ((this.X) % this.size); + int sz = (short) ((this.Z) % this.size); + if (sx < 0) { + sx += this.size; + } + if (sz < 0) { + sz += this.size; + } + if (region != null) { - final int X = cx << 4; - final int Z = cz << 4; - int sx = ((X) % this.size); - int sz = ((Z) % this.size); - if (sx < 0) { - sx += this.size; - } - if (sz < 0) { - sz += this.size; - } for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (biomes != null) { @@ -191,7 +191,9 @@ public class HybridGen extends PlotGenerator { setBlock(x, y, z, this.filling); } setBlock(x, this.plotheight, z, this.plotfloors); - final PlotLoc loc = new PlotLoc((X + x), (Z + z)); + final int absX = ((sx + x) % this.size); + final int absZ = ((sz + z) % this.size); + final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = plotworld.G_SCH.get(loc); if (blocks != null) { for (final Entry entry : blocks.entrySet()) { @@ -203,14 +205,6 @@ public class HybridGen extends PlotGenerator { } return; } - int sx = (short) ((this.X) % this.size); - int sz = (short) ((this.Z) % this.size); - if (sx < 0) { - sx += this.size; - } - if (sz < 0) { - sz += this.size; - } for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 29aece37d..94389e78b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -112,16 +112,17 @@ public class HybridPop extends PlotPopulator { @Override public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) { PlotSquared.getPlotManager(world.getName()); + + int sx = (short) ((this.X) % this.size); + int sz = (short) ((this.Z) % this.size); + if (sx < 0) { + sx += this.size; + } + if (sz < 0) { + sz += this.size; + } + if (requiredRegion != null) { - short sx = (short) ((this.X) % this.size); - short sz = (short) ((this.Z) % this.size); - if (sx < 0) { - sx += this.size; - } - if (sz < 0) { - sz += this.size; - } - for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (contains(requiredRegion, x, z)) { @@ -134,7 +135,9 @@ public class HybridPop extends PlotPopulator { setBlock(x, (short) this.plotheight, z, this.plotfloors); } if (this.plotworld.PLOT_SCHEMATIC) { - final PlotLoc loc = new PlotLoc((short) (this.X + x), (short) (this.Z + z)); + final int absX = ((sx + x) % this.size); + final int absZ = ((sz + z) % this.size); + final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { for (final short y : blocks.keySet()) { @@ -155,14 +158,6 @@ public class HybridPop extends PlotPopulator { } return; } - int sx = (short) ((this.X) % this.size); - int sz = (short) ((this.Z) % this.size); - if (sx < 0) { - sx += this.size; - } - if (sz < 0) { - sz += this.size; - } for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) {