mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 04:46:40 +00:00
*
A tribute to Jesse
This commit is contained in:
@ -24,8 +24,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -52,16 +50,12 @@ public interface OutputExtent {
|
||||
* @param block block to set
|
||||
* @return true if the block was successfully set (return value may not be accurate)
|
||||
* @throws WorldEditException thrown on an error
|
||||
* @deprecated Use {@link #setBlock(int, int, int, BlockStateHolder)}
|
||||
* @deprecated It is recommended that you use {@link #setBlock(int, int, int, BlockStateHolder)} in FAWE
|
||||
*/
|
||||
@Deprecated
|
||||
default <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||
return setBlock(position.getX(), position.getY(), position.getZ(), block);
|
||||
}
|
||||
<T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException;
|
||||
|
||||
default <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
return setBlock(MutableBlockVector3.get(x, y, z), block);
|
||||
}
|
||||
<T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException;
|
||||
|
||||
boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException;
|
||||
|
||||
@ -72,13 +66,9 @@ public interface OutputExtent {
|
||||
* @param biome the biome to set to
|
||||
* @return true if the biome was successfully set (return value may not be accurate)
|
||||
*/
|
||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
|
||||
}
|
||||
boolean setBiome(BlockVector2 position, BiomeType biome);
|
||||
|
||||
default boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return setBiome(MutableBlockVector2.get(x, z), biome);
|
||||
}
|
||||
boolean setBiome(int x, int y, int z, BiomeType biome);
|
||||
|
||||
/**
|
||||
* Return an {@link Operation} that should be called to tie up loose ends
|
||||
|
@ -175,6 +175,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
||||
return getExtent().getBlockDistributionWithData(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Operation commit() {
|
||||
return getExtent().commit();
|
||||
@ -271,6 +272,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
||||
return getExtent().setBlock(position, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
return getExtent().setBlock(x, y, z, block);
|
||||
}
|
||||
@ -285,6 +287,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
||||
return getExtent().setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return getExtent().setBiome(x, y, z, biome);
|
||||
}
|
||||
|
@ -25,16 +25,20 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@ -46,12 +50,16 @@ import java.util.Map;
|
||||
* <p>This buffer will not attempt to return results from the buffer when
|
||||
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
|
||||
*/
|
||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern, BiomePattern {
|
||||
|
||||
private final Map<BlockVector3, BaseBlock> buffer = new LinkedHashMap<>();
|
||||
private final Map<BlockVector2, BiomeType> biomeBuffer = new LinkedHashMap<>();
|
||||
private final Mask mask;
|
||||
private final Mask2D biomeMask;
|
||||
private BlockVector3 min = null;
|
||||
private BlockVector2 min2d = null;
|
||||
private BlockVector3 max = null;
|
||||
private BlockVector2 max2d = null;
|
||||
|
||||
/**
|
||||
* Create a new extent buffer that will buffer every change.
|
||||
@ -79,6 +87,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
checkNotNull(delegate);
|
||||
checkNotNull(mask);
|
||||
this.mask = mask;
|
||||
Mask2D bmask = mask.toMask2D();
|
||||
this.biomeMask = bmask == null ? Masks.alwaysTrue2D() : bmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,6 +115,54 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
// Update minimum
|
||||
if (min2d == null) {
|
||||
min2d = position;
|
||||
} else {
|
||||
min2d = min2d.getMinimum(position);
|
||||
}
|
||||
|
||||
// Update maximum
|
||||
if (max2d == null) {
|
||||
max2d = position;
|
||||
} else {
|
||||
max2d = max2d.getMaximum(position);
|
||||
}
|
||||
|
||||
if (biomeMask.test(position)) {
|
||||
biomeBuffer.put(position, biome);
|
||||
return true;
|
||||
} else {
|
||||
return getExtent().setBiome(position, biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
// Update minimum
|
||||
if (min2d == null) {
|
||||
min2d = BlockVector2.at(x, z);
|
||||
} else {
|
||||
min2d = min2d.getMinimum(BlockVector2.at(x,z));
|
||||
}
|
||||
|
||||
// Update maximum
|
||||
if (max2d == null) {
|
||||
max2d = BlockVector2.at(x,z);
|
||||
} else {
|
||||
max2d = max2d.getMaximum(BlockVector2.at(x,z));
|
||||
}
|
||||
|
||||
if (biomeMask.test(BlockVector2.at(x,z))) {
|
||||
biomeBuffer.put(BlockVector2.at(x,z), biome);
|
||||
return true;
|
||||
} else {
|
||||
return getExtent().setBiome(x, y, z, biome);
|
||||
} }
|
||||
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 pos) {
|
||||
BaseBlock block = buffer.get(pos);
|
||||
@ -115,6 +173,16 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType apply(BlockVector2 pos) {
|
||||
BiomeType biome = biomeBuffer.get(pos);
|
||||
if (biome != null) {
|
||||
return biome;
|
||||
} else {
|
||||
return BiomeTypes.OCEAN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a region representation of this buffer.
|
||||
*
|
||||
@ -151,6 +219,10 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return buffer.keySet().iterator();
|
||||
}
|
||||
|
||||
public Iterable<BlockVector2> asFlatRegion() {
|
||||
return biomeBuffer.keySet();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -216,6 +216,7 @@ public class BlockArrayClipboard implements Clipboard, Closeable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||
x -= mx;
|
||||
y -= my;
|
||||
|
@ -19,10 +19,27 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.transform;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.util.Direction.ASCENDING_EAST;
|
||||
import static com.sk89q.worldedit.util.Direction.ASCENDING_NORTH;
|
||||
import static com.sk89q.worldedit.util.Direction.ASCENDING_SOUTH;
|
||||
import static com.sk89q.worldedit.util.Direction.ASCENDING_WEST;
|
||||
import static com.sk89q.worldedit.util.Direction.DOWN;
|
||||
import static com.sk89q.worldedit.util.Direction.EAST;
|
||||
import static com.sk89q.worldedit.util.Direction.Flag;
|
||||
import static com.sk89q.worldedit.util.Direction.NORTH;
|
||||
import static com.sk89q.worldedit.util.Direction.NORTHEAST;
|
||||
import static com.sk89q.worldedit.util.Direction.NORTHWEST;
|
||||
import static com.sk89q.worldedit.util.Direction.SOUTH;
|
||||
import static com.sk89q.worldedit.util.Direction.SOUTHEAST;
|
||||
import static com.sk89q.worldedit.util.Direction.SOUTHWEST;
|
||||
import static com.sk89q.worldedit.util.Direction.UP;
|
||||
import static com.sk89q.worldedit.util.Direction.WEST;
|
||||
import static com.sk89q.worldedit.util.Direction.findClosest;
|
||||
import static com.sk89q.worldedit.util.Direction.values;
|
||||
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -38,21 +55,19 @@ import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import static com.sk89q.worldedit.util.Direction.*;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
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;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Transforms blocks themselves (but not their position) according to a
|
||||
@ -87,11 +102,8 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
|
||||
|
||||
private static long combine(Direction... directions) {
|
||||
long mask = 0;
|
||||
for (Direction dir : directions) {
|
||||
mask = mask | (1L << dir.ordinal());
|
||||
}
|
||||
return mask;
|
||||
return Arrays.stream(directions).mapToLong(dir -> (1L << dir.ordinal()))
|
||||
.reduce(0, (a, b) -> a | b);
|
||||
}
|
||||
|
||||
private static long[] adapt(Direction... dirs) {
|
||||
@ -497,7 +509,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
return super.setBlock(x, y, z, transformInverse(block));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user