3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 13:00:05 +01:00

Few fixes for FastModeExtent.

Dieser Commit ist enthalten in:
Matthew Miller 2018-11-15 19:18:22 +10:00 committet von IronApollo
Ursprung e88b8c961d
Commit bc3562eb57
5 geänderte Dateien mit 36 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -549,4 +549,10 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
public void notifyAndLightBlock(Location position, BlockState previousType) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -2280,4 +2280,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
// TODO Auto-generated method stub
return false;
}
} }

Datei anzeigen

@ -121,4 +121,10 @@ public class MCAWorld implements SimpleWorld {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
// TODO Auto-generated method stub
return false;
}
} }

Datei anzeigen

@ -33,6 +33,7 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
@ -633,4 +634,10 @@ public class SchemVis extends ImmutableVirtualWorld {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
// TODO Auto-generated method stub
return false;
}
} }

Datei anzeigen

@ -31,10 +31,9 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayDeque;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Queue;
import java.util.Set; import java.util.Set;
/** /**
@ -43,7 +42,7 @@ import java.util.Set;
public class FastModeExtent extends AbstractDelegateExtent { public class FastModeExtent extends AbstractDelegateExtent {
private final World world; private final World world;
private final Queue<BlockVector3> positions = new ArrayDeque<>(); private final Set<BlockVector3> positions = new HashSet<>();
private final Set<BlockVector2> dirtyChunks = new HashSet<>(); private final Set<BlockVector2> dirtyChunks = new HashSet<>();
private boolean enabled = true; private boolean enabled = true;
private boolean postEditSimulation; private boolean postEditSimulation;
@ -106,7 +105,7 @@ public class FastModeExtent extends AbstractDelegateExtent {
if (world.setBlock(location, block, false)) { if (world.setBlock(location, block, false)) {
if (postEditSimulation) { if (postEditSimulation) {
positions.offer(location); positions.add(location);
} }
return true; return true;
} }
@ -117,6 +116,10 @@ public class FastModeExtent extends AbstractDelegateExtent {
} }
} }
public boolean commitRequired() {
return !dirtyChunks.isEmpty() || !positions.isEmpty();
}
@Override @Override
protected Operation commitBefore() { protected Operation commitBefore() {
return new Operation() { return new Operation() {
@ -127,9 +130,11 @@ public class FastModeExtent extends AbstractDelegateExtent {
} }
if (postEditSimulation) { if (postEditSimulation) {
while (run.shouldContinue() && !positions.isEmpty()) { Iterator<BlockVector3> positionIterator = positions.iterator();
BlockVector3 position = positions.poll(); // Remove from queue while (run.shouldContinue() && positionIterator.hasNext()) {
BlockVector3 position = positionIterator.next();
world.notifyAndLightBlock(position, BlockTypes.AIR.getDefaultState()); world.notifyAndLightBlock(position, BlockTypes.AIR.getDefaultState());
positionIterator.remove();
} }
return !positions.isEmpty() ? this : null; return !positions.isEmpty() ? this : null;