SteamWar/BauSystem
Archiviert
13
0

RegionFix #222

Manuell gemergt
YoyoNow hat 9 Commits von RegionFix nach master 2021-04-03 11:55:02 +02:00 zusammengeführt
2 geänderte Dateien mit 21 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -23,26 +23,29 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.session.ClipboardHolder;
import org.bukkit.Bukkit;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Objects;
import org.bukkit.Bukkit;
class Region_15 {
private Region_15() {
}
static EditSession paste(File file, int x, int y, int z, boolean rotate) {
Clipboard clipboard;
try {
clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read();
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
clipboard = reader.read();
} catch (NullPointerException | IOException e) {
throw new SecurityException("Bausystem schematic not found", e);
}
@ -51,20 +54,18 @@ class Region_15 {
}
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate) {
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if (rotate) {
aT = aT.rotateY(180);
v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else {
v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset);
}
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
if (rotate) {
ch.setTransform(new AffineTransform().rotateY(180));
v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else {
v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset);
}
Operations.completeBlindly(ch.createPaste(e).to(v).build());
return e;
}

Datei anzeigen

@ -363,9 +363,9 @@ public class Region {
}
public boolean inRegionExtension(Region region, Location l) {
return inRange(l.getX(), region.minX + offsetX - extensionAxisX + 1, sizeX + extensionAxisX * 2 - 1) &&
inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY - 1) &&
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ + 1, sizeZ + extensionNegativeZ - 1 + extensionPositiveZ);
return inRange(l.getX(), region.minX + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) &&
inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY) &&
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
}
public EditSession reset(Region region, Schematic schem) throws IOException, NoClipboardException {
@ -401,7 +401,7 @@ public class Region {
}
private static boolean inRange(double l, int min, int size) {
return min <= l && l <= min + size;
return min <= l && l < min + size;
}
private static EditSession paste(File file, int x, int y, int z, boolean rotate) { //Type of protect