Schematic centering

This commit is contained in:
boy0001 2015-02-19 01:45:43 +11:00
parent 02de9c20a2
commit a3df37100a
2 changed files with 18 additions and 1 deletions

View File

@ -928,7 +928,9 @@ public class PlotMain extends JavaPlugin implements Listener {
} }
public static void loadWorld(final String world, final ChunkGenerator generator) { public static void loadWorld(final String world, final ChunkGenerator generator) {
System.out.print(2);
if (getWorldSettings(world) != null) { if (getWorldSettings(world) != null) {
System.out.print(3);
return; return;
} }
@ -940,6 +942,7 @@ public class PlotMain extends JavaPlugin implements Listener {
final String path = "worlds." + world; final String path = "worlds." + world;
if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) { if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) {
System.out.print(4);
plotGenerator = (PlotGenerator) generator; plotGenerator = (PlotGenerator) generator;
plotWorld = plotGenerator.getNewPlotWorld(world); plotWorld = plotGenerator.getNewPlotWorld(world);
plotManager = plotGenerator.getPlotManager(); plotManager = plotGenerator.getPlotManager();
@ -963,7 +966,9 @@ public class PlotMain extends JavaPlugin implements Listener {
addPlotWorld(world, plotWorld, plotManager); addPlotWorld(world, plotWorld, plotManager);
PlotHelper.setupBorder(world); PlotHelper.setupBorder(world);
} else { } else {
System.out.print(5 + " | " + (generator instanceof PlotGenerator));
if (!worlds.contains(world)) { if (!worlds.contains(world)) {
System.out.print(6);
return; return;
} }
if (!LOADING_WORLD) { if (!LOADING_WORLD) {

View File

@ -92,6 +92,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
PlotMain.sendConsoleSenderMessage("&c - road schematics are disabled for this world."); PlotMain.sendConsoleSenderMessage("&c - road schematics are disabled for this world.");
this.ROAD_SCHEMATIC_ENABLED = false; this.ROAD_SCHEMATIC_ENABLED = false;
} }
System.out.print("LOADED!");
} }
public void setupSchematics() { public void setupSchematics() {
@ -118,6 +119,17 @@ public class HybridPlotWorld extends ClassicPlotWorld {
short w3 = (short) d3.getX(); short w3 = (short) d3.getX();
short l3 = (short) d3.getZ(); short l3 = (short) d3.getZ();
short h3 = (short) d3.getY(); 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 x = 0; x < w3; x++) {
for (short z = 0; z < l3; z++) { for (short z = 0; z < l3; z++) {
for (short y = 0; y < h3; y++) { for (short y = 0; y < h3; y++) {
@ -125,7 +137,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
short id = blocks3[index].getBlock(); short id = blocks3[index].getBlock();
byte data = blocks3[index].getData(); byte data = blocks3[index].getData();
if (id != 0) { 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);
} }
} }
} }