mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
A couple of reworks
- Redo how regeneration works a little to also take a cuboid region for regeneration off-chunk plots - Fix a couple of cases where we were writing to the queue instead of the world in the ChunkConsumer (dum) - this seems to be working.
This commit is contained in:
@ -97,11 +97,18 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
||||
@Override public boolean enqueue() {
|
||||
final Clipboard regenClipboard;
|
||||
if (isRegen()) {
|
||||
Region region = new CuboidRegion(
|
||||
BlockVector3.at(getRegenStart()[0] << 4, 0, getRegenStart()[1] << 4),
|
||||
BlockVector3.at((getRegenEnd()[0] << 4) + 15, 255, (getRegenEnd()[1] << 4) + 15));
|
||||
BlockVector3 start =
|
||||
BlockVector3.at(getRegenStart()[0] << 4, 0, getRegenStart()[1] << 4);
|
||||
BlockVector3 end =
|
||||
BlockVector3.at((getRegenEnd()[0] << 4) + 15, 255, (getRegenEnd()[1] << 4) + 15);
|
||||
Region region = new CuboidRegion(start, end);
|
||||
regenClipboard = new BlockArrayClipboard(region);
|
||||
regenClipboard.setOrigin(start);
|
||||
getWorld().regenerate(region, regenClipboard);
|
||||
} else if (getRegenRegion() != null) {
|
||||
regenClipboard = new BlockArrayClipboard(getRegenRegion());
|
||||
regenClipboard.setOrigin(getRegenRegion().getMinimumPoint());
|
||||
getWorld().regenerate(getRegenRegion(), regenClipboard);
|
||||
} else {
|
||||
regenClipboard = null;
|
||||
}
|
||||
@ -121,15 +128,17 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
BaseBlock block =
|
||||
regenClipboard.getFullBlock(BlockVector3.at(x, y, z));
|
||||
setWorldBlock(x, y, z, block, blockVector2);
|
||||
if (block != null) {
|
||||
setWorldBlock(x, y, z, block, blockVector2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Allow regen and then blocks to be placed (plot schematic etc)
|
||||
if (localChunk == null) {
|
||||
return;
|
||||
} else if (localChunk == null) {
|
||||
throw new NullPointerException(
|
||||
"LocalChunk cannot be null when accessed from ChunkCoordinator");
|
||||
}
|
||||
int sx = blockVector2.getX() << 4;
|
||||
int sz = blockVector2.getZ() << 4;
|
||||
@ -143,10 +152,13 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
||||
continue;
|
||||
}
|
||||
BaseBlock block = blocksLayer[j];
|
||||
int x = sx + ChunkUtil.getX(j);
|
||||
int y = ChunkUtil.getY(layer, j);
|
||||
int z = sz + ChunkUtil.getZ(j);
|
||||
setWorldBlock(x, y, z, block, blockVector2);
|
||||
|
||||
if (block != null) {
|
||||
int x = sx + ChunkUtil.getX(j);
|
||||
int y = ChunkUtil.getY(layer, j);
|
||||
int z = sz + ChunkUtil.getZ(j);
|
||||
setWorldBlock(x, y, z, block, blockVector2);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int layer = 0; layer < localChunk.getBaseblocks().length; layer++) {
|
||||
@ -159,10 +171,12 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
||||
continue;
|
||||
}
|
||||
BiomeType biome = biomesLayer[j];
|
||||
int x = sx + ChunkUtil.getX(j);
|
||||
int y = ChunkUtil.getY(layer, j);
|
||||
int z = sz + ChunkUtil.getZ(j);
|
||||
getWorld().setBiome(BlockVector3.at(x, y, z), biome);
|
||||
if (biome != null) {
|
||||
int x = sx + ChunkUtil.getX(j);
|
||||
int y = ChunkUtil.getY(layer, j);
|
||||
int z = sz + ChunkUtil.getZ(j);
|
||||
getWorld().setBiome(BlockVector3.at(x, y, z), biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localChunk.getTiles().size() > 0) {
|
||||
@ -184,7 +198,6 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
||||
}
|
||||
};
|
||||
}
|
||||
CuboidRegion region;
|
||||
Collection<BlockVector2> read = new ArrayList<>();
|
||||
if (getReadChunks().size() > 0) {
|
||||
read.addAll(getReadChunks());
|
||||
|
@ -76,7 +76,8 @@ public class BukkitRegionManager extends RegionManager {
|
||||
LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName());
|
||||
private final GlobalBlockQueue blockQueue;
|
||||
|
||||
@Inject public BukkitRegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue) {
|
||||
@Inject
|
||||
public BukkitRegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue) {
|
||||
super(worldUtil, blockQueue);
|
||||
this.blockQueue = blockQueue;
|
||||
}
|
||||
@ -174,7 +175,9 @@ public class BukkitRegionManager extends RegionManager {
|
||||
final int tcz = p2z >> 4;
|
||||
|
||||
final QueueCoordinator queue = blockQueue.getNewQueue(world);
|
||||
queue.addReadChunks(new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()).getChunks());
|
||||
final QueueCoordinator regenQueue = blockQueue.getNewQueue(world);
|
||||
queue.addReadChunks(
|
||||
new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()).getChunks());
|
||||
queue.setChunkConsumer(chunk -> {
|
||||
|
||||
int x = chunk.getX();
|
||||
@ -185,7 +188,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
int zzt = zzb + 15;
|
||||
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
||||
AugmentedUtils
|
||||
.bypass(ignoreAugment, () -> queue.regenChunk(chunk.getX(), chunk.getZ()));
|
||||
.bypass(ignoreAugment, () -> regenQueue.regenChunk(chunk.getX(), chunk.getZ()));
|
||||
return;
|
||||
}
|
||||
boolean checkX1 = false;
|
||||
@ -285,7 +288,8 @@ public class BukkitRegionManager extends RegionManager {
|
||||
//map.restoreBlocks(worldObj, 0, 0);
|
||||
map.restoreEntities(Bukkit.getWorld(world.getName()), 0, 0);
|
||||
});
|
||||
queue.setCompleteTask(whenDone);
|
||||
regenQueue.setCompleteTask(whenDone);
|
||||
queue.setCompleteTask(regenQueue::enqueue);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user