geforkt von Mirrors/FastAsyncWorldEdit
Dieser Commit ist enthalten in:
Ursprung
f1e98da01f
Commit
58c6b6278f
@ -257,12 +257,21 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
return c.stream().allMatch(this::contains);
|
for (Object o : c) {
|
||||||
|
if (!contains(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(Collection<? extends BlockVector3> c) {
|
public boolean addAll(Collection<? extends BlockVector3> c) {
|
||||||
return c.stream().map(this::add).reduce(false, (a, b) -> a || b);
|
boolean result = false;
|
||||||
|
for (BlockVector3 v : c) {
|
||||||
|
result |= add(v);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -290,7 +299,11 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
return c.stream().map(this::remove).reduce(false, (a, b) -> a || b);
|
boolean result = false;
|
||||||
|
for (Object o : c) {
|
||||||
|
result |= remove(o);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forEach(BlockVectorSetVisitor visitor) {
|
public void forEach(BlockVectorSetVisitor visitor) {
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.jnbt;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
|
import com.boydti.fawe.object.io.LittleEndianOutputStream;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@ -66,6 +68,15 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use a little endian output stream
|
||||||
|
*/
|
||||||
|
public void setLittleEndian() {
|
||||||
|
if (!(os instanceof LittleEndianOutputStream)) {
|
||||||
|
this.os = new LittleEndianOutputStream((OutputStream) os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a tag.
|
* Writes a tag.
|
||||||
*
|
*
|
||||||
@ -79,11 +90,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
checkNotNull(tag);
|
checkNotNull(tag);
|
||||||
|
|
||||||
int type = NBTUtils.getTypeCode(tag.getClass());
|
int type = NBTUtils.getTypeCode(tag.getClass());
|
||||||
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
|
writeNamedTagName(name, type);
|
||||||
|
|
||||||
os.writeByte(type);
|
|
||||||
os.writeShort(nameBytes.length);
|
|
||||||
os.write(nameBytes);
|
|
||||||
|
|
||||||
if (type == NBTConstants.TYPE_END) {
|
if (type == NBTConstants.TYPE_END) {
|
||||||
throw new IOException("Named TAG_End not permitted.");
|
throw new IOException("Named TAG_End not permitted.");
|
||||||
|
@ -192,20 +192,11 @@ public class BiomeCommands extends MethodCommands {
|
|||||||
Collections.sort(distribution);
|
Collections.sort(distribution);
|
||||||
for (Countable<BiomeType> c : distribution) {
|
for (Countable<BiomeType> c : distribution) {
|
||||||
BiomeData data = biomeRegistry.getData(c.getID());
|
BiomeData data = biomeRegistry.getData(c.getID());
|
||||||
String str;
|
String str = String.format("%-7s (%.3f%%) %s #%d",
|
||||||
if (data == null) {
|
String.valueOf(c.getAmount()),
|
||||||
str = String.format("%-7s (%.3f%%) %s #%d",
|
c.getAmount() / (double) size * 100,
|
||||||
String.valueOf(c.getAmount()),
|
data == null ? "Unknown" : data.getName(),
|
||||||
c.getAmount() / (double) size * 100,
|
c.getID().getInternalId());
|
||||||
"Unknown",
|
|
||||||
c.getID().getInternalId());
|
|
||||||
} else {
|
|
||||||
str = String.format("%-7s (%.3f%%) %s #%d",
|
|
||||||
String.valueOf(c.getAmount()),
|
|
||||||
c.getAmount() / (double) size * 100,
|
|
||||||
data.getName(),
|
|
||||||
c.getID().getInternalId());
|
|
||||||
}
|
|
||||||
player.print(str);
|
player.print(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,10 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
for (int x = ox - range; x <= ox + range; ++x) {
|
for (int x = ox - range; x <= ox + range; ++x) {
|
||||||
for (int z = oz - range; z <= oz + range; ++z) {
|
for (int z = oz - range; z <= oz + range; ++z) {
|
||||||
for (int y = oy + range; y >= oy - range; --y) {
|
for (int y = oy + range; y >= oy - range; --y) {
|
||||||
BlockVector3 pos = BlockVector3.at(x, y, z);
|
if (editSession.getLazyBlock(x, y, z).getBlockType() != initialType) {
|
||||||
if (editSession.getLazyBlock(pos).getBlockType() != initialType) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,11 @@ import com.boydti.fawe.jnbt.anvil.generator.OreGen;
|
|||||||
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
||||||
import com.boydti.fawe.jnbt.anvil.generator.SchemGen;
|
import com.boydti.fawe.jnbt.anvil.generator.SchemGen;
|
||||||
|
|
||||||
|
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -408,4 +410,17 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
default int getMaxY() {
|
default int getMaxY() {
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lazily copy a region
|
||||||
|
*
|
||||||
|
* @param region
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default BlockArrayClipboard lazyCopy(Region region) {
|
||||||
|
WorldCopyClipboard faweClipboard = new WorldCopyClipboard(this, region);
|
||||||
|
BlockArrayClipboard weClipboard = new BlockArrayClipboard(region, faweClipboard);
|
||||||
|
weClipboard.setOrigin(region.getMinimumPoint());
|
||||||
|
return weClipboard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -111,7 +112,7 @@ public interface ClipboardFormat {
|
|||||||
* @param in
|
* @param in
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
default void hold(Player player, URI uri, InputStream in) throws IOException {
|
default URIClipboardHolder hold(Player player, URI uri, InputStream in) throws IOException {
|
||||||
checkNotNull(player);
|
checkNotNull(player);
|
||||||
checkNotNull(uri);
|
checkNotNull(uri);
|
||||||
checkNotNull(in);
|
checkNotNull(in);
|
||||||
@ -125,6 +126,7 @@ public interface ClipboardFormat {
|
|||||||
clipboard = reader.read(player.getUniqueId());
|
clipboard = reader.read(player.getUniqueId());
|
||||||
URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard);
|
URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard);
|
||||||
session.setClipboard(holder);
|
session.setClipboard(holder);
|
||||||
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
default Schematic load(File file) throws IOException {
|
default Schematic load(File file) throws IOException {
|
||||||
|
@ -143,11 +143,10 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
||||||
try {
|
try {
|
||||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
if (block.hasNbtData()) {
|
||||||
if (hasNbt) {
|
CompoundTag nbt = block.getNbtData();
|
||||||
if (block.getNbtData() != null) {
|
if (nbt != null) {
|
||||||
BaseBlock localBlock = (BaseBlock) block;
|
Map<String, Tag> values = nbt.getValue();
|
||||||
Map<String, Tag> values = localBlock.getNbtData().getValue();
|
|
||||||
|
|
||||||
values.remove("id"); // Remove 'id' if it exists. We want 'Id'
|
values.remove("id"); // Remove 'id' if it exists. We want 'Id'
|
||||||
|
|
||||||
@ -164,7 +163,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
z
|
z
|
||||||
}));
|
}));
|
||||||
numTiles[0]++;
|
numTiles[0]++;
|
||||||
tilesOut.writeTagPayload(localBlock.getNbtData());
|
tilesOut.writeTagPayload(block.getNbtData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int ordinal = block.getOrdinal();
|
int ordinal = block.getOrdinal();
|
||||||
|
@ -26,6 +26,7 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockID;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
@ -35,7 +36,13 @@ public class SignCompatibilityHandler implements NBTCompatibilityHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean isAffectedBlock(B block) {
|
public <B extends BlockStateHolder<B>> boolean isAffectedBlock(B block) {
|
||||||
return block.getBlockType() == BlockTypes.SIGN || block.getBlockType() == BlockTypes.WALL_SIGN;
|
switch (block.getBlockType().getInternalId()) {
|
||||||
|
case BlockID.SIGN:
|
||||||
|
case BlockID.WALL_SIGN:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -26,17 +27,23 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a {@link BlockBag} to operations.
|
* Applies a {@link BlockBag} to operations.
|
||||||
*/
|
*/
|
||||||
public class BlockBagExtent extends AbstractDelegateExtent {
|
public class BlockBagExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
private Map<BlockType, Integer> missingBlocks = new HashMap<>();
|
private final boolean mine;
|
||||||
|
private int[] missingBlocks = new int[BlockTypes.size()];
|
||||||
private BlockBag blockBag;
|
private BlockBag blockBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,9 +52,15 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param blockBag the block bag
|
* @param blockBag the block bag
|
||||||
*/
|
*/
|
||||||
public BlockBagExtent(Extent extent, @Nullable BlockBag blockBag) {
|
public BlockBagExtent(Extent extent, @Nonnull BlockBag blockBag) {
|
||||||
|
this(extent, blockBag, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockBagExtent(Extent extent, @Nonnull BlockBag blockBag, boolean mine) {
|
||||||
super(extent);
|
super(extent);
|
||||||
|
checkNotNull(blockBag);
|
||||||
this.blockBag = blockBag;
|
this.blockBag = blockBag;
|
||||||
|
this.mine = mine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,9 +88,15 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
* @return a map of missing blocks
|
* @return a map of missing blocks
|
||||||
*/
|
*/
|
||||||
public Map<BlockType, Integer> popMissing() {
|
public Map<BlockType, Integer> popMissing() {
|
||||||
Map<BlockType, Integer> missingBlocks = this.missingBlocks;
|
HashMap<BlockType, Integer> map = new HashMap<>();
|
||||||
this.missingBlocks = new HashMap<>();
|
for (int i = 0; i < missingBlocks.length; i++) {
|
||||||
return missingBlocks;
|
int count = missingBlocks[i];
|
||||||
|
if (count > 0) {
|
||||||
|
map.put(BlockTypes.get(i), count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Arrays.fill(missingBlocks, 0);
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -95,21 +114,18 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
try {
|
try {
|
||||||
blockBag.fetchPlacedBlock(block.toImmutableState());
|
blockBag.fetchPlacedBlock(block.toImmutableState());
|
||||||
} catch (UnplaceableBlockException e) {
|
} catch (UnplaceableBlockException e) {
|
||||||
return false;
|
throw new FaweException.FaweBlockBagException();
|
||||||
} catch (BlockBagException e) {
|
} catch (BlockBagException e) {
|
||||||
if (!missingBlocks.containsKey(block.getBlockType())) {
|
missingBlocks[block.getBlockType().getInternalId()]++;
|
||||||
missingBlocks.put(block.getBlockType(), 1);
|
throw new FaweException.FaweBlockBagException();
|
||||||
} else {
|
|
||||||
missingBlocks.put(block.getBlockType(), missingBlocks.get(block.getBlockType()) + 1);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mine) {
|
||||||
if (!existing.getBlockType().getMaterial().isAir()) {
|
if (!existing.getBlockType().getMaterial().isAir()) {
|
||||||
try {
|
try {
|
||||||
blockBag.storeDroppedBlock(existing);
|
blockBag.storeDroppedBlock(existing);
|
||||||
} catch (BlockBagException ignored) {
|
} catch (BlockBagException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,17 +85,27 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
|
|
||||||
|
|
||||||
private static long combine(Direction... directions) {
|
private static long combine(Direction... directions) {
|
||||||
return Arrays.stream(directions).mapToLong(dir -> (1L << dir.ordinal())).reduce(0, (a, b) -> a | b);
|
long mask = 0;
|
||||||
|
for (Direction dir : directions) {
|
||||||
|
mask = mask | (1L << dir.ordinal());
|
||||||
|
}
|
||||||
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Direction... dirs) {
|
private static long[] adapt(Direction... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
long[] arr = new long[dirs.length];
|
||||||
Arrays.setAll(arr, i -> 1L << dirs[i].ordinal());
|
for (int i = 0; i < arr.length; i++) {
|
||||||
|
arr[i] = 1L << dirs[i].ordinal();
|
||||||
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Long... dirs) {
|
private static long[] adapt(Long... dirs) {
|
||||||
return Arrays.stream(dirs).mapToLong(dir -> dir).toArray();
|
long[] arr = new long[dirs.length];
|
||||||
|
for (int i = 0; i < arr.length; i++) {
|
||||||
|
arr[i] = dirs[i];
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] getDirections(AbstractProperty property) {
|
private static long[] getDirections(AbstractProperty property) {
|
||||||
@ -209,7 +219,9 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long notIndex(long mask, int... indexes) {
|
private static long notIndex(long mask, int... indexes) {
|
||||||
mask |= Arrays.stream(indexes).mapToLong(index -> (1L << (index + values().length))).reduce(0, (a, b) -> a | b);
|
for (int index : indexes) {
|
||||||
|
mask = mask | (1L << (index + values().length));
|
||||||
|
}
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,8 +433,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
* @return the same block
|
* @return the same block
|
||||||
*/
|
*/
|
||||||
public static <B extends BlockStateHolder<B>> B transform(B block, Transform transform) {
|
public static <B extends BlockStateHolder<B>> B transform(B block, Transform transform) {
|
||||||
checkNotNull(block);
|
// performance critical
|
||||||
checkNotNull(transform);
|
|
||||||
BlockState state = block.toImmutableState();
|
BlockState state = block.toImmutableState();
|
||||||
|
|
||||||
int transformedId = transformState(state, transform);
|
int transformedId = transformState(state, transform);
|
||||||
|
@ -260,11 +260,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int ret = toImmutableState().hashCode() << 3;
|
return getOrdinal();
|
||||||
if (hasNbtData()) {
|
|
||||||
ret += getNbtData().hashCode();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -849,4 +849,8 @@ public final class ItemTypes {
|
|||||||
public static int size() {
|
public static int size() {
|
||||||
return ItemType.REGISTRY.size();
|
return ItemType.REGISTRY.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Collection<ItemType> values() {
|
||||||
|
return ItemType.REGISTRY.values();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren