Fix a couple more Guice issues. Refactor read chunks to be a list of chunks rather than CuboidRegion

This commit is contained in:
dordsor21 2020-07-24 14:36:50 +01:00
parent 416e181992
commit 18918eb3a3
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
13 changed files with 87 additions and 56 deletions

View File

@ -186,8 +186,8 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
} }
CuboidRegion region; CuboidRegion region;
Collection<BlockVector2> read = new ArrayList<>(); Collection<BlockVector2> read = new ArrayList<>();
if ((region = getReadRegion()) != null) { if (getReadChunks().size() > 0) {
read = region.getChunks(); read.addAll(getReadChunks());
} }
chunkCoordinator = chunkCoordinator =
chunkCoordinatorBuilderFactory.create(chunkCoordinatorFactory).inWorld(getWorld()) chunkCoordinatorBuilderFactory.create(chunkCoordinatorFactory).inWorld(getWorld())

View File

@ -39,6 +39,7 @@ import com.plotsquared.core.queue.ScopedQueueCoordinator;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.RegionManager; import com.plotsquared.core.util.RegionManager;
import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.RegionUtil;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.entity.EntityCategories; import com.plotsquared.core.util.entity.EntityCategories;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -55,6 +56,7 @@ import org.bukkit.entity.Player;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -72,7 +74,12 @@ public class BukkitRegionManager extends RegionManager {
private static final Logger logger = private static final Logger logger =
LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName()); LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName());
@Inject private GlobalBlockQueue blockQueue; private final GlobalBlockQueue blockQueue;
@Inject public BukkitRegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue) {
super(worldUtil, blockQueue);
this.blockQueue = blockQueue;
}
@Override public boolean handleClear(Plot plot, Runnable whenDone, PlotManager manager) { @Override public boolean handleClear(Plot plot, Runnable whenDone, PlotManager manager) {
return false; return false;
@ -167,7 +174,7 @@ public class BukkitRegionManager extends RegionManager {
final int tcz = p2z >> 4; final int tcz = p2z >> 4;
final QueueCoordinator queue = blockQueue.getNewQueue(world); final QueueCoordinator queue = blockQueue.getNewQueue(world);
queue.setReadRegion(new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3())); queue.addReadChunks(new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()).getChunks());
queue.setChunkConsumer(chunk -> { queue.setChunkConsumer(chunk -> {
int x = chunk.getX(); int x = chunk.getX();

View File

@ -287,16 +287,17 @@ public class Area extends SubCommand {
case 2: case 2:
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "pos1": { // Set position 1 case "pos1": { // Set position 1
HybridPlotWorld area = (HybridPlotWorld) metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()) HybridPlotWorld area = (HybridPlotWorld) metaData
.get("area_create_area"); .computeIfAbsent(player.getUUID(),
missingUUID -> new HashMap<>()).get("area_create_area");
if (area == null) { if (area == null) {
Captions.COMMAND_SYNTAX.send(player, Captions.COMMAND_SYNTAX.send(player,
"/plot area create [world[:id]] [<modifier>=<value>]..."); "/plot area create [world[:id]] [<modifier>=<value>]...");
return false; return false;
} }
Location location = player.getLocation(); Location location = player.getLocation();
metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()) metaData.computeIfAbsent(player.getUUID(),
.put("area_pos1", location); missingUUID -> new HashMap<>()).put("area_pos1", location);
Captions.SET_ATTRIBUTE.send(player, "area_pos1", Captions.SET_ATTRIBUTE.send(player, "area_pos1",
location.getX() + "," + location.getZ()); location.getX() + "," + location.getZ());
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
@ -306,14 +307,17 @@ public class Area extends SubCommand {
} }
case "pos2": // Set position 2 and finish creation for type=2 (partial) case "pos2": // Set position 2 and finish creation for type=2 (partial)
final HybridPlotWorld area = (HybridPlotWorld) metaData final HybridPlotWorld area = (HybridPlotWorld) metaData
.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).get("area_create_area"); .computeIfAbsent(player.getUUID(),
missingUUID -> new HashMap<>()).get("area_create_area");
if (area == null) { if (area == null) {
Captions.COMMAND_SYNTAX.send(player, Captions.COMMAND_SYNTAX.send(player,
"/plot area create [world[:id]] [<modifier>=<value>]..."); "/plot area create [world[:id]] [<modifier>=<value>]...");
return false; return false;
} }
Location pos1 = player.getLocation(); Location pos1 = player.getLocation();
Location pos2 = (Location) metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).get("area_pos1"); Location pos2 = (Location) metaData
.computeIfAbsent(player.getUUID(),
missingUUID -> new HashMap<>()).get("area_pos1");
int dx = Math.abs(pos1.getX() - pos2.getX()); int dx = Math.abs(pos1.getX() - pos2.getX());
int dz = Math.abs(pos1.getZ() - pos2.getZ()); int dz = Math.abs(pos1.getZ() - pos2.getZ());
int numX = Math.max(1, int numX = Math.max(1,
@ -367,7 +371,7 @@ public class Area extends SubCommand {
queue.setChunkConsumer(chunk -> AugmentedUtils queue.setChunkConsumer(chunk -> AugmentedUtils
.generate(null, world, chunk.getX(), chunk.getZ(), .generate(null, world, chunk.getX(), chunk.getZ(),
queue)); queue));
queue.setReadRegion(region); queue.addReadChunks(region.getChunks());
queue.enqueue(); queue.enqueue();
} }
} else { } else {
@ -529,7 +533,8 @@ public class Area extends SubCommand {
player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), player.teleport(this.worldUtil.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND); TeleportCause.COMMAND);
} }
metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa); metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>())
.put("area_create_area", pa);
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"$1Go to the first corner and use: $2 " + getCommandString() "$1Go to the first corner and use: $2 " + getCommandString()
+ " create pos1"); + " create pos1");
@ -677,7 +682,7 @@ public class Area extends SubCommand {
blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName())); blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName()));
queue.setChunkConsumer(chunk -> AugmentedUtils queue.setChunkConsumer(chunk -> AugmentedUtils
.generate(null, area.getWorldName(), chunk.getX(), chunk.getZ(), queue)); .generate(null, area.getWorldName(), chunk.getX(), chunk.getZ(), queue));
queue.setReadRegion(area.getRegion()); queue.addReadChunks(area.getRegion().getChunks());
queue.setCompleteTask(() -> player.sendMessage("Regen complete")); queue.setCompleteTask(() -> player.sendMessage("Regen complete"));
queue.enqueue(); queue.enqueue();
return true; return true;

View File

@ -248,8 +248,8 @@ public class HybridPlotManager extends ClassicPlotManager {
final BiomeType biome = hybridPlotWorld.getPlotBiome(); final BiomeType biome = hybridPlotWorld.getPlotBiome();
final QueueCoordinator queue = hybridPlotWorld.getQueue(); final QueueCoordinator queue = hybridPlotWorld.getQueue();
queue.setReadRegion(new CuboidRegion(plot.getExtendedBottomAbs().getBlockVector3(), queue.addReadChunks(new CuboidRegion(plot.getExtendedBottomAbs().getBlockVector3(),
plot.getExtendedTopAbs().getBlockVector3())); plot.getExtendedTopAbs().getBlockVector3()).getChunks());
queue.setChunkConsumer(blockVector2 -> { queue.setChunkConsumer(blockVector2 -> {
// If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk // If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk
if (canRegen && ChunkUtil.isWholeChunk(pos1, pos2, blockVector2)) { if (canRegen && ChunkUtil.isWholeChunk(pos1, pos2, blockVector2)) {

View File

@ -82,8 +82,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
private Location SIGN_LOCATION; private Location SIGN_LOCATION;
@Getter private File root = null; @Getter private File root = null;
private final RegionManager regionManager; @Inject private SchematicHandler schematicHandler;
private final SchematicHandler schematicHandler;
@Inject public HybridPlotWorld(@Assisted("world") final String worldName, @Inject public HybridPlotWorld(@Assisted("world") final String worldName,
@Nullable @Assisted("id") final String id, @Nullable @Assisted("id") final String id,
@ -91,13 +90,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
@Nullable @Assisted("min") final PlotId min, @Nullable @Assisted("min") final PlotId min,
@Nullable @Assisted("max") final PlotId max, @Nullable @Assisted("max") final PlotId max,
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
@Nonnull final RegionManager regionManager,
@Nonnull final SchematicHandler schematicHandler,
@Nonnull final GlobalBlockQueue blockQueue, @Nonnull final GlobalBlockQueue blockQueue,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler); super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
this.regionManager = regionManager; PlotSquared.platform().getInjector().injectMembers(this);
this.schematicHandler = schematicHandler;
} }
public static byte wrap(byte data, int start) { public static byte wrap(byte data, int start) {
@ -148,7 +144,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
@Nonnull @Override protected PlotManager createManager() { @Nonnull @Override protected PlotManager createManager() {
return new HybridPlotManager(this, this.regionManager); return new HybridPlotManager(this, PlotSquared.platform().getRegionManager());
} }
public Location getSignLocation(@Nonnull Plot plot) { public Location getSignLocation(@Nonnull Plot plot) {

View File

@ -161,7 +161,7 @@ public class HybridUtils {
System.gc(); System.gc();
QueueCoordinator queue = area.getQueue(); QueueCoordinator queue = area.getQueue();
queue.setReadRegion(region); queue.addReadChunks(region.getChunks());
queue.setChunkConsumer(blockVector2 -> { queue.setChunkConsumer(blockVector2 -> {
int X = blockVector2.getX(); int X = blockVector2.getX();
int Z = blockVector2.getZ(); int Z = blockVector2.getZ();

View File

@ -30,7 +30,6 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
@ -39,6 +38,9 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.entity.EntityTypes;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -47,6 +49,7 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
private final World world; private final World world;
private final ConcurrentHashMap<BlockVector2, LocalChunk> blockChunks = private final ConcurrentHashMap<BlockVector2, LocalChunk> blockChunks =
new ConcurrentHashMap<>(); new ConcurrentHashMap<>();
private final List<BlockVector2> readRegion = new ArrayList<>();
private long modified; private long modified;
private LocalChunk lastWrappedChunk; private LocalChunk lastWrappedChunk;
private int lastX = Integer.MIN_VALUE; private int lastX = Integer.MIN_VALUE;
@ -58,8 +61,6 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
private int[] regenEnd; private int[] regenEnd;
private Consumer<BlockVector2> consumer = null; private Consumer<BlockVector2> consumer = null;
private boolean unloadAfter = true; private boolean unloadAfter = true;
private CuboidRegion readRegion = null;
private GlobalBlockQueue globalBlockQueue; private GlobalBlockQueue globalBlockQueue;
public BasicQueueCoordinator(World world) { public BasicQueueCoordinator(World world) {
@ -74,7 +75,7 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
} }
@Override public final int size() { @Override public final int size() {
return blockChunks.size(); return blockChunks.size() + readRegion.size();
} }
@Override public final void setModified(long modified) { @Override public final void setModified(long modified) {
@ -142,12 +143,16 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
return true; return true;
} }
@Override public CuboidRegion getReadRegion() { @Override public List<BlockVector2> getReadChunks() {
return this.readRegion; return this.readRegion;
} }
@Override public void setReadRegion(CuboidRegion readRegion) { @Override public void addReadChunk(BlockVector2 chunk) {
this.readRegion = readRegion; this.readRegion.add(chunk);
}
@Override public void addReadChunks(Set<BlockVector2> readRegion) {
this.readRegion.addAll(readRegion);
} }
@Override public void regenChunk(int x, int z) { @Override public void regenChunk(int x, int z) {

View File

@ -30,11 +30,10 @@ import com.google.inject.Inject;
import com.plotsquared.core.inject.factory.ChunkCoordinatorFactory; import com.plotsquared.core.inject.factory.ChunkCoordinatorFactory;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
@ -53,7 +52,6 @@ public class ChunkCoordinatorBuilder {
private long maxIterationTime = 60; // A little over 1 tick; private long maxIterationTime = 60; // A little over 1 tick;
private int initialBatchSize = 4; private int initialBatchSize = 4;
private boolean unloadAfter = true; private boolean unloadAfter = true;
private CuboidRegion readRegion = null;
@Inject @Inject
public ChunkCoordinatorBuilder(@Nonnull ChunkCoordinatorFactory chunkCoordinatorFactory) { public ChunkCoordinatorBuilder(@Nonnull ChunkCoordinatorFactory chunkCoordinatorFactory) {
@ -105,8 +103,11 @@ public class ChunkCoordinatorBuilder {
return this; return this;
} }
@Nonnull public ChunkCoordinatorBuilder withFinalAction(@Nonnull final Runnable whenDone) { @Nonnull public ChunkCoordinatorBuilder withFinalAction(@Nullable final Runnable whenDone) {
this.whenDone = Preconditions.checkNotNull(whenDone, "Final action may not be null"); if (whenDone == null) {
return this;
}
this.whenDone = whenDone;
return this; return this;
} }

View File

@ -29,12 +29,13 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
public class DelegateQueueCoordinator extends QueueCoordinator { public class DelegateQueueCoordinator extends QueueCoordinator {
@ -180,16 +181,22 @@ public class DelegateQueueCoordinator extends QueueCoordinator {
} }
} }
@Override public CuboidRegion getReadRegion() { @Override public List<BlockVector2> getReadChunks() {
if (parent != null) { if (parent != null) {
return parent.getReadRegion(); return parent.getReadChunks();
} }
return null; return null;
} }
@Override public void setReadRegion(CuboidRegion readRegion) { @Override public void addReadChunks(Set<BlockVector2> readChunks) {
if (parent != null) { if (parent != null) {
parent.setReadRegion(readRegion); parent.addReadChunks(readChunks);
}
}
@Override public void addReadChunk(BlockVector2 chunk) {
if (parent != null) {
parent.addReadChunk(chunk);
} }
} }

View File

@ -68,6 +68,7 @@ public class GlobalBlockQueue {
boolean success = false; boolean success = false;
if (queue.size() > 0 && !activeQueues.contains(queue)) { if (queue.size() > 0 && !activeQueues.contains(queue)) {
success = activeQueues.add(queue); success = activeQueues.add(queue);
System.out.println("c");
queue.start(); queue.start();
} }
return success; return success;

View File

@ -33,7 +33,6 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -43,6 +42,7 @@ import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
public abstract class QueueCoordinator { public abstract class QueueCoordinator {
@ -119,14 +119,16 @@ public abstract class QueueCoordinator {
public abstract boolean setEntity(Entity entity); public abstract boolean setEntity(Entity entity);
public abstract CuboidRegion getReadRegion(); public abstract List<BlockVector2> getReadChunks();
public abstract void setReadRegion(CuboidRegion readRegion); public abstract void addReadChunks(Set<BlockVector2> readChunks);
public abstract void setUnloadAfter(boolean unloadAfter); public abstract void addReadChunk(BlockVector2 chunk);
public abstract boolean isUnloadAfter(); public abstract boolean isUnloadAfter();
public abstract void setUnloadAfter(boolean unloadAfter);
public abstract void regenChunk(int x, int z); public abstract void regenChunk(int x, int z);
public abstract World getWorld(); public abstract World getWorld();
@ -136,6 +138,7 @@ public abstract class QueueCoordinator {
} }
public boolean enqueue() { public boolean enqueue() {
System.out.println("b");
return blockQueue.enqueue(this); return blockQueue.enqueue(this);
} }

View File

@ -46,10 +46,10 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
public abstract class RegionManager { public abstract class RegionManager {
@ -58,9 +58,14 @@ public abstract class RegionManager {
LoggerFactory.getLogger("P2/" + RegionManager.class.getSimpleName()); LoggerFactory.getLogger("P2/" + RegionManager.class.getSimpleName());
public static RegionManager manager = null; public static RegionManager manager = null;
@Inject private WorldUtil worldUtil; private final WorldUtil worldUtil;
@Inject private ChunkManager chunkManager; private final GlobalBlockQueue blockQueue;
@Inject private GlobalBlockQueue blockQueue;
@Inject
public RegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue) {
this.worldUtil = worldUtil;
this.blockQueue = blockQueue;
}
public static BlockVector2 getRegion(Location location) { public static BlockVector2 getRegion(Location location) {
int x = location.getX() >> 9; int x = location.getX() >> 9;
@ -143,8 +148,8 @@ public abstract class RegionManager {
(BasicQueueCoordinator) blockQueue.getNewQueue(newWorld); (BasicQueueCoordinator) blockQueue.getNewQueue(newWorld);
copyFromTo(pos1, pos2, relX, relZ, oldWorld, copyFrom, copyTo, false); copyFromTo(pos1, pos2, relX, relZ, oldWorld, copyFrom, copyTo, false);
copyFrom.setCompleteTask(copyTo::enqueue); copyFrom.setCompleteTask(copyTo::enqueue);
copyFrom.setReadRegion(new CuboidRegion(BlockVector3.at(pos1.getX(), 0, pos1.getZ()), copyFrom.addReadChunks(new CuboidRegion(BlockVector3.at(pos1.getX(), 0, pos1.getZ()),
BlockVector3.at(pos2.getX(), 0, pos2.getZ()))); BlockVector3.at(pos2.getX(), 0, pos2.getZ())).getChunks());
copyTo.setCompleteTask(whenDone); copyTo.setCompleteTask(whenDone);
copyFrom.enqueue(); copyFrom.enqueue();
return true; return true;
@ -171,10 +176,11 @@ public abstract class RegionManager {
QueueCoordinator fromQueue2 = blockQueue.getNewQueue(world2); QueueCoordinator fromQueue2 = blockQueue.getNewQueue(world2);
fromQueue1.setUnloadAfter(false); fromQueue1.setUnloadAfter(false);
fromQueue2.setUnloadAfter(false); fromQueue2.setUnloadAfter(false);
fromQueue1.setReadRegion(new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3())); fromQueue1.addReadChunks(
fromQueue2.setReadRegion(new CuboidRegion(swapPos.getBlockVector3(), BlockVector3 new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()).getChunks());
fromQueue2.addReadChunks(new CuboidRegion(swapPos.getBlockVector3(), BlockVector3
.at(swapPos.getX() + pos2.getX() - pos1.getX(), 0, .at(swapPos.getX() + pos2.getX() - pos1.getX(), 0,
swapPos.getZ() + pos2.getZ() - pos1.getZ()))); swapPos.getZ() + pos2.getZ() - pos1.getZ())).getChunks());
QueueCoordinator toQueue1 = blockQueue.getNewQueue(world1); QueueCoordinator toQueue1 = blockQueue.getNewQueue(world1);
QueueCoordinator toQueue2 = blockQueue.getNewQueue(world2); QueueCoordinator toQueue2 = blockQueue.getNewQueue(world2);
@ -231,7 +237,7 @@ public abstract class RegionManager {
final int minZ = pos1.getZ(); final int minZ = pos1.getZ();
final int maxX = pos2.getX(); final int maxX = pos2.getX();
final int maxZ = pos2.getZ(); final int maxZ = pos2.getZ();
queue.setReadRegion(region); queue.addReadChunks(region.getChunks());
queue.setChunkConsumer(blockVector2 -> { queue.setChunkConsumer(blockVector2 -> {
final int cx = blockVector2.getX() << 4; final int cx = blockVector2.getX() << 4;
final int cz = blockVector2.getZ() << 4; final int cz = blockVector2.getZ() << 4;

View File

@ -330,8 +330,8 @@ public abstract class SchematicHandler {
final int bcz = p1z >> 4; final int bcz = p1z >> 4;
final int tcx = p2x >> 4; final int tcx = p2x >> 4;
final int tcz = p2z >> 4; final int tcz = p2z >> 4;
queue.setReadRegion( queue.addReadChunks(
new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3())); new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()).getChunks());
queue.setChunkConsumer(blockVector2 -> { queue.setChunkConsumer(blockVector2 -> {
int x = blockVector2.getX(); int x = blockVector2.getX();
int z = blockVector2.getZ(); int z = blockVector2.getZ();