SteamWar/BauSystem
Archiviert
13
0

Add Regional Reset History #211

Manuell gemergt
YoyoNow hat 9 Commits von reset_history nach master 2021-04-02 20:45:17 +02:00 zusammengeführt
Nur Änderungen aus Commit 4f9afd0db0 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -77,42 +77,4 @@ class Region_15 {
return e;
}
}
static void fastpaste(File file, int x, int y, int z, boolean rotate) {
Clipboard clipboard;
try {
clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read();
} catch (NullPointerException | IOException e) {
throw new SecurityException("Bausystem schematic not found", e);
}
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
if (rotate) {
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);
}
WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
v = v.add(offset);
for (int X = v.getBlockX(); X < v.getBlockX() + dimensions.getBlockX(); X++) {
for (int Y = v.getBlockY(); Y < v.getBlockY() + dimensions.getBlockY(); Y++) {
for (int Z = v.getBlockZ(); Z < v.getBlockZ() + dimensions.getBlockZ(); Z++) {
BlockPosition blockPos = new BlockPosition(X, Y, Z);
BaseBlock fullBlock = clipboard.getFullBlock(BlockVector3.at(X, Y, Z).subtract(v).add(clipboard.getRegion().getMinimumPoint()));
BlockData replaceTo = BukkitAdapter.adapt(fullBlock);
world.removeTileEntity(blockPos);
if (replaceTo == null)
world.setTypeAndData(blockPos, ((CraftBlockData) Material.AIR.createBlockData()).getState(), 1042);
else
world.setTypeAndData(new BlockPosition(X, Y, Z), ((CraftBlockData) replaceTo).getState(), 1042);
world.getChunkProvider().flagDirty(blockPos);
}
}
}
}
}