Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-07 12:00:07 +01:00
Regen using EditSession
Dieser Commit ist enthalten in:
Ursprung
6142f30715
Commit
92b34e4fa9
@ -183,47 +183,48 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
|
||||
|
||||
for (BlockVector2 chunk : region.getChunks()) {
|
||||
BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
|
||||
// First save all the blocks inside
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
BlockVector3 pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
history[index] = editSession.getFullBlock(pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Chunk generation via Bukkit raised an error", t);
|
||||
}
|
||||
|
||||
// Then restore
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
BlockVector3 pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
|
||||
// We have to restore the block if it was outside
|
||||
if (!region.contains(pt)) {
|
||||
editSession.smartSetBlock(pt, history[index]);
|
||||
} else { // Otherwise fool with history
|
||||
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return editSession.regenerate(region);
|
||||
// BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
|
||||
//
|
||||
// for (BlockVector2 chunk : region.getChunks()) {
|
||||
// BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
//
|
||||
// // First save all the blocks inside
|
||||
// for (int x = 0; x < 16; ++x) {
|
||||
// for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
// for (int z = 0; z < 16; ++z) {
|
||||
// BlockVector3 pt = min.add(x, y, z);
|
||||
// int index = y * 16 * 16 + z * 16 + x;
|
||||
// history[index] = editSession.getFullBlock(pt);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
|
||||
// } catch (Throwable t) {
|
||||
// logger.warn("Chunk generation via Bukkit raised an error", t);
|
||||
// }
|
||||
//
|
||||
// // Then restore
|
||||
// for (int x = 0; x < 16; ++x) {
|
||||
// for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
// for (int z = 0; z < 16; ++z) {
|
||||
// BlockVector3 pt = min.add(x, y, z);
|
||||
// int index = y * 16 * 16 + z * 16 + x;
|
||||
//
|
||||
// // We have to restore the block if it was outside
|
||||
// if (!region.contains(pt)) {
|
||||
// editSession.smartSetBlock(pt, history[index]);
|
||||
// } else { // Otherwise fool with history
|
||||
// editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren