Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-20 09:50:06 +01:00
Merge branch 'main' into feat/improved-entity-operations
Dieser Commit ist enthalten in:
Commit
1f0ac129dd
@ -12,6 +12,6 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT
|
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT
|
||||||
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240323.213332-142")
|
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240325.123556-143")
|
||||||
compileOnly(libs.paperlib)
|
compileOnly(libs.paperlib)
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,9 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -80,28 +77,18 @@ public class MultiBatchProcessor implements IBatchProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||||
Map<Integer, Set<IBatchProcessor>> ordered = new HashMap<>();
|
Map<Integer, List<IBatchProcessor>> ordered = new HashMap<>();
|
||||||
IChunkSet chunkSet = set;
|
IChunkSet chunkSet = set;
|
||||||
for (IBatchProcessor processor : processors) {
|
for (IBatchProcessor processor : processors) {
|
||||||
if (processor.getScope() != ProcessorScope.ADDING_BLOCKS) {
|
if (processor.getScope() != ProcessorScope.ADDING_BLOCKS) {
|
||||||
ordered.merge(
|
ordered.computeIfAbsent(processor.getScope().intValue(), k -> new ArrayList<>())
|
||||||
processor.getScope().intValue(),
|
.add(processor);
|
||||||
new HashSet<>(Collections.singleton(processor)),
|
|
||||||
(existing, theNew) -> {
|
|
||||||
existing.add(processor);
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
chunkSet = processSet(processor, chunk, get, chunkSet);
|
chunkSet = processSet(processor, chunk, get, chunkSet);
|
||||||
}
|
}
|
||||||
if (ordered.size() > 0) {
|
if (!ordered.isEmpty()) {
|
||||||
for (int i = 1; i <= 4; i++) {
|
for (List<IBatchProcessor> processors : ordered.values()) {
|
||||||
Set<IBatchProcessor> processors = ordered.get(i);
|
|
||||||
if (processors == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (IBatchProcessor processor : processors) {
|
for (IBatchProcessor processor : processors) {
|
||||||
chunkSet = processSet(processor, chunk, get, chunkSet);
|
chunkSet = processSet(processor, chunk, get, chunkSet);
|
||||||
if (chunkSet == null) {
|
if (chunkSet == null) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.fastasyncworldedit.core.function.pattern;
|
package com.fastasyncworldedit.core.function.pattern;
|
||||||
|
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
@ -57,4 +58,9 @@ public class ExpressionPattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new ExpressionPattern(this.expression.clone());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static java.lang.Math.floorDiv;
|
import static java.lang.Math.floorDiv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,4 +54,10 @@ public class Linear2DBlockPattern extends AbstractPattern {
|
|||||||
return patternsArray[index].apply(extent, get, set);
|
return patternsArray[index].apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
final Pattern[] forked = Arrays.stream(this.patternsArray).map(Pattern::fork).toArray(Pattern[]::new);
|
||||||
|
return new Linear2DBlockPattern(forked, this.xScale, this.zScale);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static java.lang.Math.floorDiv;
|
import static java.lang.Math.floorDiv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,4 +58,10 @@ public class Linear3DBlockPattern extends AbstractPattern {
|
|||||||
return patternsArray[index].apply(extent, get, set);
|
return patternsArray[index].apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
final Pattern[] forked = Arrays.stream(this.patternsArray).map(Pattern::fork).toArray(Pattern[]::new);
|
||||||
|
return new Linear3DBlockPattern(forked, this.xScale, this.yScale, this.zScale);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,15 +36,15 @@ public class LinearBlockPattern extends AbstractPattern implements ResettablePat
|
|||||||
return patternsArray[index].apply(extent, get, set);
|
return patternsArray[index].apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Filter fork() {
|
|
||||||
final Pattern[] forked = Arrays.stream(this.patternsArray).map(Pattern::fork).toArray(Pattern[]::new);
|
|
||||||
return new LinearBlockPattern(forked);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
final Pattern[] forked = Arrays.stream(this.patternsArray).map(Pattern::fork).toArray(Pattern[]::new);
|
||||||
|
return new LinearBlockPattern(forked);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,4 +43,9 @@ public class MaskedPattern extends AbstractPattern {
|
|||||||
return secondary.apply(extent, get, set);
|
return secondary.apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new MaskedPattern(this.mask.copy(), this.primary.fork(), this.secondary.fork());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,9 @@ public class NoXPattern extends AbstractPattern {
|
|||||||
return pattern.apply(extent, mutable, set);
|
return pattern.apply(extent, mutable, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new NoXPattern(this.pattern.fork());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,9 @@ public class NoYPattern extends AbstractPattern {
|
|||||||
return pattern.apply(extent, mutable, set);
|
return pattern.apply(extent, mutable, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new NoYPattern(this.pattern.fork());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.fastasyncworldedit.core.function.pattern;
|
package com.fastasyncworldedit.core.function.pattern;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||||
|
import com.fastasyncworldedit.core.queue.Filter;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
@ -36,4 +37,9 @@ public class NoZPattern extends AbstractPattern {
|
|||||||
return pattern.apply(extent, mutable, set);
|
return pattern.apply(extent, mutable, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new NoZPattern(this.pattern.fork());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,9 @@ public class OffsetPattern extends AbstractPattern {
|
|||||||
return pattern.apply(extent, get, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new OffsetPattern(this.pattern.fork(), this.dx, this.dy, this.dz, this.minY, this.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,4 +72,9 @@ public class RandomOffsetPattern extends AbstractPattern {
|
|||||||
return pattern.apply(extent, get, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new RandomOffsetPattern(this.pattern.fork(), this.dx, this.dy, this.dz, this.minY, this.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,4 +63,11 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
|
|||||||
origin = null;
|
origin = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
RelativePattern forked = new RelativePattern(this.pattern.fork(), this.minY, this.maxY);
|
||||||
|
forked.origin = this.origin; // maintain origin for forks
|
||||||
|
return forked;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,4 +94,9 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
|||||||
return pattern.apply(extent, get, set);
|
return pattern.apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new SolidRandomOffsetPattern(this.pattern.fork(), this.dx, this.dy, this.dz, this.minY, this.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,4 +129,9 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
|||||||
return !block.getBlockType().getMaterial().isMovementBlocker();
|
return !block.getBlockType().getMaterial().isMovementBlocker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new SurfaceRandomOffsetPattern(this.pattern.fork(), this.moves, this.minY, this.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -235,4 +235,11 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FAWE - stateful pattern
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
return new ForgetfulExtentBuffer(extent, mask.copy());
|
||||||
|
}
|
||||||
|
//FAWE end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ import com.sk89q.worldedit.extent.buffer.ExtentBuffer;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,4 +66,12 @@ public class ExtentBufferedCompositePattern extends AbstractExtentPattern {
|
|||||||
return lastBlock;
|
return lastBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FAWE - stateful pattern
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
final Pattern[] forkedPatterns = Arrays.stream(patterns).map(Pattern::fork).toArray(Pattern[]::new);
|
||||||
|
return new ExtentBufferedCompositePattern(getExtent(), forkedPatterns);
|
||||||
|
}
|
||||||
|
//FAWE end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,11 @@ public interface Pattern extends Filter {
|
|||||||
apply(block, block, block);
|
apply(block, block, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default Pattern fork() { // covariant return type
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +67,13 @@ public class RandomPattern extends AbstractPattern {
|
|||||||
this.collection = RandomCollection.of(weights, random);
|
this.collection = RandomCollection.of(weights, random);
|
||||||
this.patterns = parent.patterns;
|
this.patterns = parent.patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RandomPattern(SimpleRandom random, Map<Pattern, Double> weights) {
|
||||||
|
this.random = random;
|
||||||
|
this.weights = weights;
|
||||||
|
this.collection = RandomCollection.of(weights, random);
|
||||||
|
this.patterns = new LinkedHashSet<>(weights.keySet());
|
||||||
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,6 +114,14 @@ public class RandomPattern extends AbstractPattern {
|
|||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(extent, get, set);
|
return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern fork() {
|
||||||
|
final LinkedHashMap<Pattern, Double> newWeights = new LinkedHashMap<>();
|
||||||
|
this.weights.forEach((p, w) -> newWeights.put(p.fork(), w));
|
||||||
|
return new RandomPattern(this.random, newWeights);
|
||||||
|
}
|
||||||
|
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,16 @@ import com.sk89q.worldedit.world.block.BlockType;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static com.sk89q.worldedit.blocks.Blocks.resolveProperties;
|
import static com.sk89q.worldedit.blocks.Blocks.resolveProperties;
|
||||||
|
|
||||||
public class StateApplyingPattern extends AbstractExtentPattern {
|
public class StateApplyingPattern extends AbstractExtentPattern {
|
||||||
|
|
||||||
private final Map<String, String> states;
|
private final Map<String, String> states;
|
||||||
private final Map<BlockType, Map<Property<Object>, Object>> cache = Maps.newHashMap();
|
//FAWE - avoid race conditions
|
||||||
|
private final Map<BlockType, Map<Property<Object>, Object>> cache = new ConcurrentHashMap<>();
|
||||||
|
//FAWE end
|
||||||
|
|
||||||
public StateApplyingPattern(Extent extent, Map<String, String> statesToSet) {
|
public StateApplyingPattern(Extent extent, Map<String, String> statesToSet) {
|
||||||
super(extent);
|
super(extent);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren