commanding-pipeline diff

This commit is contained in:
Jesse Boyd
2019-10-23 05:23:52 +01:00
parent fb91456bdd
commit 2080e9786b
193 changed files with 5449 additions and 3491 deletions

View File

@ -1,8 +1,13 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.WEManager;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
@ -17,9 +22,12 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
public abstract class FaweRegionExtent extends ResettableExtent {
public abstract class FaweRegionExtent extends ResettableExtent implements IBatchProcessor {
private final FaweLimit limit;
/**
@ -39,7 +47,20 @@ public abstract class FaweRegionExtent extends ResettableExtent {
public abstract Collection<Region> getRegions();
public boolean isGlobal() {
return getRegions().stream().anyMatch(Region::isGlobal);
for (Region r : getRegions()) {
if (r.isGlobal()) {
return true;
}
}
return false;
}
@Override
public Extent construct(Extent child) {
if (getExtent() != child) {
new ExtentTraverser<Extent>(this).setNext(child);
}
return this;
}
@Override

View File

@ -1,14 +1,24 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.RegionWrapper;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class HeightBoundExtent extends FaweRegionExtent {
public class HeightBoundExtent extends FaweRegionExtent implements IBatchProcessor {
private final int min, max;
private int lastY = -1;
@ -38,4 +48,12 @@ public class HeightBoundExtent extends FaweRegionExtent {
public Collection<Region> getRegions() {
return Collections.singletonList(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, min, max, Integer.MIN_VALUE, Integer.MAX_VALUE));
}
@Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
if (trimY(set, min, max) | trimNBT(set, this::contains)) {
return set;
}
return null;
}
}

View File

@ -1,13 +1,20 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.FaweLimit;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionIntersection;
import java.util.Arrays;
import java.util.Collection;
public class MultiRegionExtent extends FaweRegionExtent {
private final RegionIntersection intersection;
private Region region;
private final Region[] regions;
private int index;
@ -22,6 +29,7 @@ public class MultiRegionExtent extends FaweRegionExtent {
this.index = 0;
this.region = regions[0];
this.regions = regions;
this.intersection = new RegionIntersection(Arrays.asList(regions));
}
@Override
@ -64,4 +72,9 @@ public class MultiRegionExtent extends FaweRegionExtent {
public Collection<Region> getRegions() {
return Arrays.asList(regions);
}
@Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
return intersection.processBatch(chunk, get, set);
}
}

View File

@ -32,20 +32,26 @@ public class MultiTransform extends RandomTransform {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return Arrays.stream(extents).map(extent -> extent.setBlock(x, y, z, block))
.reduce(false, (a, b) -> a || b);
// don't use streams for each block place, it'd be incredibly slow
boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(x, y, z, block);
return result;
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
return Arrays.stream(extents).map(extent -> extent.setBlock(location, block))
.reduce(false, (a, b) -> a || b);
// don't use streams for each block place, it'd be incredibly slow
boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(location, block);
return result;
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return Arrays.stream(extents).map(extent -> extent.setBiome(position, biome))
.reduce(false, (a, b) -> a || b);
// don't use streams for each block place, it'd be incredibly slow
boolean result = false;
for (AbstractDelegateExtent extent : extents) result |= extent.setBiome(position, biome);
return result;
}
@Nullable

View File

@ -1,5 +1,8 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException;
@ -321,4 +324,9 @@ public class NullExtent extends FaweRegionExtent {
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
throw reason;
}
@Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
return null;
}
}

View File

@ -19,12 +19,12 @@ import com.sk89q.worldedit.world.block.BlockTypes;
public class ProcessedWEExtent extends AbstractDelegateExtent {
private final FaweLimit limit;
private final AbstractDelegateExtent extent;
private final Extent extent;
public ProcessedWEExtent(Extent parent, FaweLimit limit) {
super(parent);
this.limit = limit;
this.extent = (AbstractDelegateExtent) parent;
this.extent = parent;
}
public void setLimit(FaweLimit other) {

View File

@ -1,5 +1,8 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.FaweLimit;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.regions.Region;
@ -35,4 +38,9 @@ public class SingleRegionExtent extends FaweRegionExtent {
public Collection<Region> getRegions() {
return Collections.singletonList(region);
}
@Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
return region.processBatch(chunk, get, set);
}
}