From 8bf95a273b93c08cc333d068fd9d178d83987c70 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 18 Sep 2021 14:23:52 +0200 Subject: [PATCH] Fix Region Testblock paste Signed-off-by: yoyosource --- .../src/de/steamwar/bausystem/region/Region.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index c88516de..d3248977 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; @@ -392,6 +393,7 @@ public class Region { Point pastePoint; File tempFile = null; + Clipboard clipboard = null; switch (regionType) { case BUILD: pastePoint = minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2); @@ -400,9 +402,17 @@ public class Region { } break; case TESTBLOCK: - pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2); + pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, 0); if (schematic == null) { tempFile = prototype.getTestblock().getSchematicFile(); + pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2); + } else { + clipboard = schematic.load(); + if (clipboard.getDimensions().getZ() != prototype.getTestblock().getSizeZ()) { + pastePoint = pastePoint.add(0, 0, clipboard.getDimensions().getZ() / 2 - (clipboard.getOrigin().getZ() - clipboard.getMinimumPoint().getZ()) - 1); + } else { + pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2); + } } break; default: @@ -416,7 +426,7 @@ public class Region { EditSession editSession = null; if (schematic != null) { - editSession = paste(schematic.load(), pastePoint, pasteOptions); + editSession = paste(clipboard != null ? clipboard : schematic.load(), pastePoint, pasteOptions); } else { editSession = paste(tempFile, pastePoint, pasteOptions); }