mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Various debugging and cleaning
This commit is contained in:
parent
a5ee0b197d
commit
cfb6e3bca4
@ -1,8 +1,6 @@
|
|||||||
package com.boydti.fawe;
|
package com.boydti.fawe;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.config.Caption;
|
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||||
@ -31,6 +29,7 @@ import com.sk89q.worldedit.internal.registry.InputParser;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -152,13 +151,12 @@ public class FaweAPI {
|
|||||||
* Remember to commit when you're done!<br>
|
* Remember to commit when you're done!<br>
|
||||||
*
|
*
|
||||||
* @param world The name of the world
|
* @param world The name of the world
|
||||||
* @param autoqueue If it should start dispatching before you enqueue it.
|
* @param autoQueue If it should start dispatching before you enqueue it.
|
||||||
* @return
|
* @return the queue extent
|
||||||
* @see IQueueExtent#enqueue()
|
|
||||||
*/
|
*/
|
||||||
public static IQueueExtent createQueue(World world, boolean autoqueue) {
|
public static IQueueExtent createQueue(World world, boolean autoQueue) {
|
||||||
IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world);
|
IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world);
|
||||||
if (!autoqueue) {
|
if (!autoQueue) {
|
||||||
queue.disableQueue();
|
queue.disableQueue();
|
||||||
}
|
}
|
||||||
return queue;
|
return queue;
|
||||||
@ -189,10 +187,9 @@ public class FaweAPI {
|
|||||||
/**
|
/**
|
||||||
* Just forwards to ClipboardFormat.SCHEMATIC.load(file)
|
* Just forwards to ClipboardFormat.SCHEMATIC.load(file)
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file the file to load
|
||||||
* @return
|
* @return a clipboard containing the schematic
|
||||||
* @see ClipboardFormat
|
* @see ClipboardFormat
|
||||||
* @see Schematic
|
|
||||||
*/
|
*/
|
||||||
public static Clipboard load(File file) throws IOException {
|
public static Clipboard load(File file) throws IOException {
|
||||||
return ClipboardFormats.findByFile(file).load(file);
|
return ClipboardFormats.findByFile(file).load(file);
|
||||||
|
@ -4,11 +4,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.Trimable;
|
import com.boydti.fawe.beta.Trimable;
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.collection.BitArray4096;
|
import com.boydti.fawe.object.collection.BitArray4096;
|
||||||
import com.boydti.fawe.object.collection.CleanableThreadLocal;
|
import com.boydti.fawe.object.collection.CleanableThreadLocal;
|
||||||
@ -18,6 +13,9 @@ import com.boydti.fawe.object.exception.FaweChunkLoadException;
|
|||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.util.IOUtil;
|
import com.boydti.fawe.util.IOUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.sk89q.jnbt.ByteArrayTag;
|
import com.sk89q.jnbt.ByteArrayTag;
|
||||||
import com.sk89q.jnbt.ByteTag;
|
import com.sk89q.jnbt.ByteTag;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -34,6 +32,7 @@ import com.sk89q.jnbt.StringTag;
|
|||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableVector3;
|
import com.sk89q.worldedit.math.MutableVector3;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -192,7 +191,7 @@ public enum FaweCache implements Trimable {
|
|||||||
} else {
|
} else {
|
||||||
pool = cache::get;
|
pool = cache::get;
|
||||||
}
|
}
|
||||||
Pool previous = REGISTERED_POOLS.putIfAbsent(clazz, pool);
|
Pool<T> previous = REGISTERED_POOLS.putIfAbsent(clazz, pool);
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
throw new IllegalStateException("Previous key");
|
throw new IllegalStateException("Previous key");
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package com.boydti.fawe.beta;
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
|
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
|
|
||||||
import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor;
|
import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor;
|
||||||
import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor;
|
import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -68,10 +65,12 @@ public interface IBatchProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int layer = (minY - 15) >> 4; layer < (maxY + 15) >> 4; layer++) {
|
int layer = (minY - 15) >> 4;
|
||||||
|
while (layer < (maxY + 15) >> 4) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
layer++;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,9 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockID;
|
import com.sk89q.worldedit.world.block.BlockID;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -4,13 +4,10 @@ import com.boydti.fawe.FaweCache;
|
|||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.boydti.fawe.object.collection.MemBlockSet;
|
import com.boydti.fawe.object.collection.MemBlockSet;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
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 java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.boydti.fawe.beta.implementation.blocks;
|
package com.boydti.fawe.beta.implementation.blocks;
|
||||||
|
|
||||||
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.beta.IBlocks;
|
import com.boydti.fawe.beta.IBlocks;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
import org.jetbrains.annotations.Range;
|
||||||
|
|
||||||
public abstract class CharBlocks implements IBlocks {
|
public abstract class CharBlocks implements IBlocks {
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(int layer) {
|
public void reset(@Range(from = 0, to = 15) int layer) {
|
||||||
sections[layer] = EMPTY;
|
sections[layer] = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,12 +83,12 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSection(int layer) {
|
public boolean hasSection(@Range(from = 0, to = 15) int layer) {
|
||||||
return sections[layer] == FULL;
|
return sections[layer] == FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] load(int layer) {
|
public char[] load(@Range(from = 0, to = 15) int layer) {
|
||||||
return sections[layer].get(this, layer);
|
return sections[layer].get(this, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +104,7 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void set(int x, int y, int z, char value) {
|
public void set(int x, int y, int z, char value) {
|
||||||
|
Fawe.imp().debug("Setting Block at x:" + x + ", y:" + y + " , z:" + z);
|
||||||
final int layer = y >> 4;
|
final int layer = y >> 4;
|
||||||
final int index = (y & 15) << 8 | z << 4 | x;
|
final int index = (y & 15) << 8 | z << 4 | x;
|
||||||
set(layer, index, value);
|
set(layer, index, value);
|
||||||
@ -111,11 +114,11 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
Section
|
Section
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final char get(int layer, int index) {
|
public final char get(@Range(from = 0, to = 15)int layer, int index) {
|
||||||
return sections[layer].get(this, layer, index);
|
return sections[layer].get(this, layer, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void set(int layer, int index, char value) {
|
public final void set(@Range(from = 0, to = 15) int layer, int index, char value) {
|
||||||
sections[layer].set(this, layer, index, value);
|
sections[layer].set(this, layer, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,16 +250,14 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(ChunkHolder chunk, int x, int y, int z,
|
public boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome) {
|
||||||
BiomeType biome) {
|
|
||||||
chunk.getOrCreateSet();
|
chunk.getOrCreateSet();
|
||||||
chunk.delegate = SET;
|
chunk.delegate = SET;
|
||||||
return chunk.setBiome(x, y, z, biome);
|
return chunk.setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
|
public boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder block) {
|
||||||
BlockStateHolder block) {
|
|
||||||
chunk.getOrCreateSet();
|
chunk.getOrCreateSet();
|
||||||
chunk.delegate = SET;
|
chunk.delegate = SET;
|
||||||
return chunk.setBlock(x, y, z, block);
|
return chunk.setBlock(x, y, z, block);
|
||||||
@ -471,11 +469,9 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
|
|||||||
IChunkGet get(ChunkHolder chunk);
|
IChunkGet get(ChunkHolder chunk);
|
||||||
IChunkSet set(ChunkHolder chunk);
|
IChunkSet set(ChunkHolder chunk);
|
||||||
|
|
||||||
boolean setBiome(ChunkHolder chunk, int x, int y, int z,
|
boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome);
|
||||||
BiomeType biome);
|
|
||||||
|
|
||||||
boolean setBlock(ChunkHolder chunk, int x, int y, int z,
|
boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder holder);
|
||||||
BlockStateHolder holder);
|
|
||||||
|
|
||||||
BiomeType getBiome(ChunkHolder chunk, int x, int y, int z);
|
BiomeType getBiome(ChunkHolder chunk, int x, int y, int z);
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ import java.util.concurrent.Future;
|
|||||||
*/
|
*/
|
||||||
public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk> {
|
public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk> {
|
||||||
|
|
||||||
// // Pool discarded chunks for reuse (can safely be cleared by another thread)
|
// Pool discarded chunks for reuse (can safely be cleared by another thread)
|
||||||
// private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
|
// private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
|
||||||
// Chunks currently being queued / worked on
|
// Chunks currently being queued / worked on
|
||||||
private final Long2ObjectLinkedOpenHashMap<IQueueChunk> chunks = new Long2ObjectLinkedOpenHashMap<>();
|
private final Long2ObjectLinkedOpenHashMap<IQueueChunk> chunks = new Long2ObjectLinkedOpenHashMap<>();
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public class MCAChunk implements IChunk {
|
|||||||
for (Map.Entry<String, String> entry : properties.entrySet()) {
|
for (Map.Entry<String, String> entry : properties.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
String value = entry.getValue();
|
String value = entry.getValue();
|
||||||
Property property = type.getProperty(key);
|
Property<Object> property = type.getProperty(key);
|
||||||
state = state.with(property, property.getValueFor(value));
|
state = state.with(property, property.getValueFor(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,8 +246,8 @@ public class MCAChunk implements IChunk {
|
|||||||
int type = NBTConstants.TYPE_BYTE_ARRAY;
|
int type = NBTConstants.TYPE_BYTE_ARRAY;
|
||||||
out.writeNamedTagName("Biomes", type);
|
out.writeNamedTagName("Biomes", type);
|
||||||
out.writeInt(biomes.length);
|
out.writeInt(biomes.length);
|
||||||
for (int i = 0; i < biomes.length; i++) {
|
for (BiomeType biome : biomes) {
|
||||||
out.write(biomes[i].getLegacyId());
|
out.write(biome.getLegacyId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@ -430,9 +430,7 @@ public class MCAChunk implements IChunk {
|
|||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
tiles.put(x, y, z, tile);
|
tiles.put(x, y, z, tile);
|
||||||
} else {
|
} else {
|
||||||
if (tiles.remove(x, y, z) == null) {
|
return tiles.remove(x, y, z) != null;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -520,18 +518,14 @@ public class MCAChunk implements IChunk {
|
|||||||
@Override
|
@Override
|
||||||
public void setBlocks(int layer, char[] data) {
|
public void setBlocks(int layer, char[] data) {
|
||||||
int offset = layer << 12;
|
int offset = layer << 12;
|
||||||
for (int i = 0; i < 4096; i++) {
|
System.arraycopy(data, 0, blocks, offset, 4096);
|
||||||
blocks[offset + i] = data[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] load(int layer) {
|
public char[] load(int layer) {
|
||||||
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
||||||
int offset = layer << 12;
|
int offset = layer << 12;
|
||||||
for (int i = 0; i < 4096; i++) {
|
System.arraycopy(blocks, offset, tmp, 0, 4096);
|
||||||
tmp[i] = blocks[offset + i];
|
|
||||||
}
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import java.util.concurrent.ForkJoinTask;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
import java.util.zip.Deflater;
|
import java.util.zip.Deflater;
|
||||||
import java.util.zip.Inflater;
|
import java.util.zip.Inflater;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
@ -397,10 +398,8 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<MCAChunk> getCachedChunks() {
|
public List<MCAChunk> getCachedChunks() {
|
||||||
int size = 0;
|
int size = (int) IntStream.range(0, chunks.length)
|
||||||
for (int i = 0; i < chunks.length; i++) {
|
.filter(i -> chunks[i] != null && this.chunkInitialized[i]).count();
|
||||||
if (chunks[i] != null && this.chunkInitialized[i]) size++;
|
|
||||||
}
|
|
||||||
ArrayList<MCAChunk> list = new ArrayList<>(size);
|
ArrayList<MCAChunk> list = new ArrayList<>(size);
|
||||||
for (int i = 0; i < chunks.length; i++) {
|
for (int i = 0; i < chunks.length; i++) {
|
||||||
MCAChunk chunk = chunks[i];
|
MCAChunk chunk = chunks[i];
|
||||||
|
@ -41,7 +41,6 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
|
|||||||
* The locations provided are relative to the clipboard min
|
* The locations provided are relative to the clipboard min
|
||||||
*
|
*
|
||||||
* @param task
|
* @param task
|
||||||
* @param air
|
|
||||||
*/
|
*/
|
||||||
public abstract void streamBiomes(IntValueReader task);
|
public abstract void streamBiomes(IntValueReader task);
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.boydti.fawe.object.collection;
|
package com.boydti.fawe.object.collection;
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class VariableThreadLocal extends CleanableThreadLocal<byte[]> {
|
public class VariableThreadLocal extends CleanableThreadLocal<byte[]> {
|
||||||
public VariableThreadLocal() {
|
public VariableThreadLocal() {
|
||||||
super(() -> null);
|
super(() -> null);
|
||||||
|
@ -5,6 +5,7 @@ import java.io.FilterOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UTFDataFormatException;
|
import java.io.UTFDataFormatException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class LittleEndianOutputStream extends FilterOutputStream implements DataOutput {
|
public class LittleEndianOutputStream extends FilterOutputStream implements DataOutput {
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
* output stream specified by the out argument.
|
* output stream specified by the out argument.
|
||||||
*
|
*
|
||||||
* @param out the underlying output stream.
|
* @param out the underlying output stream.
|
||||||
* @see java.io.FilterOutputStream#out
|
* @see FilterOutputStream#out
|
||||||
*/
|
*/
|
||||||
public LittleEndianOutputStream(OutputStream out) {
|
public LittleEndianOutputStream(OutputStream out) {
|
||||||
super(out);
|
super(out);
|
||||||
@ -27,24 +28,26 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
/**
|
/**
|
||||||
* Writes the specified byte value to the underlying output stream.
|
* Writes the specified byte value to the underlying output stream.
|
||||||
*
|
*
|
||||||
* @param b the <code>byte</code> value to be written.
|
* @param b the {@code byte} value to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void write(int b) throws IOException {
|
public synchronized void write(int b) throws IOException {
|
||||||
out.write(b);
|
out.write(b);
|
||||||
written++;
|
written++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes <code>length</code> bytes from the specified byte array
|
* Writes {@code length} bytes from the specified byte array
|
||||||
* starting at <code>offset</code> to the underlying output stream.
|
* starting at {@code offset} to the underlying output stream.
|
||||||
*
|
*
|
||||||
* @param data the data.
|
* @param data the data.
|
||||||
* @param offset the start offset in the data.
|
* @param offset the start offset in the data.
|
||||||
* @param length the number of bytes to write.
|
* @param length the number of bytes to write.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
public synchronized void write(byte[] data, int offset, int length)
|
@Override
|
||||||
|
public synchronized void write(@NotNull byte[] data, int offset, int length)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
out.write(data, offset, length);
|
out.write(data, offset, length);
|
||||||
written += length;
|
written += length;
|
||||||
@ -52,13 +55,14 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a <code>boolean</code> to the underlying output stream as
|
* Writes a {@code boolean} to the underlying output stream as
|
||||||
* a single byte. If the argument is true, the byte value 1 is written.
|
* a single byte. If the argument is true, the byte value 1 is written.
|
||||||
* If the argument is false, the byte value <code>0</code> in written.
|
* If the argument is false, the byte value {@code 0} in written.
|
||||||
*
|
*
|
||||||
* @param b the <code>boolean</code> value to be written.
|
* @param b the {@code boolean} value to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeBoolean(boolean b) throws IOException {
|
public void writeBoolean(boolean b) throws IOException {
|
||||||
|
|
||||||
if (b) this.write(1);
|
if (b) this.write(1);
|
||||||
@ -67,23 +71,25 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes out a <code>byte</code> to the underlying output stream
|
* Writes out a {@code byte} to the underlying output stream
|
||||||
*
|
*
|
||||||
* @param b the <code>byte</code> value to be written.
|
* @param b the {@code byte} value to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeByte(int b) throws IOException {
|
public void writeByte(int b) throws IOException {
|
||||||
out.write(b);
|
out.write(b);
|
||||||
written++;
|
written++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a two byte <code>short</code> to the underlying output stream in
|
* Writes a two byte {@code short} to the underlying output stream in
|
||||||
* little endian order, low byte first.
|
* little endian order, low byte first.
|
||||||
*
|
*
|
||||||
* @param s the <code>short</code> to be written.
|
* @param s the {@code short} to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeShort(int s) throws IOException {
|
public void writeShort(int s) throws IOException {
|
||||||
|
|
||||||
out.write(s & 0xFF);
|
out.write(s & 0xFF);
|
||||||
@ -93,12 +99,13 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a two byte <code>char</code> to the underlying output stream
|
* Writes a two byte {@code char} to the underlying output stream
|
||||||
* in little endian order, low byte first.
|
* in little endian order, low byte first.
|
||||||
*
|
*
|
||||||
* @param c the <code>char</code> value to be written.
|
* @param c the {@code char} value to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeChar(int c) throws IOException {
|
public void writeChar(int c) throws IOException {
|
||||||
|
|
||||||
out.write(c & 0xFF);
|
out.write(c & 0xFF);
|
||||||
@ -108,12 +115,13 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a four-byte <code>int</code> to the underlying output stream
|
* Writes a four-byte {@code int} to the underlying output stream
|
||||||
* in little endian order, low byte first, high byte last
|
* in little endian order, low byte first, high byte last
|
||||||
*
|
*
|
||||||
* @param i the <code>int</code> to be written.
|
* @param i the {@code int} to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeInt(int i) throws IOException {
|
public void writeInt(int i) throws IOException {
|
||||||
|
|
||||||
out.write(i & 0xFF);
|
out.write(i & 0xFF);
|
||||||
@ -125,12 +133,13 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes an eight-byte <code>long</code> to the underlying output stream
|
* Writes an eight-byte {@code long} to the underlying output stream
|
||||||
* in little endian order, low byte first, high byte last
|
* in little endian order, low byte first, high byte last
|
||||||
*
|
*
|
||||||
* @param l the <code>long</code> to be written.
|
* @param l the {@code long} to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeLong(long l) throws IOException {
|
public void writeLong(long l) throws IOException {
|
||||||
|
|
||||||
out.write((int) l & 0xFF);
|
out.write((int) l & 0xFF);
|
||||||
@ -149,9 +158,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
* Writes a 4 byte Java float to the underlying output stream in
|
* Writes a 4 byte Java float to the underlying output stream in
|
||||||
* little endian order.
|
* little endian order.
|
||||||
*
|
*
|
||||||
* @param f the <code>float</code> value to be written.
|
* @param f the {@code float} value to be written.
|
||||||
* @exception IOException if an I/O error occurs.
|
* @exception IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void writeFloat(float f) throws IOException {
|
public final void writeFloat(float f) throws IOException {
|
||||||
|
|
||||||
this.writeInt(Float.floatToIntBits(f));
|
this.writeInt(Float.floatToIntBits(f));
|
||||||
@ -162,9 +172,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
* Writes an 8 byte Java double to the underlying output stream in
|
* Writes an 8 byte Java double to the underlying output stream in
|
||||||
* little endian order.
|
* little endian order.
|
||||||
*
|
*
|
||||||
* @param d the <code>double</code> value to be written.
|
* @param d the {@code double} value to be written.
|
||||||
* @exception IOException if an I/O error occurs.
|
* @exception IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void writeDouble(double d) throws IOException {
|
public final void writeDouble(double d) throws IOException {
|
||||||
|
|
||||||
this.writeLong(Double.doubleToLongBits(d));
|
this.writeLong(Double.doubleToLongBits(d));
|
||||||
@ -174,13 +185,14 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
/**
|
/**
|
||||||
* Writes a string to the underlying output stream as a sequence of
|
* Writes a string to the underlying output stream as a sequence of
|
||||||
* bytes. Each character is written to the data output stream as
|
* bytes. Each character is written to the data output stream as
|
||||||
* if by the <code>writeByte()</code> method.
|
* if by the {@code writeByte()} method.
|
||||||
*
|
*
|
||||||
* @param s the <code>String</code> value to be written.
|
* @param s the {@code String} value to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
* @see java.io.DataOutputStream#writeByte(int)
|
* @see java.io.DataOutputStream#writeByte(int)
|
||||||
* @see java.io.DataOutputStream#out
|
* @see java.io.DataOutputStream#out
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeBytes(String s) throws IOException {
|
public void writeBytes(String s) throws IOException {
|
||||||
|
|
||||||
int length = s.length();
|
int length = s.length();
|
||||||
@ -193,13 +205,14 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
/**
|
/**
|
||||||
* Writes a string to the underlying output stream as a sequence of
|
* Writes a string to the underlying output stream as a sequence of
|
||||||
* characters. Each character is written to the data output stream as
|
* characters. Each character is written to the data output stream as
|
||||||
* if by the <code>writeChar</code> method.
|
* if by the {@code writeChar} method.
|
||||||
*
|
*
|
||||||
* @param s a <code>String</code> value to be written.
|
* @param s a {@code String} value to be written.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
* @see java.io.DataOutputStream#writeChar(int)
|
* @see java.io.DataOutputStream#writeChar(int)
|
||||||
* @see java.io.DataOutputStream#out
|
* @see java.io.DataOutputStream#out
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeChars(String s) throws IOException {
|
public void writeChars(String s) throws IOException {
|
||||||
|
|
||||||
int length = s.length();
|
int length = s.length();
|
||||||
@ -227,6 +240,7 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
* 65,535 characters.
|
* 65,535 characters.
|
||||||
* @exception IOException if the underlying stream throws an IOException.
|
* @exception IOException if the underlying stream throws an IOException.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeUTF(String s) throws IOException {
|
public void writeUTF(String s) throws IOException {
|
||||||
|
|
||||||
int numchars = s.length();
|
int numchars = s.length();
|
||||||
@ -270,8 +284,7 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
|||||||
* (This class is not thread-safe with respect to this method. It is
|
* (This class is not thread-safe with respect to this method. It is
|
||||||
* possible that this number is temporarily less than the actual
|
* possible that this number is temporarily less than the actual
|
||||||
* number of bytes written.)
|
* number of bytes written.)
|
||||||
* @return the value of the <code>written</code> field.
|
* @return the value of the {@code written} field.
|
||||||
* @see java.io.DataOutputStream#written
|
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
return this.written;
|
return this.written;
|
||||||
|
@ -33,7 +33,6 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class PolyhedralRegion extends AbstractRegion {
|
public class PolyhedralRegion extends AbstractRegion {
|
||||||
@ -69,7 +68,7 @@ public class PolyhedralRegion extends AbstractRegion {
|
|||||||
private BlockVector3 centerAccum = BlockVector3.ZERO;
|
private BlockVector3 centerAccum = BlockVector3.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last triangle that caused a {@link #contains(Vector)} to classify a point as "outside". Used for optimization.
|
* The last triangle that caused a {@link #contains(BlockVector3)} to classify a point as "outside". Used for optimization.
|
||||||
*/
|
*/
|
||||||
private Triangle lastTriangle;
|
private Triangle lastTriangle;
|
||||||
|
|
||||||
|
@ -520,33 +520,6 @@ public class UtilityCommands {
|
|||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int killMatchingEntities(Integer radius, Actor actor, Supplier<EntityFunction> func) throws IncompleteRegionException,
|
|
||||||
MaxChangedBlocksException {
|
|
||||||
List<EntityVisitor> visitors = new ArrayList<>();
|
|
||||||
|
|
||||||
LocalSession session = we.getSessionManager().get(actor);
|
|
||||||
BlockVector3 center = session.getPlacementPosition(actor);
|
|
||||||
EditSession editSession = session.createEditSession(actor);
|
|
||||||
List<? extends Entity> entities;
|
|
||||||
if (radius >= 0) {
|
|
||||||
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
|
|
||||||
entities = editSession.getEntities(region);
|
|
||||||
} else {
|
|
||||||
entities = editSession.getEntities();
|
|
||||||
}
|
|
||||||
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
|
|
||||||
|
|
||||||
int killed = 0;
|
|
||||||
for (EntityVisitor visitor : visitors) {
|
|
||||||
Operations.completeLegacy(visitor);
|
|
||||||
killed += visitor.getAffected();
|
|
||||||
}
|
|
||||||
|
|
||||||
session.remember(editSession);
|
|
||||||
editSession.flushSession();
|
|
||||||
return killed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "extinguish",
|
name = "extinguish",
|
||||||
aliases = { "/ex", "/ext", "/extinguish", "ex", "ext" },
|
aliases = { "/ex", "/ext", "/extinguish", "ex", "ext" },
|
||||||
@ -632,6 +605,55 @@ public class UtilityCommands {
|
|||||||
return killed;
|
return killed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "remove",
|
||||||
|
aliases = { "rem", "rement" },
|
||||||
|
desc = "Remove all entities of a type"
|
||||||
|
)
|
||||||
|
@CommandPermissions("worldedit.remove")
|
||||||
|
@Logging(PLACEMENT)
|
||||||
|
public int remove(Actor actor,
|
||||||
|
@Arg(desc = "The type of entity to remove")
|
||||||
|
EntityRemover remover,
|
||||||
|
@Arg(desc = "The radius of the cuboid to remove from")
|
||||||
|
int radius) throws WorldEditException {
|
||||||
|
if (radius < -1) {
|
||||||
|
actor.printError(TranslatableComponent.of("worldedit.remove.explain-all"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int removed = killMatchingEntities(radius, actor, remover::createFunction);
|
||||||
|
actor.printInfo(TranslatableComponent.of("worldedit.remove.removed", TextComponent.of(removed)));
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int killMatchingEntities(Integer radius, Actor actor, Supplier<EntityFunction> func) throws IncompleteRegionException,
|
||||||
|
MaxChangedBlocksException {
|
||||||
|
List<EntityVisitor> visitors = new ArrayList<>();
|
||||||
|
|
||||||
|
LocalSession session = we.getSessionManager().get(actor);
|
||||||
|
BlockVector3 center = session.getPlacementPosition(actor);
|
||||||
|
EditSession editSession = session.createEditSession(actor);
|
||||||
|
List<? extends Entity> entities;
|
||||||
|
if (radius >= 0) {
|
||||||
|
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
|
||||||
|
entities = editSession.getEntities(region);
|
||||||
|
} else {
|
||||||
|
entities = editSession.getEntities();
|
||||||
|
}
|
||||||
|
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
|
||||||
|
|
||||||
|
int killed = 0;
|
||||||
|
for (EntityVisitor visitor : visitors) {
|
||||||
|
Operations.completeLegacy(visitor);
|
||||||
|
killed += visitor.getAffected();
|
||||||
|
}
|
||||||
|
|
||||||
|
session.remember(editSession);
|
||||||
|
editSession.flushSession();
|
||||||
|
return killed;
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/help",
|
name = "/help",
|
||||||
desc = "Displays help for WorldEdit commands"
|
desc = "Displays help for WorldEdit commands"
|
||||||
@ -648,28 +670,6 @@ public class UtilityCommands {
|
|||||||
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "//help");
|
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "//help");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "remove",
|
|
||||||
aliases = { "rem", "rement" },
|
|
||||||
desc = "Remove all entities of a type"
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.remove")
|
|
||||||
@Logging(PLACEMENT)
|
|
||||||
public int remove(Actor actor,
|
|
||||||
@Arg(desc = "The type of entity to remove")
|
|
||||||
EntityRemover remover,
|
|
||||||
@Arg(desc = "The radius of the cuboid to remove from")
|
|
||||||
int radius) throws WorldEditException {
|
|
||||||
if (radius < -1) {
|
|
||||||
actor.printError(TranslatableComponent.of("worldedit.remove.explain-all"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int removed = killMatchingEntities(radius, actor, remover::createFunction);
|
|
||||||
actor.printInfo(TranslatableComponent.of("worldedit.remove.removed", TextComponent.of(removed)));
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DecimalFormat formatForLocale(Locale locale) {
|
private DecimalFormat formatForLocale(Locale locale) {
|
||||||
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(locale);
|
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(locale);
|
||||||
format.applyPattern("#,##0.#####");
|
format.applyPattern("#,##0.#####");
|
||||||
@ -696,7 +696,7 @@ public class UtilityCommands {
|
|||||||
double result = expression.evaluate(
|
double result = expression.evaluate(
|
||||||
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
||||||
String formatted = Double.isNaN(result) ? "NaN" : formatForLocale(actor.getLocale()).format(result);
|
String formatted = Double.isNaN(result) ? "NaN" : formatForLocale(actor.getLocale()).format(result);
|
||||||
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.GRAY));
|
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
|
||||||
}, (Component) null);
|
}, (Component) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,21 +19,20 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.platform;
|
package com.sk89q.worldedit.extension.platform;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.command.AnvilCommands;
|
import com.boydti.fawe.command.AnvilCommands;
|
||||||
import com.boydti.fawe.command.AnvilCommandsRegistration;
|
import com.boydti.fawe.command.AnvilCommandsRegistration;
|
||||||
import com.boydti.fawe.command.CFICommands;
|
import com.boydti.fawe.command.CFICommands;
|
||||||
import com.boydti.fawe.command.CFICommandsRegistration;
|
import com.boydti.fawe.command.CFICommandsRegistration;
|
||||||
import com.boydti.fawe.config.Caption;
|
import com.boydti.fawe.config.Caption;
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
import com.sk89q.worldedit.command.HistorySubCommands;
|
|
||||||
import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
|
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.object.task.ThrowableSupplier;
|
import com.boydti.fawe.object.task.ThrowableSupplier;
|
||||||
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@ -61,6 +60,8 @@ import com.sk89q.worldedit.command.GenerationCommands;
|
|||||||
import com.sk89q.worldedit.command.GenerationCommandsRegistration;
|
import com.sk89q.worldedit.command.GenerationCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.HistoryCommands;
|
import com.sk89q.worldedit.command.HistoryCommands;
|
||||||
import com.sk89q.worldedit.command.HistoryCommandsRegistration;
|
import com.sk89q.worldedit.command.HistoryCommandsRegistration;
|
||||||
|
import com.sk89q.worldedit.command.HistorySubCommands;
|
||||||
|
import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.MaskCommands;
|
import com.sk89q.worldedit.command.MaskCommands;
|
||||||
import com.sk89q.worldedit.command.MaskCommandsRegistration;
|
import com.sk89q.worldedit.command.MaskCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.NavigationCommands;
|
import com.sk89q.worldedit.command.NavigationCommands;
|
||||||
@ -135,10 +136,26 @@ import com.sk89q.worldedit.session.request.Request;
|
|||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||||
import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
|
import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
|
||||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.logging.FileHandler;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.converter.ArgumentConverter;
|
import org.enginehub.piston.converter.ArgumentConverter;
|
||||||
@ -160,27 +177,10 @@ import org.enginehub.piston.part.SubCommandPart;
|
|||||||
import org.enginehub.piston.suggestion.Suggestion;
|
import org.enginehub.piston.suggestion.Suggestion;
|
||||||
import org.enginehub.piston.util.HelpGenerator;
|
import org.enginehub.piston.util.HelpGenerator;
|
||||||
import org.enginehub.piston.util.ValueProvider;
|
import org.enginehub.piston.util.ValueProvider;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.logging.FileHandler;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the registration and invocation of commands.
|
* Handles the registration and invocation of commands.
|
||||||
@ -333,15 +333,41 @@ public final class PlatformCommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
|
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
|
||||||
CommandManager commandManager,
|
CommandRegistration<CI> registration, CI instance) {
|
||||||
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance) {
|
registerSubCommands(name, aliases, desc, registration, instance, m -> {});
|
||||||
registerSubCommands(name, aliases, desc, commandManager, handlerInstance, m -> {});
|
}
|
||||||
|
|
||||||
|
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
|
||||||
|
CommandRegistration<CI> registration, CI instance,
|
||||||
|
Consumer<CommandManager> additionalConfig) {
|
||||||
|
commandManager.register(name, cmd -> {
|
||||||
|
cmd.aliases(aliases);
|
||||||
|
cmd.description(TextComponent.of(desc));
|
||||||
|
cmd.action(Command.Action.NULL_ACTION);
|
||||||
|
|
||||||
|
CommandManager manager = commandManagerService.newCommandManager();
|
||||||
|
this.registration.register(
|
||||||
|
manager,
|
||||||
|
registration,
|
||||||
|
instance
|
||||||
|
);
|
||||||
|
additionalConfig.accept(manager);
|
||||||
|
|
||||||
|
final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList());
|
||||||
|
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
|
||||||
|
TextComponent.of("Sub-command to run."))
|
||||||
|
.withCommands(subCommands)
|
||||||
|
.required()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
cmd.condition(new SubCommandPermissionCondition.Generator(subCommands).build());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
|
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
|
||||||
CommandManager commandManager,
|
CommandManager commandManager,
|
||||||
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance,
|
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance,
|
||||||
Consumer<CommandManager> additionalConfig) {
|
@NotNull Consumer<CommandManager> additionalConfig) {
|
||||||
commandManager.register(name, cmd -> {
|
commandManager.register(name, cmd -> {
|
||||||
cmd.aliases(aliases);
|
cmd.aliases(aliases);
|
||||||
cmd.description(TextComponent.of(desc));
|
cmd.description(TextComponent.of(desc));
|
||||||
@ -356,7 +382,7 @@ public final class PlatformCommandManager {
|
|||||||
instance
|
instance
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (additionalConfig != null) additionalConfig.accept(manager);
|
additionalConfig.accept(manager);
|
||||||
|
|
||||||
final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList());
|
final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList());
|
||||||
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
|
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
|
||||||
@ -369,26 +395,21 @@ public final class PlatformCommandManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public <CI> void registerSubCommands(String name, List<String> aliases, String desc,
|
|
||||||
CommandRegistration<CI> registration, CI instance) {
|
|
||||||
registerSubCommands(name, aliases, desc, commandManager, c -> c.accept(registration, instance));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerAllCommands() {
|
public void registerAllCommands() {
|
||||||
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
|
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
|
||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
"patterns",
|
"patterns",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
"Patterns determine what blocks are placed",
|
"Patterns determine what blocks are placed",
|
||||||
PatternCommandsRegistration.builder(),
|
PatternCommandsRegistration.builder(),
|
||||||
new PatternCommands()
|
new PatternCommands()
|
||||||
);
|
);
|
||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
"masks",
|
"masks",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
"Masks determine which blocks are placed",
|
"Masks determine which blocks are placed",
|
||||||
MaskCommandsRegistration.builder(),
|
MaskCommandsRegistration.builder(),
|
||||||
new MaskCommands(worldEdit)
|
new MaskCommands(worldEdit)
|
||||||
);
|
);
|
||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
"transforms",
|
"transforms",
|
||||||
@ -486,11 +507,11 @@ public final class PlatformCommandManager {
|
|||||||
history
|
history
|
||||||
);
|
);
|
||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
"/history",
|
"/history",
|
||||||
ImmutableList.of("/frb"),
|
ImmutableList.of("/frb"),
|
||||||
"Manage your history",
|
"Manage your history",
|
||||||
HistorySubCommandsRegistration.builder(),
|
HistorySubCommandsRegistration.builder(),
|
||||||
new HistorySubCommands(history)
|
new HistorySubCommands(history)
|
||||||
);
|
);
|
||||||
this.registration.register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
@ -718,7 +739,7 @@ public final class PlatformCommandManager {
|
|||||||
if (msg != TextComponent.empty()) {
|
if (msg != TextComponent.empty()) {
|
||||||
actor.print(TextComponent.builder("")
|
actor.print(TextComponent.builder("")
|
||||||
.color(TextColor.RED)
|
.color(TextColor.RED)
|
||||||
.append(msg)
|
.append(e.getRichMessage())
|
||||||
.build());
|
.build());
|
||||||
List<String> argList = parseArgs(event.getArguments()).map(Substring::getSubstring).collect(Collectors.toList());
|
List<String> argList = parseArgs(event.getArguments()).map(Substring::getSubstring).collect(Collectors.toList());
|
||||||
printUsage(actor, argList);
|
printUsage(actor, argList);
|
||||||
@ -736,13 +757,16 @@ public final class PlatformCommandManager {
|
|||||||
editSession.flushQueue();
|
editSession.flushQueue();
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
|
|
||||||
long timems = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
if (timems > 1000) {
|
double timeS = (time / 1000.0);
|
||||||
|
int changed = editSession.getBlockChangeCount();
|
||||||
|
double throughput = timeS == 0 ? changed : changed / timeS;
|
||||||
|
if (time > 1000) {
|
||||||
actor.printDebug(TranslatableComponent.of(
|
actor.printDebug(TranslatableComponent.of(
|
||||||
"worldedit.command.time-elapsed",
|
"worldedit.command.time-elapsed",
|
||||||
TextComponent.of(timems + "m"),
|
TextComponent.of(timeS),
|
||||||
TextComponent.of(-1),
|
TextComponent.of(changed),
|
||||||
TextComponent.of(Math.round(-1))
|
TextComponent.of(Math.round(throughput))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Identifiable;
|
import com.sk89q.worldedit.util.Identifiable;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
|
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
@ -168,11 +169,10 @@ public class ConsumeBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an {@link TreeType} from a {@link ArgumentStack}.
|
* Gets an {@link TreeType} from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return a TreeType
|
* @return a TreeType
|
||||||
* @throws ParameterException on error
|
|
||||||
* @throws WorldEditException on error
|
* @throws WorldEditException on error
|
||||||
*/
|
*/
|
||||||
@Binding
|
@Binding
|
||||||
@ -192,11 +192,10 @@ public class ConsumeBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an {@link BiomeType} from a {@link ArgumentStack}.
|
* Gets an {@link BiomeType} from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return a BiomeType
|
* @return a BiomeType
|
||||||
* @throws ParameterException on error
|
|
||||||
* @throws WorldEditException on error
|
* @throws WorldEditException on error
|
||||||
*/
|
*/
|
||||||
@Binding
|
@Binding
|
||||||
|
@ -18,13 +18,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector2;
|
import com.sk89q.worldedit.math.Vector2;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.enginehub.piston.CommandManager;
|
|
||||||
import org.enginehub.piston.annotation.Command;
|
|
||||||
import org.enginehub.piston.inject.InjectedValueStore;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class PrimitiveBindings extends Bindings {
|
public class PrimitiveBindings extends Bindings {
|
||||||
public PrimitiveBindings(WorldEdit worldEdit) {
|
public PrimitiveBindings(WorldEdit worldEdit) {
|
||||||
@ -50,9 +45,9 @@ public class PrimitiveBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an {@link com.sk89q.worldedit.extent.Extent} from a {@link ArgumentStack}.
|
* Gets an {@link Extent} from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return an extent
|
* @return an extent
|
||||||
* @throws InputParseException on other error
|
* @throws InputParseException on other error
|
||||||
*/
|
*/
|
||||||
@ -74,9 +69,9 @@ public class PrimitiveBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a type from a {@link ArgumentStack}.
|
* Gets a type from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return the requested type
|
* @return the requested type
|
||||||
* @throws InputParseException on error
|
* @throws InputParseException on error
|
||||||
*/
|
*/
|
||||||
@ -105,16 +100,15 @@ public class PrimitiveBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a type from a {@link ArgumentStack}.
|
* Gets a type from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return the requested type
|
* @return the requested type
|
||||||
* @throws InputParseException on error
|
* @throws InputParseException on error
|
||||||
*/
|
*/
|
||||||
@Binding
|
@Binding
|
||||||
public Vector3 getVector3(String argument) {
|
public Vector3 getVector3(String argument) {
|
||||||
String radiusString = argument;
|
String[] radii = argument.split(",");
|
||||||
String[] radii = radiusString.split(",");
|
|
||||||
final double radiusX, radiusY, radiusZ;
|
final double radiusX, radiusY, radiusZ;
|
||||||
switch (radii.length) {
|
switch (radii.length) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -135,9 +129,9 @@ public class PrimitiveBindings extends Bindings {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a type from a {@link ArgumentStack}.
|
* Gets a type from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return the requested type
|
* @return the requested type
|
||||||
* @throws InputParseException on error
|
* @throws InputParseException on error
|
||||||
*/
|
*/
|
||||||
@ -163,9 +157,9 @@ public class PrimitiveBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a type from a {@link ArgumentStack}.
|
* Gets a type from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return the requested type
|
* @return the requested type
|
||||||
* @throws InputParseException on error
|
* @throws InputParseException on error
|
||||||
*/
|
*/
|
||||||
@ -193,16 +187,15 @@ public class PrimitiveBindings extends Bindings {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a type from a {@link ArgumentStack}.
|
* Gets a type from a {@link Binding}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param argument the context
|
||||||
* @return the requested type
|
* @return the requested type
|
||||||
* @throws InputParseException on error
|
* @throws InputParseException on error
|
||||||
*/
|
*/
|
||||||
@Binding
|
@Binding
|
||||||
public BlockVector2 getBlockVector2(String argument) {
|
public BlockVector2 getBlockVector2(String argument) {
|
||||||
String radiusString = argument;
|
String[] radii = argument.split(",");
|
||||||
String[] radii = radiusString.split(",");
|
|
||||||
final double radiusX, radiusZ;
|
final double radiusX, radiusZ;
|
||||||
switch (radii.length) {
|
switch (radii.length) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -69,7 +69,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
|||||||
private BlockVector3 centerAccum = BlockVector3.ZERO;
|
private BlockVector3 centerAccum = BlockVector3.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last triangle that caused a {@link #contains(Vector3)} to classify a point as "outside". Used for optimization.
|
* The last triangle that caused a {@link #contains(BlockVector3)} to classify a point as "outside". Used for optimization.
|
||||||
*/
|
*/
|
||||||
private Triangle lastTriangle;
|
private Triangle lastTriangle;
|
||||||
|
|
||||||
|
@ -49,10 +49,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||||
|
|
||||||
|
|
||||||
private boolean useOldIterator;
|
|
||||||
private int minX, minY, minZ, maxX, maxY, maxZ;
|
private int minX, minY, minZ, maxX, maxY, maxZ;
|
||||||
private BlockVector3 min;
|
|
||||||
private BlockVector3 max;
|
|
||||||
private BlockVector3 pos1;
|
private BlockVector3 pos1;
|
||||||
private BlockVector3 pos2;
|
private BlockVector3 pos2;
|
||||||
|
|
||||||
@ -82,10 +79,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
recalculate();
|
recalculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseOldIterator(boolean useOldIterator) {
|
|
||||||
this.useOldIterator = useOldIterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the first cuboid-defining corner.
|
* Get the first cuboid-defining corner.
|
||||||
*
|
*
|
||||||
@ -139,8 +132,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
maxX = Math.max(pos1.getX(), pos2.getX());
|
maxX = Math.max(pos1.getX(), pos2.getX());
|
||||||
maxY = Math.max(pos1.getY(), pos2.getY());
|
maxY = Math.max(pos1.getY(), pos2.getY());
|
||||||
maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
||||||
this.min = BlockVector3.at(minX, minY, minZ);
|
|
||||||
this.max = BlockVector3.at(maxX, maxY, maxZ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,12 +179,22 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return min;
|
return pos1.getMinimum(pos2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return max;
|
return pos1.getMaximum(pos2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinimumY() {
|
||||||
|
return minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaximumY() {
|
||||||
|
return maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -448,7 +449,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<BlockVector3> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9 || useOldIterator) {
|
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9) {
|
||||||
return iterator_old();
|
return iterator_old();
|
||||||
}
|
}
|
||||||
return new Iterator<BlockVector3>() {
|
return new Iterator<BlockVector3>() {
|
||||||
@ -644,16 +645,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return new CuboidRegion(origin.subtract(size), origin.add(size));
|
return new CuboidRegion(origin.subtract(size), origin.add(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMinimumY() {
|
|
||||||
return minY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaximumY() {
|
|
||||||
return maxY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinimumX() {
|
public int getMinimumX() {
|
||||||
return minX;
|
return minX;
|
||||||
}
|
}
|
||||||
@ -724,7 +715,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
trimNBT(set, this::contains);
|
trimNBT(set, this::contains);
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
else if (tx >= minX && bx <= maxX && tz >= minZ && bz <= maxZ) {
|
if (tx >= minX && bx <= maxX && tz >= minZ && bz <= maxZ) {
|
||||||
trimY(set, minY, maxY);
|
trimY(set, minY, maxY);
|
||||||
final int lowerX = Math.max(0, minX - bx);
|
final int lowerX = Math.max(0, minX - bx);
|
||||||
final int upperX = Math.min(15, 15 + maxX - tx);
|
final int upperX = Math.min(15, 15 + maxX - tx);
|
||||||
@ -781,9 +772,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
trimNBT(set, this::contains);
|
trimNBT(set, this::contains);
|
||||||
return set;
|
return set;
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,15 +14,14 @@ package net.jpountz.lz4;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
|
|
||||||
import static net.jpountz.util.ByteBufferUtils.checkNotReadOnly;
|
import static net.jpountz.util.ByteBufferUtils.checkNotReadOnly;
|
||||||
import static net.jpountz.util.ByteBufferUtils.checkRange;
|
import static net.jpountz.util.ByteBufferUtils.checkRange;
|
||||||
import static net.jpountz.util.SafeUtils.checkRange;
|
import static net.jpountz.util.SafeUtils.checkRange;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fast {@link LZ4FastCompressor}s implemented with JNI bindings to the original C
|
* Fast {@link LZ4Compressor} implemented with JNI bindings to the original C
|
||||||
* implementation of LZ4.
|
* implementation of LZ4.
|
||||||
*/
|
*/
|
||||||
final class LZ4JNICompressor extends LZ4Compressor {
|
final class LZ4JNICompressor extends LZ4Compressor {
|
||||||
|
Loading…
Reference in New Issue
Block a user