mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
It started on work with commands then I got carried away.
This commit is contained in:
@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction {
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return pattern.apply(extent, position, position);
|
||||
return extent.setBlock(position, pattern.apply(position));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -147,17 +147,33 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
CompoundTag tag = state.getNbtData();
|
||||
|
||||
if (tag != null) {
|
||||
// Handle leashed entities
|
||||
Tag leashTag = tag.getValue().get("Leash");
|
||||
if (leashTag instanceof CompoundTag) {
|
||||
CompoundTag leashCompound = (CompoundTag) leashTag;
|
||||
if (leashCompound.containsKey("X")) { // leashed to a fence
|
||||
Vector3 tilePosition = Vector3.at(leashCompound.asInt("X"), leashCompound.asInt("Y"), leashCompound.asInt("Z"));
|
||||
BlockVector3 newLeash = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
|
||||
return new BaseEntity(state.getType(), tag.createBuilder()
|
||||
.put("Leash", leashCompound.createBuilder()
|
||||
.putInt("X", newLeash.getBlockX())
|
||||
.putInt("Y", newLeash.getBlockY())
|
||||
.putInt("Z", newLeash.getBlockZ())
|
||||
.build()
|
||||
).build());
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
// Handle hanging entities (paintings, item frames, etc.)
|
||||
|
||||
boolean hasTilePosition = tag.containsKey("TileX") && tag.containsKey("TileY") && tag.containsKey("TileZ");
|
||||
boolean hasFacing = tag.containsKey("Facing");
|
||||
tag = tag.createBuilder().build();
|
||||
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
|
||||
|
||||
boolean hasTilePosition = tag.containsKey("TileX") && tag.containsKey("TileY") && tag.containsKey("TileZ");
|
||||
boolean hasDirection = tag.containsKey("Direction");
|
||||
boolean hasLegacyDirection = tag.containsKey("Dir");
|
||||
boolean hasFacing = tag.containsKey("Facing");
|
||||
|
||||
if (hasTilePosition) {
|
||||
changed = true;
|
||||
|
@ -44,7 +44,7 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
||||
*
|
||||
* @return the extent
|
||||
*/
|
||||
public final Extent getExtent() {
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,11 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mask that tests whether a block matches a given {@link BlockCategory}, or tag.
|
||||
@ -39,7 +41,12 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return category.contains(vector.getBlock(getExtent()));
|
||||
return category.contains(getExtent().getBlock(vector));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -31,8 +33,17 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mask that checks whether blocks at the given positions are matched by
|
||||
* a block in a list.
|
||||
*
|
||||
* <p>This mask checks for both an exact block type and state value match,
|
||||
* respecting fuzzy status of the BlockState.</p>
|
||||
*/
|
||||
public class BlockMask extends ABlockMask {
|
||||
|
||||
private final boolean[] ordinals;
|
||||
|
||||
public BlockMask() {
|
||||
@ -49,6 +60,10 @@ public class BlockMask extends ABlockMask {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new block mask.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param blocks a list of blocks to match
|
||||
* @deprecated NBT not supported by this mask
|
||||
*/
|
||||
@Deprecated
|
||||
@ -57,11 +72,23 @@ public class BlockMask extends ABlockMask {
|
||||
add(blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new block mask.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param block an array of blocks to match
|
||||
*/
|
||||
public BlockMask(Extent extent, BaseBlock... block) {
|
||||
this(extent, Arrays.asList(checkNotNull(block)));
|
||||
}
|
||||
|
||||
public BlockMask add(Predicate<BlockState> predicate) {
|
||||
for (int i = 0; i < ordinals.length; i++) {
|
||||
if (!ordinals[i]) {
|
||||
BlockState state = BlockTypes.states[i];
|
||||
if (state != null) ordinals[i] = predicate.test(state);
|
||||
if (state != null) {
|
||||
ordinals[i] = predicate.test(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@ -73,7 +100,9 @@ public class BlockMask extends ABlockMask {
|
||||
}
|
||||
|
||||
public BlockMask remove(BlockState... states) {
|
||||
for (BlockState state : states) ordinals[state.getOrdinal()] = false;
|
||||
for (BlockState state : states) {
|
||||
ordinals[state.getOrdinal()] = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -84,13 +113,17 @@ public class BlockMask extends ABlockMask {
|
||||
|
||||
public boolean isEmpty() {
|
||||
for (boolean value : ordinals) {
|
||||
if (value) return false;
|
||||
if (value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public BlockMask addStates(Collection<BlockState> states) {
|
||||
for (BlockState state : states) ordinals[state.getOrdinal()] = true;
|
||||
private BlockMask addStates(Collection<BlockState> states) {
|
||||
for (BlockState state : states) {
|
||||
ordinals[state.getOrdinal()] = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -99,7 +132,7 @@ public class BlockMask extends ABlockMask {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockMask addTypes(Collection<BlockType> types) {
|
||||
private BlockMask addTypes(Collection<BlockType> types) {
|
||||
for (BlockType type : types) {
|
||||
for (BlockState state : type.getAllStates()) {
|
||||
ordinals[state.getOrdinal()] = true;
|
||||
@ -109,6 +142,9 @@ public class BlockMask extends ABlockMask {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given blocks to the list of criteria.
|
||||
*
|
||||
* @param blocks a list of blocks
|
||||
* @deprecated NBT not supported by this mask
|
||||
*/
|
||||
@Deprecated
|
||||
@ -118,6 +154,15 @@ public class BlockMask extends ABlockMask {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given blocks to the list of criteria.
|
||||
*
|
||||
* @param block an array of blocks
|
||||
*/
|
||||
public void add(BaseBlock... block) {
|
||||
add(Arrays.asList(checkNotNull(block)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockState state) {
|
||||
return ordinals[state.getOrdinal()];
|
||||
@ -156,6 +201,12 @@ public class BlockMask extends ABlockMask {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask tryOptimize() {
|
||||
int setStates = 0;
|
||||
@ -218,7 +269,11 @@ public class BlockMask extends ABlockMask {
|
||||
}
|
||||
|
||||
if (setTypes == totalTypes - 1) {
|
||||
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
|
||||
if (unsetType != null) {
|
||||
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
|
||||
} else {
|
||||
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -227,7 +282,9 @@ public class BlockMask extends ABlockMask {
|
||||
@Override
|
||||
public Mask inverse() {
|
||||
boolean[] cloned = ordinals.clone();
|
||||
for (int i = 0; i < cloned.length; i++) cloned[i] = !cloned[i];
|
||||
for (int i = 0; i < cloned.length; i++) {
|
||||
cloned[i] = !cloned[i];
|
||||
}
|
||||
return new BlockMask(getExtent(), cloned);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldedit.blocks.Blocks;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -27,8 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Deprecated
|
||||
public class BlockStateMask extends AbstractExtentMask {
|
||||
@ -66,4 +65,9 @@ public class BlockStateMask extends AbstractExtentMask {
|
||||
.allMatch(entry -> block.getState(entry.getKey()) == entry.getValue());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -20,15 +20,16 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A mask that checks whether blocks at the given positions are matched by
|
||||
@ -38,10 +39,8 @@ import java.util.Set;
|
||||
* use {@link BlockMask}.</p>
|
||||
* @deprecated use BlockMaskBuilder
|
||||
*/
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Deprecated
|
||||
public final class BlockTypeMask extends AbstractExtentMask {
|
||||
public class BlockTypeMask extends AbstractExtentMask {
|
||||
|
||||
private final boolean[] types;
|
||||
|
||||
@ -51,7 +50,7 @@ public final class BlockTypeMask extends AbstractExtentMask {
|
||||
* @param extent the extent
|
||||
* @param blocks a list of blocks to match
|
||||
*/
|
||||
public BlockTypeMask(Extent extent, Collection<BlockType> blocks) {
|
||||
public BlockTypeMask(Extent extent, @NotNull Collection<BlockType> blocks) {
|
||||
this(extent, blocks.toArray(new BlockType[0]));
|
||||
}
|
||||
|
||||
@ -61,23 +60,18 @@ public final class BlockTypeMask extends AbstractExtentMask {
|
||||
* @param extent the extent
|
||||
* @param block an array of blocks to match
|
||||
*/
|
||||
public BlockTypeMask(Extent extent, BlockType... block) {
|
||||
public BlockTypeMask(Extent extent, @NotNull BlockType... block) {
|
||||
super(extent);
|
||||
this.types = new boolean[BlockTypes.size()];
|
||||
for (BlockType type : block) this.types[type.getInternalId()] = true;
|
||||
}
|
||||
|
||||
protected BlockTypeMask(Extent extent, boolean[] types) {
|
||||
super(extent);
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given blocks to the list of criteria.
|
||||
*
|
||||
* @param blocks a list of blocks
|
||||
*/
|
||||
public void add(Collection<BlockType> blocks) {
|
||||
public void add(@NotNull Collection<BlockType> blocks) {
|
||||
checkNotNull(blocks);
|
||||
for (BlockType type : blocks) {
|
||||
add(type);
|
||||
@ -92,7 +86,7 @@ public final class BlockTypeMask extends AbstractExtentMask {
|
||||
*
|
||||
* @param block an array of blocks
|
||||
*/
|
||||
public void add(BlockType... block) {
|
||||
public void add(@NotNull BlockType... block) {
|
||||
for (BlockType type : block) {
|
||||
this.types[type.getInternalId()] = true;
|
||||
}
|
||||
@ -120,4 +114,10 @@ public final class BlockTypeMask extends AbstractExtentMask {
|
||||
return types[block.getInternalId()];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,9 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Has the criteria where the Y value of passed positions must be within
|
||||
@ -48,4 +50,9 @@ public class BoundedHeightMask extends AbstractMask {
|
||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mask that returns true whenever the block at the location is not
|
||||
@ -40,7 +40,13 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !vector.getBlock(getExtent()).getMaterial().isAir();
|
||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
|
@ -22,17 +22,12 @@ package com.sk89q.worldedit.function.mask;
|
||||
import com.boydti.fawe.beta.DelegateFilter;
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.minecraft.util.commands.Link;
|
||||
import com.sk89q.worldedit.command.UtilityCommands;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Tests whether a given vector meets a criteria.
|
||||
*/
|
||||
@Link(clazz = UtilityCommands.class, value = "masks")
|
||||
public interface Mask {
|
||||
|
||||
/**
|
||||
|
@ -22,11 +22,9 @@ package com.sk89q.worldedit.function.mask;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
@ -87,8 +85,8 @@ public class NoiseFilter extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 v) {
|
||||
return noiseGenerator.noise(MutableVector3.get(v.getX(), v.getY(), v.getZ())) <= density;
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return noiseGenerator.noise(MutableVector3.get(vector.getX(), vector.getY(), vector.getZ())) <= density;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -63,4 +63,9 @@ public class RegionMask extends AbstractMask {
|
||||
return region.contains(vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SolidBlockMask extends BlockMask {
|
||||
@ -29,6 +31,13 @@ public class SolidBlockMask extends BlockMask {
|
||||
add(state -> state.getMaterial().isMovementBlocker());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Extent extent = getExtent();
|
||||
BlockState block = extent.getBlock(vector);
|
||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
|
@ -19,16 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -68,13 +66,12 @@ public class ChangeSetExecutor implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
while (iterator.hasNext()) {
|
||||
Change change = iterator.next();
|
||||
if (type == Type.UNDO) {
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next().undo(context);
|
||||
}
|
||||
change.undo(context);
|
||||
} else {
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next().redo(context);
|
||||
change.redo(context);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.function.operation;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.object.extent.BlockTranslateExtent;
|
||||
import com.boydti.fawe.object.extent.PositionTransformExtent;
|
||||
import com.boydti.fawe.object.function.block.BiomeCopy;
|
||||
@ -30,7 +29,6 @@ import com.boydti.fawe.object.function.block.CombinedBlockCopy;
|
||||
import com.boydti.fawe.object.function.block.SimpleBlockCopy;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
@ -74,7 +72,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
private int repetitions = 1;
|
||||
private Mask sourceMask = Masks.alwaysTrue();
|
||||
private boolean removingEntities;
|
||||
private boolean copyingEntities = true; // default to true for backwards compatibility, sort of // No, it's not for compatibility, it makes sense for entities to be copied and people will get annoyed if it doesn't
|
||||
private boolean copyingEntities = true; // default to true for backwards compatibility, sort of
|
||||
private boolean copyingBiomes;
|
||||
private RegionFunction sourceFunction = null;
|
||||
private Transform transform = new Identity();
|
||||
|
@ -1,18 +1,11 @@
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Link;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.UtilityCommands;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
* Returns a {@link BlockStateHolder} for a given position.
|
||||
* - Adapts the vector apply to integer
|
||||
*/
|
||||
@Link(clazz = UtilityCommands.class, value = "patterns")
|
||||
public interface FawePattern extends Pattern {
|
||||
//
|
||||
// @Deprecated
|
||||
|
@ -21,9 +21,7 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.minecraft.util.commands.Link;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.UtilityCommands;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
@ -32,7 +30,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
/**
|
||||
* Returns a {@link BlockStateHolder} for a given position.
|
||||
*/
|
||||
@Link(clazz = UtilityCommands.class, value = "patterns")
|
||||
public interface Pattern extends Filter {
|
||||
|
||||
/**
|
||||
|
@ -20,19 +20,13 @@
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Removes the waterlogged state from blocks if possible. If not possible, returns air.
|
||||
@ -42,9 +36,9 @@ public class WaterloggedRemover extends AbstractExtentPattern {
|
||||
private static SoftReference<BlockState[]> cache = new SoftReference<>(null);
|
||||
|
||||
private synchronized BlockState[] getRemap() {
|
||||
BlockState[] remap = this.cache.get();
|
||||
BlockState[] remap = cache.get();
|
||||
if (remap != null) return remap;
|
||||
this.cache = new SoftReference<>(remap = new BlockState[BlockTypes.states.length]);
|
||||
cache = new SoftReference<>(remap = new BlockState[BlockTypes.states.length]);
|
||||
|
||||
// init
|
||||
for (int i = 0; i < remap.length; i++) {
|
||||
@ -76,4 +70,4 @@ public class WaterloggedRemover extends AbstractExtentPattern {
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -130,7 +131,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* Add the directions along the axes as directions to visit.
|
||||
*/
|
||||
public void addAxes() {
|
||||
HashSet<BlockVector3> set = new HashSet<>(Arrays.asList(directions));
|
||||
HashSet<BlockVector3> set = Sets.newHashSet(directions);
|
||||
set.add(BlockVector3.UNIT_MINUS_Y);
|
||||
set.add(BlockVector3.UNIT_Y);
|
||||
set.add(BlockVector3.UNIT_MINUS_X);
|
||||
@ -144,7 +145,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* Add the diagonal directions as directions to visit.
|
||||
*/
|
||||
public void addDiagonal() {
|
||||
HashSet<BlockVector3> set = new HashSet<>(Arrays.asList(directions));
|
||||
HashSet<BlockVector3> set = Sets.newHashSet(directions);
|
||||
set.add(Direction.NORTHEAST.toBlockVector());
|
||||
set.add(Direction.SOUTHEAST.toBlockVector());
|
||||
set.add(Direction.SOUTHWEST.toBlockVector());
|
||||
@ -175,6 +176,22 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to visit the given 'to' location.
|
||||
*
|
||||
* @param from the origin block
|
||||
* @param to the block under question
|
||||
*/
|
||||
private void visit(BlockVector3 from, BlockVector3 to) {
|
||||
BlockVector3 blockVector = to;
|
||||
if (!visited.contains(blockVector)) {
|
||||
visited.add(blockVector);
|
||||
if (isVisitable(from, to)) {
|
||||
queue.add(blockVector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisited(BlockVectorSet set) {
|
||||
this.visited = set;
|
||||
}
|
||||
@ -213,11 +230,8 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
// MutableBlockVector3 mutable2 = new MutableBlockVector3();
|
||||
boolean shouldTrim = false;
|
||||
BlockVector3[] dirs = directions;
|
||||
BlockVectorSet tempQueue = new BlockVectorSet();
|
||||
BlockVectorSet chunkLoadSet = new BlockVectorSet();
|
||||
for (currentDepth = 0; !queue.isEmpty() && currentDepth <= maxDepth; currentDepth++) {
|
||||
for (BlockVector3 from : queue) {
|
||||
if (function.apply(from)) affected++;
|
||||
@ -244,9 +258,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
BlockVectorSet tmp = queue;
|
||||
queue = tempQueue;
|
||||
tmp.clear();
|
||||
chunkLoadSet.clear();
|
||||
tempQueue = tmp;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -70,17 +70,13 @@ public class RegionVisitor implements Operation {
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
for (BlockVector3 pt : iterable) {
|
||||
apply(pt);
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void apply(BlockVector3 pt) throws WorldEditException {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
Reference in New Issue
Block a user