mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Various minor
refactor some region dependencies swithc masking extent to a filter (so it can be parallelized) Some unfinished refactoring of the filters remove piston messages from strings.json
This commit is contained in:
parent
a36778794b
commit
6ddeb2ebf5
@ -56,8 +56,7 @@ dependencies {
|
|||||||
"implementation"("org.inventivetalent:mapmanager:1.7.3-SNAPSHOT") { isTransitive = false }
|
"implementation"("org.inventivetalent:mapmanager:1.7.3-SNAPSHOT") { isTransitive = false }
|
||||||
"implementation"("org.inventivetalent:mapmanager:1.7.3-SNAPSHOT") { isTransitive = false }
|
"implementation"("org.inventivetalent:mapmanager:1.7.3-SNAPSHOT") { isTransitive = false }
|
||||||
|
|
||||||
"implementation"("com.massivecraft:factions:2.8.0") { isTransitive = false }
|
"implementation"("com.massivecraft:Factions:1.6.9.5-U0.2.1-SNAPSHOT") { isTransitive = false }
|
||||||
"implementation"("com.drtshock:factions:1.6.9.5") { isTransitive = false }
|
|
||||||
"implementation"("com.github.TechFortress:GriefPrevention:16.12.0") { isTransitive = false }
|
"implementation"("com.github.TechFortress:GriefPrevention:16.12.0") { isTransitive = false }
|
||||||
"implementation"("com.massivecraft:mcore:7.0.1") { isTransitive = false }
|
"implementation"("com.massivecraft:mcore:7.0.1") { isTransitive = false }
|
||||||
"implementation"("net.jzx7:regios:5.9.9") { isTransitive = false }
|
"implementation"("net.jzx7:regios:5.9.9") { isTransitive = false }
|
||||||
|
@ -13,7 +13,6 @@ import com.boydti.fawe.bukkit.listener.ChunkListener_8;
|
|||||||
import com.boydti.fawe.bukkit.listener.ChunkListener_9;
|
import com.boydti.fawe.bukkit.listener.ChunkListener_9;
|
||||||
import com.boydti.fawe.bukkit.listener.RenderListener;
|
import com.boydti.fawe.bukkit.listener.RenderListener;
|
||||||
import com.boydti.fawe.bukkit.regions.ASkyBlockHook;
|
import com.boydti.fawe.bukkit.regions.ASkyBlockHook;
|
||||||
import com.boydti.fawe.bukkit.regions.FactionsFeature;
|
|
||||||
import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature;
|
import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature;
|
||||||
import com.boydti.fawe.bukkit.regions.FreeBuildRegion;
|
import com.boydti.fawe.bukkit.regions.FreeBuildRegion;
|
||||||
import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
|
import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
|
||||||
@ -269,14 +268,9 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions");
|
final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions");
|
||||||
if (factionsPlugin != null && factionsPlugin.isEnabled()) {
|
if (factionsPlugin != null && factionsPlugin.isEnabled()) {
|
||||||
try {
|
try {
|
||||||
managers.add(new FactionsFeature(factionsPlugin));
|
managers.add(new FactionsUUIDFeature(factionsPlugin, this));
|
||||||
log.debug("Attempting to use plugin 'Factions'");
|
log.debug("Attempting to use plugin 'FactionsUUID'");
|
||||||
} catch (Throwable e) {
|
} catch (Throwable ignored) {
|
||||||
try {
|
|
||||||
managers.add(new FactionsUUIDFeature(factionsPlugin, this));
|
|
||||||
log.debug("Attempting to use plugin 'FactionsUUID'");
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Plugin residencePlugin = Bukkit.getServer().getPluginManager().getPlugin("Residence");
|
final Plugin residencePlugin = Bukkit.getServer().getPluginManager().getPlugin("Residence");
|
||||||
|
@ -94,7 +94,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTag(int x, int y, int z) {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
||||||
if (tileEntity == null) {
|
if (tileEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -101,7 +101,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTag(int x, int y, int z) {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
||||||
if (tileEntity == null) {
|
if (tileEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
package com.boydti.fawe.bukkit.regions;
|
|
||||||
|
|
||||||
import com.boydti.fawe.regions.FaweMask;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class FactionsFeature extends BukkitMaskManager implements Listener {
|
|
||||||
|
|
||||||
public FactionsFeature(final Plugin factionsPlugin) {
|
|
||||||
super(factionsPlugin.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) {
|
|
||||||
final Player player = BukkitAdapter.adapt(p);
|
|
||||||
final Location loc = player.getLocation();
|
|
||||||
final PS ps = PS.valueOf(loc);
|
|
||||||
final Faction fac = BoardColl.get().getFactionAt(ps);
|
|
||||||
if (fac != null) {
|
|
||||||
if (type == MaskType.OWNER) {
|
|
||||||
MPlayer leader = fac.getLeader();
|
|
||||||
if (leader != null && p.getUniqueId().equals(leader.getUuid())) {
|
|
||||||
final Chunk chunk = loc.getChunk();
|
|
||||||
final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
|
|
||||||
final BlockVector3 pos2 = BlockVector3
|
|
||||||
.at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
|
||||||
return new FaweMask(pos1, pos2);
|
|
||||||
}
|
|
||||||
} else if (fac.getOnlinePlayers().contains(player)) {
|
|
||||||
if (!fac.getComparisonName().equals("wilderness")) {
|
|
||||||
final Chunk chunk = loc.getChunk();
|
|
||||||
final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
|
|
||||||
final BlockVector3 pos2 = BlockVector3.at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
|
||||||
return new FaweMask(pos1, pos2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,6 +4,10 @@ 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.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;
|
||||||
@ -48,6 +52,7 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public enum FaweCache implements Trimable {
|
public enum FaweCache implements Trimable {
|
||||||
@ -194,6 +199,24 @@ public enum FaweCache implements Trimable {
|
|||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T, V> LoadingCache<T, V> createCache(Supplier<V> withInitial) {
|
||||||
|
return CacheBuilder.newBuilder().build(new CacheLoader<T, V>() {
|
||||||
|
@Override
|
||||||
|
public V load(T key) {
|
||||||
|
return withInitial.get();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T, V> LoadingCache<T, V> createCache(Function<T, V> withInitial) {
|
||||||
|
return CacheBuilder.newBuilder().build(new CacheLoader<T, V>() {
|
||||||
|
@Override
|
||||||
|
public V load(T key) {
|
||||||
|
return withInitial.apply(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exceptions
|
Exceptions
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +51,7 @@ public class CombinedBlocks implements IBlocks {
|
|||||||
public char[] load(int layer) {
|
public char[] load(int layer) {
|
||||||
if (primary.hasSection(layer)) {
|
if (primary.hasSection(layer)) {
|
||||||
char[] blocks = primary.load(layer);
|
char[] blocks = primary.load(layer);
|
||||||
if (secondary.hasSection(layer)) {
|
if (secondary.hasSection(layer) && primary != secondary) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < 4096; i++) {
|
for (; i < 4096; i++) {
|
||||||
if (blocks[i] == 0) {
|
if (blocks[i] == 0) {
|
||||||
@ -75,42 +75,55 @@ public class CombinedBlocks implements IBlocks {
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
BlockState block = primary.getBlock(x, y, z);
|
BlockState block = primary.getBlock(x, y, z);
|
||||||
if (block == null) {
|
if (block.getBlockType() == BlockTypes.__RESERVED__) {
|
||||||
return secondary.getBlock(x, y, z);
|
return secondary.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<BlockVector3, CompoundTag> getTiles() {
|
public Map<BlockVector3, CompoundTag> getTiles() {
|
||||||
Map<BlockVector3, CompoundTag> tiles = primary.getTiles();
|
Map<BlockVector3, CompoundTag> tiles = primary.getTiles();
|
||||||
if (tiles.isEmpty()) {
|
if (primary != secondary) {
|
||||||
return secondary.getTiles();
|
if (tiles.isEmpty()) {
|
||||||
}
|
return secondary.getTiles();
|
||||||
Map<BlockVector3, CompoundTag> otherTiles = secondary.getTiles();
|
}
|
||||||
if (!otherTiles.isEmpty()) {
|
Map<BlockVector3, CompoundTag> otherTiles = secondary.getTiles();
|
||||||
HashMap<BlockVector3, CompoundTag> copy = null;
|
if (!otherTiles.isEmpty()) {
|
||||||
for (Map.Entry<BlockVector3, CompoundTag> entry : otherTiles.entrySet()) {
|
HashMap<BlockVector3, CompoundTag> copy = null;
|
||||||
BlockVector3 pos = entry.getKey();
|
for (Map.Entry<BlockVector3, CompoundTag> entry : otherTiles.entrySet()) {
|
||||||
BlockState block = primary.getBlock(pos.getX(), pos.getY(), pos.getZ());
|
BlockVector3 pos = entry.getKey();
|
||||||
if (block.getBlockType() == BlockTypes.__RESERVED__) {
|
BlockState block = primary.getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||||
if (copy == null) copy = new HashMap<>(tiles);
|
if (block.getBlockType() == BlockTypes.__RESERVED__) {
|
||||||
copy.put(pos, entry.getValue());
|
if (copy == null) copy = new HashMap<>(tiles);
|
||||||
}
|
copy.put(pos, entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (copy != null) return copy;
|
||||||
}
|
}
|
||||||
if (copy != null) return copy;
|
|
||||||
}
|
}
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
|
CompoundTag tile = primary.getTile(x, y, z);
|
||||||
|
if (tile != null) {
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
return secondary.getTile(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<CompoundTag> getEntities() {
|
public Set<CompoundTag> getEntities() {
|
||||||
Set<CompoundTag> ents1 = primary.getEntities();
|
Set<CompoundTag> joined = primary.getEntities();
|
||||||
Set<CompoundTag> ents2 = secondary.getEntities();
|
if (primary != secondary) {
|
||||||
if (ents1.isEmpty()) return ents2;
|
Set<CompoundTag> ents2 = secondary.getEntities();
|
||||||
if (ents2.isEmpty()) return ents1;
|
if (joined.isEmpty()) return ents2;
|
||||||
HashSet<CompoundTag> joined = new HashSet<>(ents1);
|
if (ents2.isEmpty()) return joined;
|
||||||
joined.addAll(ents2);
|
joined = new HashSet<>(joined);
|
||||||
|
joined.addAll(ents2);
|
||||||
|
}
|
||||||
return joined;
|
return joined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.beta;
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
|
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
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;
|
||||||
|
@ -31,6 +31,8 @@ public interface IBlocks extends Trimable {
|
|||||||
|
|
||||||
Map<BlockVector3, CompoundTag> getTiles();
|
Map<BlockVector3, CompoundTag> getTiles();
|
||||||
|
|
||||||
|
CompoundTag getTile(int x, int y, int z);
|
||||||
|
|
||||||
Set<CompoundTag> getEntities();
|
Set<CompoundTag> getEntities();
|
||||||
|
|
||||||
BiomeType getBiomeType(int x, int z);
|
BiomeType getBiomeType(int x, int z);
|
||||||
|
@ -90,7 +90,7 @@ public interface IChunk extends Trimable, IChunkGet, IChunkSet {
|
|||||||
BaseBlock getFullBlock(int x, int y, int z);
|
BaseBlock getFullBlock(int x, int y, int z);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
CompoundTag getTag(int x, int y, int z);
|
CompoundTag getTile(int x, int y, int z);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default IChunk reset() {
|
default IChunk reset() {
|
||||||
|
@ -26,9 +26,6 @@ public interface IChunkGet extends IBlocks, Trimable, InputExtent, ITileInput {
|
|||||||
@Override
|
@Override
|
||||||
BlockState getBlock(int x, int y, int z);
|
BlockState getBlock(int x, int y, int z);
|
||||||
|
|
||||||
@Override
|
|
||||||
CompoundTag getTag(int x, int y, int z);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Map<BlockVector3, CompoundTag> getTiles();
|
Map<BlockVector3, CompoundTag> getTiles();
|
||||||
|
|
||||||
|
@ -54,6 +54,11 @@ public interface IDelegateChunk<U extends IQueueChunk> extends IQueueChunk {
|
|||||||
// getParent().flood(flood, mask, block);
|
// getParent().flood(flood, mask, block);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default CompoundTag getTile(int x, int y, int z) {
|
||||||
|
return getParent().getTile(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean setTile(int x, int y, int z, CompoundTag tag) {
|
default boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
return getParent().setTile(x, y, z, tag);
|
return getParent().setTile(x, y, z, tag);
|
||||||
|
@ -3,5 +3,5 @@ package com.boydti.fawe.beta;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
|
||||||
public interface ITileInput {
|
public interface ITileInput {
|
||||||
CompoundTag getTag(int x, int y, int z);
|
CompoundTag getTile(int x, int y, int z);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ 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.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -26,6 +27,11 @@ public class BitSetBlocks implements IChunkSet {
|
|||||||
this.blockState = blockState;
|
this.blockState = blockState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasSection(int layer) {
|
||||||
|
return row.rows[layer] != MemBlockSet.NULL_ROW_Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
@ -122,12 +128,17 @@ public class BitSetBlocks implements IChunkSet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<BlockVector3, CompoundTag> getTiles() {
|
public Map<BlockVector3, CompoundTag> getTiles() {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<CompoundTag> getEntities() {
|
public Set<CompoundTag> getEntities() {
|
||||||
return null;
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -135,11 +146,6 @@ public class BitSetBlocks implements IChunkSet {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasSection(int layer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChunkSet reset() {
|
public IChunkSet reset() {
|
||||||
row.reset();
|
row.reset();
|
||||||
|
@ -55,6 +55,11 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
|||||||
return tiles == null ? Collections.emptyMap() : tiles;
|
return tiles == null ? Collections.emptyMap() : tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
|
return tiles == null ? null : tiles.get(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<CompoundTag> getEntities() {
|
public Set<CompoundTag> getEntities() {
|
||||||
return entities == null ? Collections.emptySet() : entities;
|
return entities == null ? Collections.emptySet() : entities;
|
||||||
|
@ -42,7 +42,7 @@ public class FallbackChunkGet implements IChunkGet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTag(int x, int y, int z) {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
return extent.getFullBlock(bx + x, y, bz + z).getNbtData();
|
return extent.getFullBlock(bx + x, y, bz + z).getNbtData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ public enum NullChunkGet implements IChunkGet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTag(int x, int y, int z) {
|
public Map<BlockVector3, CompoundTag> getTiles() {
|
||||||
return null;
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<BlockVector3, CompoundTag> getTiles() {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
return Collections.emptyMap();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.boydti.fawe.beta.implementation.chunk;
|
package com.boydti.fawe.beta.implementation.chunk;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.CombinedBlocks;
|
|
||||||
import com.boydti.fawe.beta.IBlocks;
|
|
||||||
import com.boydti.fawe.beta.IQueueChunk;
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
||||||
import com.boydti.fawe.beta.Filter;
|
import com.boydti.fawe.beta.Filter;
|
||||||
@ -65,6 +63,11 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
|
|||||||
return delegate.set(this).setTile(x, y, z, tag);
|
return delegate.set(this).setTile(x, y, z, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
|
return delegate.set(this).getTile(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEntity(CompoundTag tag) {
|
public void setEntity(CompoundTag tag) {
|
||||||
delegate.set(this).setEntity(tag);
|
delegate.set(this).setEntity(tag);
|
||||||
@ -316,18 +319,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
|
|||||||
final IChunkGet get = getOrCreateGet();
|
final IChunkGet get = getOrCreateGet();
|
||||||
final IChunkSet set = getOrCreateSet();
|
final IChunkSet set = getOrCreateSet();
|
||||||
try {
|
try {
|
||||||
block = block.init(chunkX, chunkZ, get);
|
block.filter(this, get, set, filter, region, full);
|
||||||
if (region != null) {
|
|
||||||
region.filter(this, filter, block, get, set, full);
|
|
||||||
} else {
|
|
||||||
for (int layer = 0; layer < 16; layer++) {
|
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(this, layer)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
block.init(get, set, layer);
|
|
||||||
block.filter(filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
filter.finishChunk(this);
|
filter.finishChunk(this);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,11 @@ public enum NullChunk implements IQueueChunk {
|
|||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<CompoundTag> getEntities() {
|
public Set<CompoundTag> getEntities() {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
|
@ -2,11 +2,14 @@ package com.boydti.fawe.beta.implementation.filter.block;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
|
||||||
public abstract class SimpleFilterBlock extends FilterBlock {
|
/**
|
||||||
|
* Filter block with an extent
|
||||||
|
*/
|
||||||
|
public abstract class AbstractExtentFilterBlock extends FilterBlock {
|
||||||
|
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
|
|
||||||
public SimpleFilterBlock(Extent extent) {
|
public AbstractExtentFilterBlock(Extent extent) {
|
||||||
this.extent = extent;
|
this.extent = extent;
|
||||||
}
|
}
|
||||||
|
|
@ -8,12 +8,11 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
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.BlockTypes;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ArrayFilterBlock extends SimpleFilterBlock {
|
public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
||||||
|
|
||||||
private final char[] blocks;
|
private final char[] blocks;
|
||||||
private final byte[] heights;
|
private final byte[] heights;
|
||||||
@ -22,6 +21,7 @@ public class ArrayFilterBlock extends SimpleFilterBlock {
|
|||||||
private int x, z, index;
|
private int x, z, index;
|
||||||
private char ordinal;
|
private char ordinal;
|
||||||
|
|
||||||
|
// TODO use in CFI
|
||||||
public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length,
|
public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length,
|
||||||
int yOffset) {
|
int yOffset) {
|
||||||
super(extent);
|
super(extent);
|
||||||
|
@ -6,9 +6,9 @@ import com.boydti.fawe.FaweCache;
|
|||||||
import com.boydti.fawe.beta.Filter;
|
import com.boydti.fawe.beta.Filter;
|
||||||
import com.boydti.fawe.beta.FilterBlockMask;
|
import com.boydti.fawe.beta.FilterBlockMask;
|
||||||
import com.boydti.fawe.beta.Flood;
|
import com.boydti.fawe.beta.Flood;
|
||||||
|
import com.boydti.fawe.beta.IBlocks;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
|
||||||
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -38,6 +38,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
block.initSet().set(block, value);
|
block.initSet().set(block, value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private CharGetBlocks get;
|
private CharGetBlocks get;
|
||||||
private IChunkSet set;
|
private IChunkSet set;
|
||||||
private char[] getArr;
|
private char[] getArr;
|
||||||
@ -47,13 +48,12 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
// local
|
// local
|
||||||
private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ;
|
private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ;
|
||||||
|
|
||||||
public CharFilterBlock(IQueueExtent queueExtent) {
|
public CharFilterBlock(Extent extent) {
|
||||||
super(queueExtent);
|
super(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final ChunkFilterBlock init(int chunkX, int chunkZ, IChunkGet chunk) {
|
public final ChunkFilterBlock initChunk(int chunkX, int chunkZ) {
|
||||||
this.get = (CharGetBlocks) chunk;
|
|
||||||
this.chunkX = chunkX;
|
this.chunkX = chunkX;
|
||||||
this.chunkZ = chunkZ;
|
this.chunkZ = chunkZ;
|
||||||
this.xx = chunkX << 4;
|
this.xx = chunkX << 4;
|
||||||
@ -61,12 +61,34 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) {
|
||||||
|
this.get = (CharGetBlocks) iget;
|
||||||
|
this.layer = layer;
|
||||||
|
final IBlocks get = (CharGetBlocks) iget;
|
||||||
|
if (!get.hasSection(layer)) {
|
||||||
|
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
|
||||||
|
} else {
|
||||||
|
getArr = get.load(layer);
|
||||||
|
}
|
||||||
|
this.set = iset;
|
||||||
|
if (set.hasSection(layer)) {
|
||||||
|
setArr = set.load(layer);
|
||||||
|
delegate = FULL;
|
||||||
|
} else {
|
||||||
|
delegate = NULL;
|
||||||
|
setArr = null;
|
||||||
|
}
|
||||||
|
this.yy = layer << 4;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flood(IChunkGet iget, IChunkSet iset, int layer, Flood flood,
|
public void flood(IChunkGet iget, IChunkSet iset, int layer, Flood flood,
|
||||||
FilterBlockMask mask) {
|
FilterBlockMask mask) {
|
||||||
final int maxDepth = flood.getMaxDepth();
|
final int maxDepth = flood.getMaxDepth();
|
||||||
final boolean checkDepth = maxDepth < Character.MAX_VALUE;
|
final boolean checkDepth = maxDepth < Character.MAX_VALUE;
|
||||||
if (init(iget, iset, layer) != null) { // TODO replace with hasSection
|
if (initLayer(iget, iset, layer) != null) { // TODO replace with hasSection
|
||||||
while ((index = flood.poll()) != -1) {
|
while ((index = flood.poll()) != -1) {
|
||||||
x = index & 15;
|
x = index & 15;
|
||||||
z = index >> 4 & 15;
|
z = index >> 4 & 15;
|
||||||
@ -85,27 +107,6 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final ChunkFilterBlock init(IChunkGet iget, IChunkSet iset, int layer) {
|
|
||||||
this.layer = layer;
|
|
||||||
final CharGetBlocks get = (CharGetBlocks) iget;
|
|
||||||
if (!get.hasSection(layer)) {
|
|
||||||
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
|
|
||||||
} else {
|
|
||||||
getArr = get.sections[layer].get(get, layer);
|
|
||||||
}
|
|
||||||
this.set = iset;
|
|
||||||
if (set.hasSection(layer)) {
|
|
||||||
setArr = set.load(layer);
|
|
||||||
delegate = FULL;
|
|
||||||
} else {
|
|
||||||
delegate = NULL;
|
|
||||||
setArr = null;
|
|
||||||
}
|
|
||||||
this.yy = layer << 4;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(Filter filter, int x, int y, int z) {
|
public void filter(Filter filter, int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@ -247,7 +248,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
final BlockState state = getBlock();
|
final BlockState state = getBlock();
|
||||||
final BlockMaterial material = state.getMaterial();
|
final BlockMaterial material = state.getMaterial();
|
||||||
if (material.hasContainer()) {
|
if (material.hasContainer()) {
|
||||||
final CompoundTag tag = get.getTag(x, y + yy, z);
|
final CompoundTag tag = get.getTile(x, y + yy, z);
|
||||||
return state.toBaseBlock(tag);
|
return state.toBaseBlock(tag);
|
||||||
}
|
}
|
||||||
return state.toBaseBlock();
|
return state.toBaseBlock();
|
||||||
@ -264,7 +265,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final CompoundTag getNbtData() {
|
public final CompoundTag getNbtData() {
|
||||||
return get.getTag(x, y + yy, z);
|
return get.getTile(x, y + yy, z);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1),
|
NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1),
|
||||||
|
@ -3,34 +3,132 @@ package com.boydti.fawe.beta.implementation.filter.block;
|
|||||||
import com.boydti.fawe.beta.Filter;
|
import com.boydti.fawe.beta.Filter;
|
||||||
import com.boydti.fawe.beta.FilterBlockMask;
|
import com.boydti.fawe.beta.FilterBlockMask;
|
||||||
import com.boydti.fawe.beta.Flood;
|
import com.boydti.fawe.beta.Flood;
|
||||||
|
import com.boydti.fawe.beta.IBlocks;
|
||||||
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
public abstract class ChunkFilterBlock extends SimpleFilterBlock {
|
/**
|
||||||
|
* Filter block implementation which uses chunks
|
||||||
|
* - First call initChunk
|
||||||
|
* - Then for each layer, call initLayer
|
||||||
|
* - Then use whatever filter method you want, to iterate over the blocks in that layer
|
||||||
|
*/
|
||||||
|
public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
||||||
|
|
||||||
public ChunkFilterBlock(Extent extent) {
|
public ChunkFilterBlock(Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ChunkFilterBlock init(int chunkX, int chunkZ, IChunkGet chunk);
|
/**
|
||||||
|
* Initialize with chunk coordinates
|
||||||
|
* - The layer must also be initialized
|
||||||
|
* @param chunkX
|
||||||
|
* @param chunkZ
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract ChunkFilterBlock initChunk(int chunkX, int chunkZ);
|
||||||
|
|
||||||
public abstract ChunkFilterBlock init(IChunkGet iget, IChunkSet iset,
|
/**
|
||||||
int layer);
|
* Initialize a chunk layer
|
||||||
|
* - The chunk coordinates must also be initialized first
|
||||||
|
* @param iget
|
||||||
|
* @param iset
|
||||||
|
* @param layer
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer);
|
||||||
|
|
||||||
public abstract void flood(IChunkGet iget, IChunkSet iset, int layer,
|
public abstract void flood(IChunkGet iget, IChunkSet iset, int layer,
|
||||||
Flood flood, FilterBlockMask mask);
|
Flood flood, FilterBlockMask mask);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* filter a single block
|
||||||
|
* @param filter
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
*/
|
||||||
public abstract void filter(Filter filter, int x, int y, int z);
|
public abstract void filter(Filter filter, int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter a cuboid region
|
||||||
|
* @param filter
|
||||||
|
* @param minX
|
||||||
|
* @param minY
|
||||||
|
* @param minZ
|
||||||
|
* @param maxX
|
||||||
|
* @param maxY
|
||||||
|
* @param maxZ
|
||||||
|
*/
|
||||||
public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY,
|
public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY,
|
||||||
int maxZ);
|
int maxZ);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter everything in the layer
|
||||||
|
* @param filter
|
||||||
|
*/
|
||||||
public abstract void filter(Filter filter);
|
public abstract void filter(Filter filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter everything between y layers
|
||||||
|
* @param filter
|
||||||
|
* @param yStart
|
||||||
|
* @param yEnd
|
||||||
|
*/
|
||||||
public abstract void filter(Filter filter, int yStart, int yEnd);
|
public abstract void filter(Filter filter, int yStart, int yEnd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter with a region
|
||||||
|
* @param filter
|
||||||
|
* @param region
|
||||||
|
*/
|
||||||
public abstract void filter(Filter filter, Region region);
|
public abstract void filter(Filter filter, Region region);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter with a chunk object
|
||||||
|
* @param chunk
|
||||||
|
* @param get
|
||||||
|
* @param set
|
||||||
|
* @param filter
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter) {
|
||||||
|
initChunk(chunk.getX(), chunk.getZ());
|
||||||
|
for (int layer = 0; layer < 16; layer++) {
|
||||||
|
if (set.hasSection(layer)) {
|
||||||
|
initLayer(get, set, layer);
|
||||||
|
filter(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter a chunk with a region / filter
|
||||||
|
* @param chunk
|
||||||
|
* @param get
|
||||||
|
* @param set
|
||||||
|
* @param filter
|
||||||
|
* @param region
|
||||||
|
* @param full
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter, Region region, boolean full) {
|
||||||
|
if (region != null) {
|
||||||
|
region.filter(chunk, filter, this, get, set, full);
|
||||||
|
} else {
|
||||||
|
for (int layer = 0; layer < 16; layer++) {
|
||||||
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
initLayer(get, set, layer);
|
||||||
|
filter(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class representing a block with a position
|
||||||
|
* - Used for optimized block operations to avoid lookups
|
||||||
|
*/
|
||||||
public abstract class FilterBlock extends BlockVector3 implements Extent, TileEntityBlock {
|
public abstract class FilterBlock extends BlockVector3 implements Extent, TileEntityBlock {
|
||||||
|
|
||||||
public abstract Extent getExtent();
|
public abstract Extent getExtent();
|
||||||
|
@ -501,12 +501,8 @@ public class MCAChunk implements IChunk {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
return null;
|
BlockState block = getBlock(x, y, z);
|
||||||
}
|
return block.toBaseBlock(this, x, y, z);
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getTag(int x, int y, int z) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -570,18 +566,7 @@ public class MCAChunk implements IChunk {
|
|||||||
@Override
|
@Override
|
||||||
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
|
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
|
||||||
try {
|
try {
|
||||||
if (region != null) {
|
block.filter(this, this, this, filter, region, full);
|
||||||
region.filter(this, filter, block, this, this, full);
|
|
||||||
} else {
|
|
||||||
block = block.init(chunkX, chunkZ, this);
|
|
||||||
for (int layer = 0; layer < 16; layer++) {
|
|
||||||
if ((!full && !this.hasSection(layer)) || !filter.appliesLayer(this, layer)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
block.init(this, this, layer);
|
|
||||||
block.filter(filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
filter.finishChunk(this);
|
filter.finishChunk(this);
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,12 @@ public class BlockVector3ChunkMap<T> implements Map<BlockVector3, T>, IAdaptedMa
|
|||||||
return map.put(key, value);
|
return map.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public T get(int x, int y, int z) {
|
||||||
|
short key = MathMan.tripleBlockCoord(x, y, z);
|
||||||
|
return map.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
public T remove(int x, int y, int z) {
|
public T remove(int x, int y, int z) {
|
||||||
short key = MathMan.tripleBlockCoord(x, y, z);
|
short key = MathMan.tripleBlockCoord(x, y, z);
|
||||||
return map.remove(key);
|
return map.remove(key);
|
||||||
|
@ -824,7 +824,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class RowZ implements IRow {
|
public static final class RowZ implements IRow {
|
||||||
private final IRow[] rows;
|
public final IRow[] rows;
|
||||||
|
|
||||||
public RowZ() {
|
public RowZ() {
|
||||||
this.rows = new IRow[FaweCache.IMP.CHUNK_LAYERS];
|
this.rows = new IRow[FaweCache.IMP.CHUNK_LAYERS];
|
||||||
|
@ -313,7 +313,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
private final List<WatchdogTickingExtent> watchdogExtents = new ArrayList<>(2);
|
private final List<WatchdogTickingExtent> watchdogExtents = new ArrayList<>(2);
|
||||||
|
|
||||||
public void setExtent(AbstractDelegateExtent extent) {
|
public void setExtent(AbstractDelegateExtent extent) {
|
||||||
new ExtentTraverser<>(getExtent()).setNext(extent);
|
new ExtentTraverser(this).setNext(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -484,7 +484,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
checkNotNull(transform);
|
checkNotNull(transform);
|
||||||
wrapped = true;
|
wrapped = true;
|
||||||
transform.setExtent(getExtent());
|
transform.setExtent(getExtent());
|
||||||
new ExtentTraverser<>(getExtent()).setNext(transform);
|
new ExtentTraverser(this).setNext(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ResettableExtent getTransform() {
|
public @Nullable ResettableExtent getTransform() {
|
||||||
@ -515,7 +515,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
maskingExtent.get().setMask(mask);
|
maskingExtent.get().setMask(mask);
|
||||||
} else if (mask != Masks.alwaysTrue()) {
|
} else if (mask != Masks.alwaysTrue()) {
|
||||||
SourceMaskExtent next = new SourceMaskExtent(getExtent(), mask);
|
SourceMaskExtent next = new SourceMaskExtent(getExtent(), mask);
|
||||||
new ExtentTraverser<>(getExtent()).setNext(next);
|
new ExtentTraverser(this).setNext(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,8 +554,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
maskingExtent.get().setMask(mask);
|
maskingExtent.get().setMask(mask);
|
||||||
} else if (mask != Masks.alwaysTrue()) {
|
} else if (mask != Masks.alwaysTrue()) {
|
||||||
MaskingExtent next = new MaskingExtent(getExtent(), mask);
|
addProcessor(new MaskingExtent(getExtent(), mask));
|
||||||
new ExtentTraverser<>(getExtent()).setNext(next);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +138,8 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.test")
|
@CommandPermissions("worldedit.region.test")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void test(Player player, EditSession editSession, @Arg(desc = "test") String worldName, BlockVector2 mcaFile) throws WorldEditException {
|
public void test(Player player, EditSession editSession, @Arg(desc = "test") double testValue) throws WorldEditException {
|
||||||
// file = new File(world, "region" + File.separator)
|
player.print("" + testValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -21,6 +21,20 @@ package com.sk89q.worldedit.extent;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.beta.Filter;
|
||||||
|
import com.boydti.fawe.beta.IBatchProcessor;
|
||||||
|
import com.boydti.fawe.beta.IChunk;
|
||||||
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
|
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.util.ExtentTraverser;
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -28,12 +42,16 @@ 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.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires that all mutating methods pass a given {@link Mask}.
|
* Requires that all mutating methods pass a given {@link Mask}.
|
||||||
*/
|
*/
|
||||||
public class MaskingExtent extends AbstractDelegateExtent {
|
public class MaskingExtent extends AbstractDelegateExtent implements IBatchProcessor, Filter {
|
||||||
|
|
||||||
private Mask mask;
|
private Mask mask;
|
||||||
|
private LoadingCache<Long, ChunkFilterBlock> threadIdToFilter = FaweCache.IMP.createCache(() -> new CharFilterBlock(getExtent()));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -81,6 +99,23 @@ public class MaskingExtent extends AbstractDelegateExtent {
|
|||||||
return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
|
return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||||
|
ChunkFilterBlock filter = threadIdToFilter.getUnchecked(Thread.currentThread().getId());
|
||||||
|
return filter.filter(chunk, get, set, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyBlock(FilterBlock block) {
|
||||||
|
int ordinal = block.getOrdinal();
|
||||||
|
if (ordinal != 0 && !mask.test(block)) {
|
||||||
|
block.setOrdinal(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Extent construct(Extent child) {
|
||||||
|
if (child == getExtent()) return this;
|
||||||
|
return new MaskingExtent(child, mask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.boydti.fawe.beta.Filter;
|
|||||||
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
|
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a given vector meets a criteria.
|
* Tests whether a given vector meets a criteria.
|
||||||
@ -92,12 +93,12 @@ public interface Mask {
|
|||||||
return new InverseMask(this);
|
return new InverseMask(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
default Filter toFilter(Runnable run) {
|
default Filter toFilter(Consumer<FilterBlock> run) {
|
||||||
return new Filter() {
|
return new Filter() {
|
||||||
@Override
|
@Override
|
||||||
public void applyBlock(FilterBlock block) {
|
public void applyBlock(FilterBlock block) {
|
||||||
if (test(block)) {
|
if (test(block)) {
|
||||||
run.run();
|
run.accept(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -674,7 +674,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, boolean full) {
|
public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, boolean full) {
|
||||||
int chunkX = chunk.getX();
|
int chunkX = chunk.getX();
|
||||||
int chunkZ = chunk.getZ();
|
int chunkZ = chunk.getZ();
|
||||||
block = block.init(chunkX, chunkZ, get);
|
block = block.initChunk(chunkX, chunkZ);
|
||||||
|
|
||||||
|
|
||||||
if ((minX + 15) >> 4 <= chunkX && (maxX - 15) >> 4 >= chunkX && (minZ + 15) >> 4 <= chunkZ && (maxZ - 15) >> 4 >= chunkZ) {
|
if ((minX + 15) >> 4 <= chunkX && (maxX - 15) >> 4 >= chunkX && (minZ + 15) >> 4 <= chunkZ && (maxZ - 15) >> 4 >= chunkZ) {
|
||||||
|
@ -303,6 +303,11 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
int sectionStart = y1 >> 4;
|
int sectionStart = y1 >> 4;
|
||||||
int sectionEnd = y2 >> 4;
|
int sectionEnd = y2 >> 4;
|
||||||
|
|
||||||
|
for (int layer = sectionStart; layer < sectionEnd; layer++) {
|
||||||
|
int yStart = Math.max(layer << 4, y1);
|
||||||
|
int yEnd = Math.min((layer << 4) + 15, y2);
|
||||||
|
filterSpherePartial(layer, yStart, yEnd, bx, bz, filter, block, get, set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterSpherePartial(int layer, int y1, int y2, int bx, int bz, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set) {
|
private void filterSpherePartial(int layer, int y1, int y2, int bx, int bz, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set) {
|
||||||
@ -310,7 +315,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
int cy = center.getBlockY();
|
int cy = center.getBlockY();
|
||||||
int cz = center.getBlockZ();
|
int cz = center.getBlockZ();
|
||||||
|
|
||||||
block.init(get, set, layer);
|
block.initLayer(get, set, layer);
|
||||||
|
|
||||||
int by = layer << 4;
|
int by = layer << 4;
|
||||||
int diffY;
|
int diffY;
|
||||||
|
@ -208,7 +208,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
int maxSection = Math.min(15, getMaximumY() >> 4);
|
int maxSection = Math.min(15, getMaximumY() >> 4);
|
||||||
for (int layer = minSection; layer <= maxSection; layer++) {
|
for (int layer = minSection; layer <= maxSection; layer++) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
||||||
block = block.init(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter, this);
|
block.filter(filter, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,19 +238,19 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
|
|
||||||
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, boolean full) {
|
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, boolean full) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
||||||
block = block.init(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter);
|
block.filter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean full) {
|
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean full) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
||||||
block = block.init(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter, minX, minY, minZ, maxX, maxY, maxZ);
|
block.filter(filter, minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int yStart, int yEnd, boolean full) {
|
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int yStart, int yEnd, boolean full) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
||||||
block = block.init(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter, yStart, yEnd);
|
block.filter(filter, yStart, yEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public class WorldEditText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Component format(Component component, Locale locale) {
|
public static Component format(Component component, Locale locale) {
|
||||||
return CONFIG_HOLDER.replace(WorldEdit.getInstance().getTranslationManager().convertText(component, locale));
|
return WorldEdit.getInstance().getTranslationManager().convertText(CONFIG_HOLDER.replace(component), locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String reduceToText(Component component, Locale locale) {
|
public static String reduceToText(Component component, Locale locale) {
|
||||||
|
@ -3,13 +3,7 @@
|
|||||||
"fawe.error": "&c{0}",
|
"fawe.error": "&c{0}",
|
||||||
"fawe.info": "&7{0}",
|
"fawe.info": "&7{0}",
|
||||||
"fawe.debug": "&3{0}",
|
"fawe.debug": "&3{0}",
|
||||||
|
|
||||||
"piston.style.help.text": "Help: {0}",
|
|
||||||
"piston.style.text.modifier": "TODO modifier: {0}, {1}, {2}",
|
|
||||||
"piston.style.main.text": "{0}",
|
|
||||||
"piston.style.part.wrapping": "&8{0}&e{1}&8{2}",
|
|
||||||
"piston.text.command.prefix": "TODO prefix",
|
|
||||||
|
|
||||||
"fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}",
|
"fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}",
|
||||||
"fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info",
|
"fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info",
|
||||||
|
|
||||||
@ -265,7 +259,7 @@
|
|||||||
"fawe.cancel.worldedit.cancel.reason.low.memory": "Low memory",
|
"fawe.cancel.worldedit.cancel.reason.low.memory": "Low memory",
|
||||||
"fawe.cancel.worldedit.cancel.reason.max.changes": "Too many blocks changed",
|
"fawe.cancel.worldedit.cancel.reason.max.changes": "Too many blocks changed",
|
||||||
"fawe.cancel.worldedit.cancel.reason.max.checks": "Too many block checks",
|
"fawe.cancel.worldedit.cancel.reason.max.checks": "Too many block checks",
|
||||||
"fawe.cancel.worldedit.cancel.reason.max.tiles": "Too many blockstates",
|
"fawe.cancel.worldedit.cancel.reason.max.tiles": "Too many block entities",
|
||||||
"fawe.cancel.worldedit.cancel.reason.max.entities": "Too many entities",
|
"fawe.cancel.worldedit.cancel.reason.max.entities": "Too many entities",
|
||||||
"fawe.cancel.worldedit.cancel.reason.max.iterations": "Max iterations",
|
"fawe.cancel.worldedit.cancel.reason.max.iterations": "Max iterations",
|
||||||
"fawe.cancel.worldedit.cancel.reason.outside.level": "Outside world",
|
"fawe.cancel.worldedit.cancel.reason.outside.level": "Outside world",
|
||||||
|
Loading…
Reference in New Issue
Block a user