Fix schematic pasting offsets

This commit is contained in:
Sauilitired 2019-01-21 09:53:04 +01:00
parent bd797b59fe
commit d37f5b9aa8
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678
4 changed files with 15 additions and 4 deletions

View File

@ -225,6 +225,11 @@ public class Settings extends Config {
@Comment("Display scientific numbers (4.2E8)") public static boolean SCIENTIFIC = false; @Comment("Display scientific numbers (4.2E8)") public static boolean SCIENTIFIC = false;
} }
@Comment("Schematic Settings") public static final class Schematics {
@Comment("Whether schematic based generation should paste schematic on top of plots, or from Y=1")
public static boolean PASTE_ON_TOP = true;
}
@Comment("Configure the paths that will be used") public static final class Paths { @Comment("Configure the paths that will be used") public static final class Paths {
public static String SCHEMATICS = "schematics"; public static String SCHEMATICS = "schematics";

View File

@ -1,6 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.generator; package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
@ -16,7 +17,12 @@ public class HybridGen extends IndependentPlotGenerator {
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX, private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
short relativeZ, int x, int z) { short relativeZ, int x, int z) {
int minY = Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT); int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
if (Settings.Schematics.PASTE_ON_TOP) {
minY = Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
} else {
minY = 1;
}
BaseBlock[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ)); BaseBlock[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ));
if (blocks != null) { if (blocks != null) {
for (int y = 0; y < blocks.length; y++) { for (int y = 0; y < blocks.length; y++) {

View File

@ -156,13 +156,13 @@ public class HybridPlotWorld extends ClassicPlotWorld {
if (w3 > PLOT_WIDTH || h3 > PLOT_WIDTH) { if (w3 > PLOT_WIDTH || h3 > PLOT_WIDTH) {
this.ROAD_SCHEMATIC_ENABLED = true; this.ROAD_SCHEMATIC_ENABLED = true;
} }
int centerShiftZ = 0; int centerShiftZ;
if (l3 < this.PLOT_WIDTH) { if (l3 < this.PLOT_WIDTH) {
centerShiftZ = (this.PLOT_WIDTH - l3) / 2; centerShiftZ = (this.PLOT_WIDTH - l3) / 2;
} else { } else {
centerShiftZ = (PLOT_WIDTH - l3) / 2; centerShiftZ = (PLOT_WIDTH - l3) / 2;
} }
int centerShiftX = 0; int centerShiftX;
if (w3 < this.PLOT_WIDTH) { if (w3 < this.PLOT_WIDTH) {
centerShiftX = (this.PLOT_WIDTH - w3) / 2; centerShiftX = (this.PLOT_WIDTH - w3) / 2;
} else { } else {

View File

@ -1443,7 +1443,7 @@ public class Plot {
e.printStackTrace(); e.printStackTrace();
return true; return true;
} }
SchematicHandler.manager.paste(sch, this, 0, 1, 0, false, new RunnableVal<Boolean>() { SchematicHandler.manager.paste(sch, this, 0, 1, 0, Settings.Schematics.PASTE_ON_TOP, new RunnableVal<Boolean>() {
@Override public void run(Boolean value) { @Override public void run(Boolean value) {
if (value) { if (value) {
MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS); MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);