mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
*
A tribute to Jesse
This commit is contained in:
@ -23,11 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Executes several region functions in order.
|
||||
@ -49,7 +47,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
*/
|
||||
public CombinedRegionFunction(Collection<RegionFunction> functions) {
|
||||
checkNotNull(functions);
|
||||
this.functions = functions.toArray(new RegionFunction[functions.size()]);
|
||||
this.functions = functions.toArray(new RegionFunction[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +82,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
checkNotNull(functions);
|
||||
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.functions));
|
||||
functionsList.addAll(functions);
|
||||
this.functions = functionsList.toArray(new RegionFunction[functionsList.size()]);
|
||||
this.functions = functionsList.toArray(new RegionFunction[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,4 +103,4 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -35,4 +35,5 @@ public interface RegionFunction {
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean apply(BlockVector3 position) throws WorldEditException;
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
@ -33,7 +34,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
public class BiomeReplace implements FlatRegionFunction {
|
||||
|
||||
private final Extent extent;
|
||||
private BiomeType biome;
|
||||
private BiomePattern biome;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -42,15 +43,25 @@ public class BiomeReplace implements FlatRegionFunction {
|
||||
* @param biome a biome
|
||||
*/
|
||||
public BiomeReplace(Extent extent, BiomeType biome) {
|
||||
this(extent, (BiomePattern) biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent to apply this function to
|
||||
* @param pattern the biome pattern to set
|
||||
*/
|
||||
public BiomeReplace(Extent extent, BiomePattern pattern) {
|
||||
checkNotNull(extent);
|
||||
checkNotNull(biome);
|
||||
checkNotNull(pattern);
|
||||
this.extent = extent;
|
||||
this.biome = biome;
|
||||
this.biome = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
return extent.setBiome(position, biome);
|
||||
return extent.setBiome(position, biome.apply(position));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,7 +80,14 @@ public class Naturalizer implements LayerFunction {
|
||||
}
|
||||
|
||||
private boolean naturalize(BlockVector3 position, int depth) throws WorldEditException {
|
||||
return editSession.setBlock(position, getTargetBlock(depth));
|
||||
BlockState block = editSession.getBlock(position);
|
||||
BlockState targetBlock = getTargetBlock(depth);
|
||||
|
||||
if (block.equalsFuzzy(targetBlock)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return editSession.setBlock(position, targetBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,10 +157,10 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
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()
|
||||
.putInt("X", newLeash.getBlockX())
|
||||
.putInt("Y", newLeash.getBlockY())
|
||||
.putInt("Z", newLeash.getBlockZ())
|
||||
.build()
|
||||
).build());
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class ForestGenerator implements RegionFunction {
|
||||
BlockState block = editSession.getBlock(position);
|
||||
BlockType t = block.getBlockType();
|
||||
|
||||
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
|
||||
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT || t == BlockTypes.PODZOL || t == BlockTypes.COARSE_DIRT) {
|
||||
return treeType.generate(editSession, position.add(0, 1, 0));
|
||||
} else if (t.getMaterial().isReplacedDuringPlacement()) {
|
||||
// since the implementation's tree generators generally don't generate in non-air spots,
|
||||
|
@ -69,6 +69,7 @@ public class BlockMask extends ABlockMask {
|
||||
@Deprecated
|
||||
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
||||
this(extent);
|
||||
checkNotNull(blocks);
|
||||
add(blocks);
|
||||
}
|
||||
|
||||
@ -149,9 +150,8 @@ public class BlockMask extends ABlockMask {
|
||||
*/
|
||||
@Deprecated
|
||||
public void add(Collection<BaseBlock> blocks) {
|
||||
for (BaseBlock block : blocks) {
|
||||
add(block.toBlockState());
|
||||
}
|
||||
checkNotNull(blocks);
|
||||
blocks.forEach(baseBlock -> add(baseBlock.toBlockState()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +235,7 @@ public class BlockMask extends ABlockMask {
|
||||
setType = type;
|
||||
setStates += all.size();
|
||||
setState = type.getDefaultState();
|
||||
} else if (hasAny) {
|
||||
} else {
|
||||
for (BlockState state : all) {
|
||||
if (test(state)) {
|
||||
setStates++;
|
||||
@ -244,8 +244,6 @@ public class BlockMask extends ABlockMask {
|
||||
unsetState = state;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unsetType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,11 +267,7 @@ public class BlockMask extends ABlockMask {
|
||||
}
|
||||
|
||||
if (setTypes == totalTypes - 1) {
|
||||
if (unsetType != null) {
|
||||
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
|
||||
} else {
|
||||
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
|
||||
}
|
||||
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -55,4 +55,5 @@ public class BoundedHeightMask extends AbstractMask {
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ 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
|
||||
|
@ -38,17 +38,6 @@ public interface Mask {
|
||||
*/
|
||||
boolean test(BlockVector3 vector);
|
||||
|
||||
default Filter toFilter(Runnable run) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public void applyBlock(FilterBlock block) {
|
||||
if (test(block)) {
|
||||
run.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default <T extends Filter> DelegateFilter<T> toFilter(T filter) {
|
||||
return new DelegateFilter<T>(filter) {
|
||||
@Override
|
||||
|
@ -37,7 +37,6 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Combines several masks and requires that all masks return true
|
||||
* when a certain position is tested. It serves as a logical AND operation
|
||||
@ -223,6 +222,10 @@ public class MaskIntersection extends AbstractMask {
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (masksArray.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Mask mask : masksArray) {
|
||||
if (!mask.test(vector)) {
|
||||
return false;
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -32,8 +31,8 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public final class Masks {
|
||||
|
||||
protected static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
|
||||
protected static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
|
||||
static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
|
||||
static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
|
||||
|
||||
private Masks() {
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -70,4 +70,5 @@ public class RegionMask extends AbstractMask {
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,16 +66,15 @@ public class ChangeSetExecutor implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
Change change = iterator.next();
|
||||
if (type == Type.UNDO) {
|
||||
while (iterator.hasNext()) {
|
||||
while (iterator.hasNext()) {
|
||||
Change change = iterator.next();
|
||||
if (type == Type.UNDO) {
|
||||
change.undo(context);
|
||||
}
|
||||
} else {
|
||||
while (iterator.hasNext()) {
|
||||
} else {
|
||||
change.redo(context);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
/**
|
||||
* Returns a {@link BiomeType} for a given position.
|
||||
*/
|
||||
public interface BiomePattern {
|
||||
|
||||
/**
|
||||
* Return a {@link BiomeType} for the given position.
|
||||
*
|
||||
* @param position the position
|
||||
* @return a block
|
||||
*/
|
||||
BiomeType apply(BlockVector2 position);
|
||||
}
|
@ -67,4 +67,5 @@ public class BlockPattern extends AbstractPattern {
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
return block;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
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;
|
||||
@ -64,9 +65,10 @@ public class WaterloggedRemover extends AbstractExtentPattern {
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BaseBlock block = getExtent().getFullBlock(position);
|
||||
BlockState newState = remap[block.getOrdinal()];
|
||||
if (newState != null) {
|
||||
return newState.toBaseBlock(block.getNbtData());
|
||||
@SuppressWarnings("unchecked")
|
||||
Property<Object> prop = (Property<Object>) remap[block.getOrdinal()].getBlockType().getPropertyMap().getOrDefault("waterlogged", null);
|
||||
if (prop != null) {
|
||||
return block.with(prop, false);
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
@ -78,9 +78,9 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
|
||||
private final RegionFunction function;
|
||||
private BlockVectorSet queue = new BlockVectorSet();
|
||||
private BlockVectorSet visited = new BlockVectorSet();
|
||||
private BlockVector3[] directions;
|
||||
private BlockVectorSet visited;
|
||||
private BlockVectorSet queue;
|
||||
private int affected = 0;
|
||||
private int currentDepth = 0;
|
||||
private final int maxDepth;
|
||||
@ -98,8 +98,6 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
|
||||
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
|
||||
checkNotNull(function);
|
||||
this.queue = new BlockVectorSet();
|
||||
this.visited = new BlockVectorSet();
|
||||
this.function = function;
|
||||
this.directions = DEFAULT_DIRECTIONS;
|
||||
this.maxDepth = maxDepth;
|
||||
@ -121,6 +119,8 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* unit vectors. An example of a valid direction is
|
||||
* {@code BlockVector3.at(1, 0, 1)}.</p>
|
||||
*
|
||||
* <p>The list of directions can be cleared.</p>
|
||||
*
|
||||
* @return the list of directions
|
||||
*/
|
||||
public Collection<BlockVector3> getDirections() {
|
||||
@ -260,6 +260,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
tmp.clear();
|
||||
tempQueue = tmp;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ public class FlatRegionVisitor implements Operation {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -20,14 +20,12 @@
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -42,17 +40,12 @@ public class RegionVisitor implements Operation {
|
||||
public int affected = 0;
|
||||
public final Iterable<? extends BlockVector3> iterable;
|
||||
|
||||
/**
|
||||
* Deprecated in favor of the other constructors which will preload chunks during iteration
|
||||
*
|
||||
* @param region
|
||||
* @param function
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public RegionVisitor(Region region, RegionFunction function) {
|
||||
this((Iterable<BlockVector3>) region, function);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RegionVisitor(Iterable<BlockVector3> iterable, RegionFunction function) {
|
||||
this.region = iterable instanceof Region ? (Region) iterable : null;
|
||||
this.function = function;
|
||||
@ -75,6 +68,7 @@ public class RegionVisitor implements Operation {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user