Fix incorrect schematic paste height, undo changes to HybridUtils

This commit is contained in:
dordsor21 2022-01-26 17:59:44 +00:00 committed by Jordan
parent ff60ad1e24
commit a12fe280db
2 changed files with 9 additions and 51 deletions

View File

@ -178,10 +178,9 @@ public class HybridPlotManager extends ClassicPlotManager {
} }
BaseBlock[] blocks = hybridPlotWorld.G_SCH.get(MathMan.pair(absX, absZ)); BaseBlock[] blocks = hybridPlotWorld.G_SCH.get(MathMan.pair(absX, absZ));
if (blocks != null) { if (blocks != null) {
for (int yIndex = 0; yIndex < blocks.length; yIndex++) { for (int y = 0; y < blocks.length; y++) {
int y = yIndex - hybridPlotWorld.getMinGenHeight(); if (blocks[y] != null) {
if (blocks[yIndex] != null) { queue.setBlock(x, minY + y, z, blocks[y]);
queue.setBlock(x, minY + y, z, blocks[yIndex]);
} else { } else {
// This is necessary, otherwise any blocks not specified in the schematic will remain after a clear // This is necessary, otherwise any blocks not specified in the schematic will remain after a clear
queue.setBlock(x, minY + y, z, airBlock); queue.setBlock(x, minY + y, z, airBlock);

View File

@ -65,7 +65,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.io.File; import java.io.File;
import java.util.ArrayDeque; import java.util.ArrayDeque;
@ -444,9 +443,8 @@ public class HybridUtils {
while (iter.hasNext()) { while (iter.hasNext()) {
BlockVector2 chunk = iter.next(); BlockVector2 chunk = iter.next();
iter.remove(); iter.remove();
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName())); boolean regenedRoad = regenerateRoad(area, chunk, extend);
boolean regenedRoad = regenerateRoad(area, chunk, extend, queue); if (!regenedRoad) {
if (!regenedRoad || !queue.enqueue()) {
LOGGER.info("Failed to regenerate roads"); LOGGER.info("Failed to regenerate roads");
} }
} }
@ -482,12 +480,11 @@ public class HybridUtils {
TaskManager.getPlatformImplementation().sync(() -> { TaskManager.getPlatformImplementation().sync(() -> {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Iterator<BlockVector2> iterator = chunks.iterator(); Iterator<BlockVector2> iterator = chunks.iterator();
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName()));
while (System.currentTimeMillis() - start < 20 && !chunks.isEmpty()) { while (System.currentTimeMillis() - start < 20 && !chunks.isEmpty()) {
final BlockVector2 chunk = iterator.next(); final BlockVector2 chunk = iterator.next();
iterator.remove(); iterator.remove();
boolean regenedRoads = regenerateRoad(area, chunk, extend, queue); boolean regenedRoads = regenerateRoad(area, chunk, extend);
if (!regenedRoads || !queue.enqueue()) { if (!regenedRoads) {
LOGGER.info("Failed to regenerate road"); LOGGER.info("Failed to regenerate road");
} }
} }
@ -575,35 +572,7 @@ public class HybridUtils {
return ey; return ey;
} }
/**
* Regenerate the road in a chunk in a plot area.
*
* @param area Plot area to regenerate road for
* @param chunk Chunk location to regenerate
* @param extend How far to extend setting air above the road
* @return if successful
* @deprecated use {@link HybridUtils#regenerateRoad(PlotArea, BlockVector2, int, QueueCoordinator)}
*/
@Deprecated(forRemoval = true, since = "TODO")
public boolean regenerateRoad(final PlotArea area, final BlockVector2 chunk, int extend) { public boolean regenerateRoad(final PlotArea area, final BlockVector2 chunk, int extend) {
return regenerateRoad(area, chunk, extend, null);
}
/**
* Regenerate the road in a chunk in a plot area.
*
* @param area Plot area to regenerate road for
* @param chunk Chunk location to regenerate
* @param extend How far to extend setting air above the road
* @param queueCoordinator {@link QueueCoordinator} to use to set the blocks. Null if one should be created and enqueued
* @return if successful
*/
public boolean regenerateRoad(
final PlotArea area,
final BlockVector2 chunk,
int extend,
@Nullable QueueCoordinator queueCoordinator
) {
int x = chunk.getX() << 4; int x = chunk.getX() << 4;
int z = chunk.getZ() << 4; int z = chunk.getZ() << 4;
int ex = x + 15; int ex = x + 15;
@ -629,15 +598,7 @@ public class HybridUtils {
z -= plotWorld.ROAD_OFFSET_Z; z -= plotWorld.ROAD_OFFSET_Z;
final int finalX = x; final int finalX = x;
final int finalZ = z; final int finalZ = z;
final boolean enqueue; QueueCoordinator queue = this.blockQueue.getNewQueue(worldUtil.getWeWorld(plotWorld.getWorldName()));
final QueueCoordinator queue;
if (queueCoordinator == null) {
queue = this.blockQueue.getNewQueue(worldUtil.getWeWorld(plotWorld.getWorldName()));
enqueue = true;
} else {
queue = queueCoordinator;
enqueue = false;
}
if (id1 == null || id2 == null || id1 != id2) { if (id1 == null || id2 == null || id1 != id2) {
this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> { this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
if (id1 != null) { if (id1 != null) {
@ -721,9 +682,7 @@ public class HybridUtils {
} }
} }
} }
if (enqueue) { queue.enqueue();
queue.enqueue();
}
}); });
return true; return true;
} }