From a3df37100a1f3ba3f1448d2c3bc41e2b05ff6270 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 01:45:43 +1100 Subject: [PATCH] Schematic centering --- .../com/intellectualcrafters/plot/PlotMain.java | 5 +++++ .../plot/generator/HybridPlotWorld.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index f06269307..4d99365cd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -928,7 +928,9 @@ public class PlotMain extends JavaPlugin implements Listener { } public static void loadWorld(final String world, final ChunkGenerator generator) { + System.out.print(2); if (getWorldSettings(world) != null) { + System.out.print(3); return; } @@ -940,6 +942,7 @@ public class PlotMain extends JavaPlugin implements Listener { final String path = "worlds." + world; if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) { + System.out.print(4); plotGenerator = (PlotGenerator) generator; plotWorld = plotGenerator.getNewPlotWorld(world); plotManager = plotGenerator.getPlotManager(); @@ -963,7 +966,9 @@ public class PlotMain extends JavaPlugin implements Listener { addPlotWorld(world, plotWorld, plotManager); PlotHelper.setupBorder(world); } else { + System.out.print(5 + " | " + (generator instanceof PlotGenerator)); if (!worlds.contains(world)) { + System.out.print(6); return; } if (!LOADING_WORLD) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index 14b18d9e2..c6703b042 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -92,6 +92,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { PlotMain.sendConsoleSenderMessage("&c - road schematics are disabled for this world."); this.ROAD_SCHEMATIC_ENABLED = false; } + System.out.print("LOADED!"); } public void setupSchematics() { @@ -118,6 +119,17 @@ public class HybridPlotWorld extends ClassicPlotWorld { short w3 = (short) d3.getX(); short l3 = (short) d3.getZ(); short h3 = (short) d3.getY(); + + int center_shift_x = 0; + int center_shift_z = 0; + if (l3 < PLOT_WIDTH) { + center_shift_z = (int) ((PLOT_WIDTH - l3)/2); + } + if (w3 < PLOT_WIDTH) { + center_shift_x = (int) ((PLOT_WIDTH - w3)/2); + } + + for (short x = 0; x < w3; x++) { for (short z = 0; z < l3; z++) { for (short y = 0; y < h3; y++) { @@ -125,7 +137,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { short id = blocks3[index].getBlock(); byte data = blocks3[index].getData(); if (id != 0) { - addOverlayBlock((short) (x + shift + oddshift), (short) (y), (short) (z + shift + oddshift), id, data, false); + addOverlayBlock((short) (x + shift + oddshift + center_shift_x), (short) (y), (short) (z + shift + oddshift + center_shift_z), id, data, false); } } }