Fix for Vector/BlockVector
Use optimized LocalBlockVectorSet for various operations
- Ideally I'd like the operations to use O(1) memory, but for now it'll
use substantially reduced O(n)
Some message tweaks
Some minor entity placement optimizations
Refactor set optimization to be in the EditSession class
Fix and minor optimizations for for countBlocks()
Minor optimizations for affine transforms (//rotate etc.)
Optimizations for fuzzy block mask
This commit is contained in:
Jesse Boyd 2017-01-11 07:47:59 +11:00
parent 674d40f19c
commit bc677f823e
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
69 changed files with 653 additions and 500 deletions

View File

@ -208,6 +208,7 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
ents = new ArrayList<>(entities[i]); ents = new ArrayList<>(entities[i]);
synchronized (BukkitQueue_0.adapter) { synchronized (BukkitQueue_0.adapter) {
for (Entity entity : ents) { for (Entity entity : ents) {
@ -217,10 +218,8 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
int x = ((int) Math.round(entity.locX) & 15); int x = ((int) Math.round(entity.locX) & 15);
int z = ((int) Math.round(entity.locZ) & 15); int z = ((int) Math.round(entity.locZ) & 15);
int y = (int) Math.round(entity.locY); int y = (int) Math.round(entity.locY);
if (array == null || y < 0 || y > 255) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
}
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }

View File

@ -186,9 +186,24 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
ChunkSection[] sections = nmsChunk.getSections(); ChunkSection[] sections = nmsChunk.getSections();
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk); final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities(); Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
// copy
// BukkitChunk_1_11 copy = getParent().getFaweChunk(getX(), getZ()); // TODO
// Set heightmap // Set heightmap
getParent().setHeightMap(this, heightMap); getParent().setHeightMap(this, heightMap);
// Remove entities // Remove entities
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (!entsToRemove.isEmpty()) {
synchronized (BukkitQueue_0.adapter) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
}
}
}
}
}
for (int i = 0; i < entities.length; i++) { for (int i = 0; i < entities.length; i++) {
int count = this.getCount(i); int count = this.getCount(i);
if (count == 0) { if (count == 0) {
@ -196,6 +211,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
} else if (count >= 4096) { } else if (count >= 4096) {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
// copy.storeEntities(this, i);
synchronized (BukkitQueue_0.adapter) { synchronized (BukkitQueue_0.adapter) {
ents.clear(); ents.clear();
} }
@ -204,6 +220,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
ents = new ArrayList<>(entities[i]); ents = new ArrayList<>(entities[i]);
synchronized (BukkitQueue_0.adapter) { synchronized (BukkitQueue_0.adapter) {
for (Entity entity : ents) { for (Entity entity : ents) {
@ -213,10 +230,9 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
int x = ((int) Math.round(entity.locX) & 15); int x = ((int) Math.round(entity.locX) & 15);
int z = ((int) Math.round(entity.locZ) & 15); int z = ((int) Math.round(entity.locZ) & 15);
int y = (int) Math.round(entity.locY); int y = (int) Math.round(entity.locY);
if (array == null || y < 0 || y > 255) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
} // copy.storeEntity(this, entity);
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }
@ -224,19 +240,6 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
} }
} }
} }
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (!entsToRemove.isEmpty()) {
synchronized (BukkitQueue_0.adapter) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
}
}
}
}
}
// Set entities // Set entities
Set<CompoundTag> entitiesToSpawn = this.getEntities(); Set<CompoundTag> entitiesToSpawn = this.getEntities();
Set<UUID> createdEntities = new HashSet<>(); Set<UUID> createdEntities = new HashSet<>();
@ -288,11 +291,6 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
} }
} }
} }
// Change task?
if (getParent().getChangeTask() != null) {
BukkitChunk_1_11 previous = getParent().getPrevious(this, sections, tiles, entities, createdEntities, false);
getParent().getChangeTask().run(previous, this);
}
// Trim tiles // Trim tiles
Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator(); Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
HashMap<BlockPosition, TileEntity> toRemove = null; HashMap<BlockPosition, TileEntity> toRemove = null;
@ -316,6 +314,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
} }
} }
if (toRemove != null) { if (toRemove != null) {
// copy.storeTiles(this, toRemove);
for (Map.Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) { for (Map.Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
BlockPosition bp = entry.getKey(); BlockPosition bp = entry.getKey();
TileEntity tile = entry.getValue(); TileEntity tile = entry.getValue();
@ -338,6 +337,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
continue; continue;
} }
ChunkSection section = sections[j]; ChunkSection section = sections[j];
// copy.storeBlocks(this, section);
if (section == null) { if (section == null) {
if (count == countAir) { if (count == countAir) {
continue; continue;
@ -349,8 +349,8 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
continue; continue;
} else { } else {
sections[j] = getParent().newChunkSection(j << 4, flag, array); sections[j] = getParent().newChunkSection(j << 4, flag, array);
}
continue; continue;
}
} else if (count >= 4096) { } else if (count >= 4096) {
if (countAir >= 4096) { if (countAir >= 4096) {
sections[j] = null; sections[j] = null;
@ -362,9 +362,9 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
continue; continue;
} else { } else {
sections[j] = getParent().newChunkSection(j << 4, flag, array); sections[j] = getParent().newChunkSection(j << 4, flag, array);
}
continue; continue;
} }
}
int by = j << 4; int by = j << 4;
DataPaletteBlock nibble = section.getBlocks(); DataPaletteBlock nibble = section.getBlocks();
int nonEmptyBlockCount = 0; int nonEmptyBlockCount = 0;
@ -407,6 +407,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
// Set biomes // Set biomes
int[][] biomes = this.biomes; int[][] biomes = this.biomes;
if (biomes != null) { if (biomes != null) {
// copy.storeBiomes(this);
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
int[] array = biomes[x]; int[] array = biomes[x];
if (array == null) { if (array == null) {
@ -436,6 +437,10 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
tileEntity.a(tag); // ReadTagIntoTile tileEntity.a(tag); // ReadTagIntoTile
} }
} }
// Change task?
// if (getParent().getChangeTask() != null) { // TODO
// getParent().getChangeTask().run(copy, this);
// }
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }

View File

@ -170,6 +170,7 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
ents = new ArrayList<>(entities[i]); ents = new ArrayList<>(entities[i]);
synchronized (BukkitQueue_0.adapter) { synchronized (BukkitQueue_0.adapter) {
for (Entity entity : ents) { for (Entity entity : ents) {
@ -179,10 +180,8 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
int x = ((int) Math.round(entity.locX) & 15); int x = ((int) Math.round(entity.locX) & 15);
int z = ((int) Math.round(entity.locZ) & 15); int z = ((int) Math.round(entity.locZ) & 15);
int y = (int) Math.round(entity.locY); int y = (int) Math.round(entity.locY);
if (array == null || y < 0 || y > 255) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
}
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }

View File

@ -109,6 +109,7 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
ents = new ArrayList<>(entities[i]); ents = new ArrayList<>(entities[i]);
synchronized (BukkitQueue_0.adapter) { synchronized (BukkitQueue_0.adapter) {
for (Entity entity : ents) { for (Entity entity : ents) {
@ -118,10 +119,8 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
int x = ((int) Math.round(entity.locX) & 15); int x = ((int) Math.round(entity.locX) & 15);
int z = ((int) Math.round(entity.locZ) & 15); int z = ((int) Math.round(entity.locZ) & 15);
int y = (int) Math.round(entity.locY); int y = (int) Math.round(entity.locY);
if (array == null || y < 0 || y > 255) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
}
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }

View File

@ -210,6 +210,7 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
ents = new ArrayList<>(entities[i]); ents = new ArrayList<>(entities[i]);
synchronized (BukkitQueue_0.adapter) { synchronized (BukkitQueue_0.adapter) {
for (Entity entity : ents) { for (Entity entity : ents) {
@ -219,10 +220,8 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
int x = ((int) Math.round(entity.locX) & 15); int x = ((int) Math.round(entity.locX) & 15);
int z = ((int) Math.round(entity.locZ) & 15); int z = ((int) Math.round(entity.locZ) & 15);
int y = (int) Math.round(entity.locY); int y = (int) Math.round(entity.locY);
if (array == null || y < 0 || y > 255) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
}
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }

View File

@ -84,7 +84,11 @@ public class Settings extends Config {
" - History on disk or memory will be deleted", " - History on disk or memory will be deleted",
}) })
public int MAX_HISTORY_MB = -1; public int MAX_HISTORY_MB = -1;
@Comment("Needlessly make WorldEdit slower for this player (ms/block)") @Comment({
"Cinematic block placement:",
" - Adds a delay to block placement (ms/block)",
" - Having an artificial delay will use more CPU/Memory",
})
public int SPEED_REDUCTION = 0; public int SPEED_REDUCTION = 0;
@Comment({ @Comment({
"Should WorldEdit use inventory?", "Should WorldEdit use inventory?",

View File

@ -52,7 +52,7 @@ public class MCAWorld extends LocalWorld {
@Override @Override
public int getBlockLightLevel(Vector position) { public int getBlockLightLevel(Vector position) {
return queue.getEmmittedLight((int) position.x, (int) position.y, (int) position.z); return queue.getEmmittedLight(position.getBlockX(), position.getBlockY(), position.getBlockZ());
} }
@Override @Override

View File

@ -372,7 +372,7 @@ public abstract class FawePlayer<T> extends Metadatable {
public void setSelection(final RegionWrapper region) { public void setSelection(final RegionWrapper region) {
final Player player = this.getPlayer(); final Player player = this.getPlayer();
Vector top = region.getTopVector(); Vector top = region.getTopVector();
top.setY(getWorld().getMaxY()); top.y = getWorld().getMaxY();
final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), top); final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), top);
this.getSession().setRegionSelector(player.getWorld(), selector); this.getSession().setRegionSelector(player.getWorld(), selector);
} }

View File

@ -17,6 +17,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.BundledBlockData;
@ -138,6 +139,48 @@ public abstract class FaweQueue {
public void optimize() {} public void optimize() {}
public int setBlocks(CuboidRegion cuboid, final int id, final int data) {
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
final int minY = cuboid.getMinimumY();
final int maxY = cuboid.getMaximumY();
final FaweChunk<?> fc = getFaweChunk(0, 0);
final byte dataByte = (byte) data;
fc.fillCuboid(0, 15, minY, maxY, 0, 15, id, dataByte);
fc.optimize();
int bcx = (current.minX) >> 4;
int bcz = (current.minZ) >> 4;
int tcx = (current.maxX) >> 4;
int tcz = (current.maxZ) >> 4;
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
MainUtil.chunkTaskSync(current, new RunnableVal<int[]>() {
@Override
public void run(int[] value) {
FaweChunk newChunk;
if (value[6] == 0) {
newChunk = fc.copy(true);
newChunk.setLoc(FaweQueue.this, value[0], value[1]);
} else {
int bx = value[2] & 15;
int tx = value[4] & 15;
int bz = value[3] & 15;
int tz = value[5] & 15;
if (bx == 0 && tx == 15 && bz == 0 && tz == 15) {
newChunk = fc.copy(true);
newChunk.setLoc(FaweQueue.this, value[0], value[1]);
} else {
newChunk = FaweQueue.this.getFaweChunk(value[0], value[1]);
newChunk.fillCuboid(value[2] & 15, value[4] & 15, minY, maxY, value[3] & 15, value[5] & 15, id, dataByte);
}
}
newChunk.addToQueue();
}
});
return cuboid.getArea();
}
public abstract boolean setBlock(final int x, final int y, final int z, final int id, final int data); public abstract boolean setBlock(final int x, final int y, final int z, final int id, final int data);
public boolean setBlock(int x, int y, int z, int id) { public boolean setBlock(int x, int y, int z, int id) {

View File

@ -97,12 +97,12 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException { public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
return setBlock((int) location.x, (int) location.y, (int) location.z, block); return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
} }
@Override @Override
public BaseBlock getLazyBlock(Vector location) { public BaseBlock getLazyBlock(Vector location) {
return getLazyBlock((int) location.x, (int) location.y, (int) location.z); return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
} }
@Nullable @Nullable

View File

@ -123,9 +123,9 @@ public class SplineBrush implements DoubleActionBrush {
private Vector getCentroid(Collection<Vector> points) { private Vector getCentroid(Collection<Vector> points) {
Vector sum = new Vector(); Vector sum = new Vector();
for (Vector p : points) { for (Vector p : points) {
sum.x += p.x; sum.x += p.getX();
sum.y += p.y; sum.y += p.getY();
sum.z += p.z; sum.z += p.getZ();
} }
return sum.multiply(1.0 / points.size()); return sum.multiply(1.0 / points.size());
} }
@ -147,15 +147,15 @@ public class SplineBrush implements DoubleActionBrush {
Vector r = new Vector(); Vector r = new Vector();
for (Vector p : points) { for (Vector p : points) {
r.x = p.x - centroid.x; r.x = (p.getX() - centroid.getX());
r.y = p.y - centroid.y; r.y = (p.getY() - centroid.getY());
r.z = p.z - centroid.z; r.z = (p.getZ() - centroid.getZ());
xx += r.x * r.x; xx += r.getX() * r.getX();
xy += r.x * r.y; xy += r.getX() * r.getY();
xz += r.x * r.z; xz += r.getX() * r.getZ();
yy += r.y * r.y; yy += r.getY() * r.getY();
yz += r.y * r.z; yz += r.getY() * r.getZ();
zz += r.z * r.z; zz += r.getZ() * r.getZ();
} }
double det_x = yy*zz - yz*yz; double det_x = yy*zz - yz*yz;

View File

@ -61,7 +61,7 @@ public class ScalableHeightMap {
int clipHeight = maxY - minY + 1; int clipHeight = maxY - minY + 1;
HashSet<IntegerPair> visited = new HashSet<>(); HashSet<IntegerPair> visited = new HashSet<>();
for (Vector pos : clipboard.getRegion()) { for (Vector pos : clipboard.getRegion()) {
IntegerPair pair = new IntegerPair((int) pos.x, (int) pos.z); IntegerPair pair = new IntegerPair(pos.getBlockX(), pos.getBlockZ());
if (visited.contains(pair)) { if (visited.contains(pair)) {
continue; continue;
} }

View File

@ -81,9 +81,9 @@ public abstract class FaweClipboard {
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
if (tag != null) { if (tag != null) {
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue()); Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
values.put("x", new IntTag((int) pos.x)); values.put("x", new IntTag(pos.getBlockX()));
values.put("y", new IntTag((int) pos.y)); values.put("y", new IntTag(pos.getBlockY()));
values.put("z", new IntTag((int) pos.z)); values.put("z", new IntTag(pos.getBlockZ()));
tiles.add(tag); tiles.add(tag);
} }
} }

View File

@ -59,9 +59,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
if (tag != null) { if (tag != null) {
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue()); Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
values.put("x", new IntTag((int) pos.x)); values.put("x", new IntTag(pos.getBlockX()));
values.put("y", new IntTag((int) pos.y)); values.put("y", new IntTag(pos.getBlockY()));
values.put("z", new IntTag((int) pos.z)); values.put("z", new IntTag(pos.getBlockZ()));
} }
task.run(pos, block); task.run(pos, block);
} }
@ -81,9 +81,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
if (tag != null) { if (tag != null) {
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue()); Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
values.put("x", new IntTag((int) pos.x)); values.put("x", new IntTag(pos.getBlockX()));
values.put("y", new IntTag((int) pos.y)); values.put("y", new IntTag(pos.getBlockY()));
values.put("z", new IntTag((int) pos.z)); values.put("z", new IntTag(pos.getBlockZ()));
} }
task.run(pos, block); task.run(pos, block);
} }
@ -108,9 +108,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
if (tag != null) { if (tag != null) {
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue()); Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
values.put("x", new IntTag((int) pos.x)); values.put("x", new IntTag(pos.getBlockX()));
values.put("y", new IntTag((int) pos.y)); values.put("y", new IntTag(pos.getBlockY()));
values.put("z", new IntTag((int) pos.z)); values.put("z", new IntTag(pos.getBlockZ()));
} }
task.run(pos, block); task.run(pos, block);
} else if (air) { } else if (air) {

View File

@ -23,9 +23,9 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
mutable.x = location.x + dx; mutable.x = (location.getX() + dx);
mutable.y = location.y + dy; mutable.y = (location.getY() + dy);
mutable.z = location.z + dz; mutable.z = (location.getZ() + dz);
return extent.setBlock(mutable, block); return extent.setBlock(mutable, block);
} }
@ -49,12 +49,12 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override @Override
public BaseBlock getBlock(Vector location) { public BaseBlock getBlock(Vector location) {
return getLazyBlock((int) location.x, (int) location.y, (int) location.z); return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
} }
@Override @Override
public BaseBlock getLazyBlock(Vector location) { public BaseBlock getLazyBlock(Vector location) {
return getLazyBlock((int) location.x, (int) location.y, (int) location.z); return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
} }
@Override @Override

View File

@ -93,12 +93,12 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
@Override @Override
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException { public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
return setBlock((int) location.x, (int) location.y, (int) location.z, block); return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
} }
@Override @Override
public BaseBlock getLazyBlock(Vector location) { public BaseBlock getLazyBlock(Vector location) {
return getLazyBlock((int) location.x, (int) location.y, (int) location.z); return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
} }
@Override @Override

View File

@ -1,7 +1,9 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.object.RegionWrapper;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import java.util.Collection;
public abstract class FaweRegionExtent extends AbstractDelegateExtent { public abstract class FaweRegionExtent extends AbstractDelegateExtent {
/** /**
@ -14,4 +16,6 @@ public abstract class FaweRegionExtent extends AbstractDelegateExtent {
} }
public abstract boolean contains(int x, int y, int z); public abstract boolean contains(int x, int y, int z);
public abstract Collection<RegionWrapper> getRegions();
} }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
@ -14,6 +15,8 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
public class NullExtent extends FaweRegionExtent { public class NullExtent extends FaweRegionExtent {
@ -88,6 +91,11 @@ public class NullExtent extends FaweRegionExtent {
@Override @Override
public boolean contains(int x, int y, int z) { return false; } public boolean contains(int x, int y, int z) { return false; }
@Override
public Collection<RegionWrapper> getRegions() {
return Collections.emptyList();
}
@Override @Override
protected Operation commitBefore() { protected Operation commitBefore() {
return null; return null;

View File

@ -33,13 +33,13 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(pos); min = new Vector(pos);
} }
mutable.x = (pos.x - min.x); mutable.x = ((pos.getX() - min.getX()));
mutable.y = (pos.y - min.y); mutable.y = ((pos.getY() - min.getY()));
mutable.z = (pos.z - min.z); mutable.z = ((pos.getZ() - min.getZ()));
Vector tmp = transform.apply(mutable); Vector tmp = transform.apply(mutable);
tmp.x += min.x; tmp.x = (tmp.getX() + min.getX());
tmp.y += min.y; tmp.y = (tmp.getY() + min.getY());
tmp.z += min.z; tmp.z = (tmp.getZ() + min.getZ());
return tmp; return tmp;
} }
@ -47,13 +47,13 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(x, y, z); min = new Vector(x, y, z);
} }
mutable.x = (x - min.x); mutable.x = ((x - min.getX()));
mutable.y = (y - min.y); mutable.y = ((y - min.getY()));
mutable.z = (z - min.z); mutable.z = ((z - min.getZ()));
Vector tmp = transform.apply(mutable); Vector tmp = transform.apply(mutable);
tmp.x += min.x; tmp.x = (tmp.getX() + min.getX());
tmp.y += min.y; tmp.y = (tmp.getY() + min.getY());
tmp.z += min.z; tmp.z = (tmp.getZ() + min.getZ());
return tmp; return tmp;
} }

View File

@ -17,6 +17,8 @@ import com.sk89q.worldedit.extent.Extent;
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.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
public class ProcessedWEExtent extends FaweRegionExtent { public class ProcessedWEExtent extends FaweRegionExtent {
@ -31,6 +33,11 @@ public class ProcessedWEExtent extends FaweRegionExtent {
this.extent = (AbstractDelegateExtent) parent; this.extent = (AbstractDelegateExtent) parent;
} }
@Override
public Collection<RegionWrapper> getRegions() {
return Arrays.asList(mask);
}
public void setLimit(FaweLimit other) { public void setLimit(FaweLimit other) {
this.limit.set(other); this.limit.set(other);
} }
@ -89,12 +96,12 @@ public class ProcessedWEExtent extends FaweRegionExtent {
@Override @Override
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException { public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
return setBlock((int) location.x, (int) location.y, (int) location.z, block); return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
} }
@Override @Override
public BaseBlock getLazyBlock(Vector location) { public BaseBlock getLazyBlock(Vector location) {
return getLazyBlock((int) location.x, (int) location.y, (int) location.z); return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
} }
@Override @Override
@ -133,7 +140,7 @@ public class ProcessedWEExtent extends FaweRegionExtent {
@Override @Override
public boolean setBiome(final Vector2D position, final BaseBiome biome) { public boolean setBiome(final Vector2D position, final BaseBiome biome) {
if (WEManager.IMP.maskContains(this.mask, (int) position.getX(), (int) position.getZ())) { if (WEManager.IMP.maskContains(this.mask, position.getBlockX(), position.getBlockZ())) {
if (!limit.MAX_CHANGES()) { if (!limit.MAX_CHANGES()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
return false; return false;

View File

@ -37,9 +37,9 @@ public class ScaleTransform extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(pos); min = new Vector(pos);
} }
mutable.x = min.x + (pos.x - min.x) * dx; mutable.x = (min.getX() + (pos.getX() - min.getX()) * dx);
mutable.y = min.y + (pos.y - min.y) * dy; mutable.y = (min.getY() + (pos.getY() - min.getY()) * dy);
mutable.z = min.z + (pos.z - min.z) * dz; mutable.z = (min.getZ() + (pos.getZ() - min.getZ()) * dz);
return mutable; return mutable;
} }
@ -47,9 +47,9 @@ public class ScaleTransform extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(x, y, z); min = new Vector(x, y, z);
} }
mutable.x = min.x + (x - min.x) * dx; mutable.x = (min.getX() + (x - min.getX()) * dx);
mutable.y = min.y + (y - min.y) * dy; mutable.y = (min.getY() + (y - min.getY()) * dy);
mutable.z = min.z + (z - min.z) * dz; mutable.z = (min.getZ() + (z - min.getZ()) * dz);
return mutable; return mutable;
} }
@ -58,9 +58,9 @@ public class ScaleTransform extends ResettableExtent {
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
boolean result = false; boolean result = false;
Vector pos = getPos(location); Vector pos = getPos(location);
double sx = pos.x; double sx = pos.getX();
double sy = pos.y; double sy = pos.getY();
double sz = pos.z; double sz = pos.getZ();
double ex = sx + dx; double ex = sx + dx;
double ey = Math.min(maxy, sy + dy); double ey = Math.min(maxy, sy + dy);
double ez = sz + dz; double ez = sz + dz;
@ -78,10 +78,10 @@ public class ScaleTransform extends ResettableExtent {
public boolean setBiome(Vector2D position, BaseBiome biome) { public boolean setBiome(Vector2D position, BaseBiome biome) {
boolean result = false; boolean result = false;
Vector pos = getPos(position.getBlockX(), 0, position.getBlockZ()); Vector pos = getPos(position.getBlockX(), 0, position.getBlockZ());
double sx = pos.x; double sx = pos.getX();
double sz = pos.z; double sz = pos.getZ();
double ex = pos.x + dx; double ex = pos.getX() + dx;
double ez = pos.z + dz; double ez = pos.getZ() + dz;
for (pos.z = sz; pos.z < ez; pos.z++) { for (pos.z = sz; pos.z < ez; pos.z++) {
for (pos.x = sx; pos.x < ex; pos.x++) { for (pos.x = sx; pos.x < ex; pos.x++) {
result |= super.setBiome(pos.toVector2D(), biome); result |= super.setBiome(pos.toVector2D(), biome);
@ -94,12 +94,12 @@ public class ScaleTransform extends ResettableExtent {
public boolean setBlock(int x1, int y1, int z1, BaseBlock block) throws WorldEditException { public boolean setBlock(int x1, int y1, int z1, BaseBlock block) throws WorldEditException {
boolean result = false; boolean result = false;
Vector pos = getPos(x1, y1, z1); Vector pos = getPos(x1, y1, z1);
double sx = pos.x; double sx = pos.getX();
double sy = pos.y; double sy = pos.getY();
double sz = pos.z; double sz = pos.getZ();
double ex = pos.x + dx; double ex = pos.getX() + dx;
double ey = Math.min(maxy, sy + dy); double ey = Math.min(maxy, sy + dy);
double ez = pos.z + dz; double ez = pos.getZ() + dz;
for (pos.y = sy; pos.y < ey; pos.y++) { for (pos.y = sy; pos.y < ey; pos.y++) {
for (pos.z = sz; pos.z < ez; pos.z++) { for (pos.z = sz; pos.z < ez; pos.z++) {
for (pos.x = sx; pos.x < ex; pos.x++) { for (pos.x = sx; pos.x < ex; pos.x++) {

View File

@ -40,7 +40,7 @@ public class SourceMaskExtent extends TemporalExtent {
} }
@Override @Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
set((int) location.x, (int) location.y, (int) location.z, block); set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
return mask.test(location) && super.setBlock(location, block); return mask.test(location) && super.setBlock(location, block);
} }

View File

@ -54,7 +54,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
@Override @Override
public BaseBlock getBlock(Vector position) { public BaseBlock getBlock(Vector position) {
if (position.x == x && position.y == y && position.z == z) { if (position.getX() == x && position.getY() == y && position.getZ() == z) {
return block; return block;
} }
return super.getBlock(position); return super.getBlock(position);
@ -62,7 +62,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
@Override @Override
public BaseBlock getLazyBlock(Vector position) { public BaseBlock getLazyBlock(Vector position) {
if (position.x == x && position.y == y && position.z == z) { if (position.getX() == x && position.getY() == y && position.getZ() == z) {
return block; return block;
} }
return super.getLazyBlock(position); return super.getLazyBlock(position);

View File

@ -35,13 +35,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) { if (min == null) {
min = new Vector(pos); min = new Vector(pos);
} }
mutable.x = (pos.x - min.x); mutable.x = ((pos.getX() - min.getX()));
mutable.y = (pos.y - min.y); mutable.y = ((pos.getY() - min.getY()));
mutable.z = (pos.z - min.z); mutable.z = ((pos.getZ() - min.getZ()));
Vector tmp = getTransform().apply(mutable); Vector tmp = getTransform().apply(mutable);
tmp.x += min.x; tmp.x = (tmp.getX() + min.getX());
tmp.y += min.y; tmp.y = (tmp.getY() + min.getY());
tmp.z += min.z; tmp.z = (tmp.getZ() + min.getZ());
return tmp; return tmp;
} }
@ -49,13 +49,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) { if (min == null) {
min = new Vector(x, y, z); min = new Vector(x, y, z);
} }
mutable.x = (x - min.x); mutable.x = ((x - min.getX()));
mutable.y = (y - min.y); mutable.y = ((y - min.getY()));
mutable.z = (z - min.z); mutable.z = ((z - min.getZ()));
Vector tmp = getTransform().apply(mutable); Vector tmp = getTransform().apply(mutable);
tmp.x += min.x; tmp.x = (tmp.getX() + min.getX());
tmp.y += min.y; tmp.y = (tmp.getY() + min.getY());
tmp.z += min.z; tmp.z = (tmp.getZ() + min.getZ());
return tmp; return tmp;
} }

View File

@ -18,9 +18,9 @@ public class AdjacentMask extends BlockMask {
@Override @Override
public boolean test(Vector v) { public boolean test(Vector v) {
int count = 0; int count = 0;
double x = v.x; double x = v.getX();
double y = v.y; double y = v.getY();
double z = v.z; double z = v.getZ();
v.x = x + 1; v.x = x + 1;
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; }
v.x = x - 1; v.x = x - 1;

View File

@ -21,7 +21,7 @@ public class BlockLightMask implements Mask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
if (extent instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBlockLight((int) vector.x, (int) vector.y, (int) vector.z); int light = ((LightingExtent) extent).getBlockLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }
return false; return false;

View File

@ -21,7 +21,7 @@ public class BrightnessMask implements Mask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
if (extent instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBrightness((int) vector.x, (int) vector.y, (int) vector.z); int light = ((LightingExtent) extent).getBrightness(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }
return false; return false;

View File

@ -21,7 +21,7 @@ public class LightMask implements Mask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
if (extent instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getLight((int) vector.x, (int) vector.y, (int) vector.z); int light = ((LightingExtent) extent).getLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }
return false; return false;

View File

@ -21,7 +21,7 @@ public class OpacityMask implements Mask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
if (extent instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getOpacity((int) vector.x, (int) vector.y, (int) vector.z); int light = ((LightingExtent) extent).getOpacity(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }
return false; return false;

View File

@ -26,9 +26,9 @@ public class RadiusMask implements Mask, ResettableMask{
if (pos == null) { if (pos == null) {
pos = new Vector(to); pos = new Vector(to);
} }
int dx = Math.abs((int) (pos.x - to.x)); int dx = Math.abs((int) (pos.getX() - to.getX()));
int dy = Math.abs((int) (pos.y - to.y)); int dy = Math.abs((int) (pos.getY() - to.getY()));
int dz = Math.abs((int) (pos.z - to.z)); int dz = Math.abs((int) (pos.getZ() - to.getZ()));
int d = dx * dx; int d = dx * dx;
if (d < minSqr || d > maxSqr) { if (d < minSqr || d > maxSqr) {
return false; return false;

View File

@ -21,7 +21,7 @@ public class SkyLightMask implements Mask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
if (extent instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getSkyLight((int) vector.x, (int) vector.y, (int) vector.z); int light = ((LightingExtent) extent).getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }
return false; return false;

View File

@ -18,9 +18,9 @@ public class WallMask extends BlockMask {
@Override @Override
public boolean test(Vector v) { public boolean test(Vector v) {
int count = 0; int count = 0;
double x = v.x; double x = v.getX();
double y = v.y; double y = v.getY();
double z = v.z; double z = v.getZ();
v.x = x + 1; v.x = x + 1;
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; }
v.x = x - 1; v.x = x - 1;

View File

@ -17,8 +17,8 @@ public class NoXPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector pos) { public BaseBlock apply(Vector pos) {
mutable.y = pos.y; mutable.y = (pos.getY());
mutable.z = pos.z; mutable.z = (pos.getZ());
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -17,8 +17,8 @@ public class NoYPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector pos) { public BaseBlock apply(Vector pos) {
mutable.x = pos.x; mutable.x = (pos.getX());
mutable.z = pos.z; mutable.z = (pos.getZ());
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -17,8 +17,8 @@ public class NoZPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector pos) { public BaseBlock apply(Vector pos) {
mutable.x = pos.x; mutable.x = (pos.getX());
mutable.y = pos.y; mutable.y = (pos.getY());
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -20,9 +20,9 @@ public class OffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = position.x + dx; mutable.x = (position.getX() + dx);
mutable.y = position.y + dy; mutable.y = (position.getY() + dy);
mutable.z = position.z + dz; mutable.z = (position.getZ() + dz);
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -55,7 +55,7 @@ public class PatternExtent extends AbstractPattern implements Extent {
@Override @Override
public BaseBlock getBlock(Vector position) { public BaseBlock getBlock(Vector position) {
BaseBlock tmp = pattern.apply(position); BaseBlock tmp = pattern.apply(position);
if (position == target || (position.x == target.x && position.y == target.y && position.z == target.z)) { if (position == target || (position.getX() == target.getX() && position.getY() == target.getY() && position.getZ() == target.getZ())) {
block = tmp; block = tmp;
} else { } else {
block = null; block = null;

View File

@ -25,9 +25,9 @@ public class RandomOffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = position.x + r.nextInt(dx2) - dx; mutable.x = (position.getX() + r.nextInt(dx2) - dx);
mutable.y = position.y + r.nextInt(dy2) - dy; mutable.y = (position.getY() + r.nextInt(dy2) - dy);
mutable.z = position.z + r.nextInt(dz2) - dz; mutable.z = (position.getZ() + r.nextInt(dz2) - dz);
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -21,9 +21,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
if (origin == null) { if (origin == null) {
origin = new Vector(pos); origin = new Vector(pos);
} }
mutable.x = pos.x - origin.x; mutable.x = (pos.getX() - origin.getX());
mutable.y = pos.y - origin.y; mutable.y = (pos.getY() - origin.getY());
mutable.z = pos.z - origin.z; mutable.z = (pos.getZ() - origin.getZ());
return pattern.apply(mutable); return pattern.apply(mutable);
} }

View File

@ -35,9 +35,9 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = position.x + r.nextInt(dx2) - dx; mutable.x = (position.getX() + r.nextInt(dx2) - dx);
mutable.y = position.y + r.nextInt(dy2) - dy; mutable.y = (position.getY() + r.nextInt(dy2) - dy);
mutable.z = position.z + r.nextInt(dz2) - dz; mutable.z = (position.getZ() + r.nextInt(dz2) - dz);
BaseBlock block = pattern.apply(mutable); BaseBlock block = pattern.apply(mutable);
if (solid[FaweCache.getCombined(block)]) { if (solid[FaweCache.getCombined(block)]) {
return block; return block;

View File

@ -35,9 +35,9 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = position.x + r.nextInt(dx2) - dx; mutable.x = (position.getX() + r.nextInt(dx2) - dx);
mutable.y = position.y + r.nextInt(dy2) - dy; mutable.y = (position.getY() + r.nextInt(dy2) - dy);
mutable.z = position.z + r.nextInt(dz2) - dz; mutable.z = (position.getZ() + r.nextInt(dz2) - dz);
BaseBlock block = pattern.apply(mutable); BaseBlock block = pattern.apply(mutable);
if (solid[FaweCache.getCombined(block)]) { if (solid[FaweCache.getCombined(block)]) {
mutable.y++; mutable.y++;

View File

@ -150,7 +150,7 @@ public class FuzzyRegion extends AbstractRegion {
@Override @Override
public boolean contains(Vector position) { public boolean contains(Vector position) {
return contains((int) position.x, (int) position.y, (int) position.z); return contains(position.getBlockX(), position.getBlockY(), position.getBlockZ());
} }
@Override @Override

View File

@ -73,7 +73,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
positions.clear(); positions.clear();
positions.add(position); positions.add(position);
this.region = new FuzzyRegion(getWorld(), getExtent(), getMask()); this.region = new FuzzyRegion(getWorld(), getExtent(), getMask());
this.region.select((int) position.x, (int) position.y, (int) position.z); this.region.select(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return true; return true;
} }
@ -81,7 +81,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
public boolean selectSecondary(Vector position, SelectorLimits limits) { public boolean selectSecondary(Vector position, SelectorLimits limits) {
this.positions.add(position); this.positions.add(position);
new MaskTraverser(getMask()).reset(getExtent()); new MaskTraverser(getMask()).reset(getExtent());
this.region.select((int) position.x, (int) position.y, (int) position.z); this.region.select(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return true; return true;
} }

View File

@ -222,7 +222,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
BaseBlock block = clipboard.getBlock(point); BaseBlock block = clipboard.getBlock(point);
int combined = FaweCache.getCombined(block); int combined = FaweCache.getCombined(block);
int index = indexes[combined]; int index = indexes[combined];
List<Integer> pos = Arrays.asList((int) (point.x - min.x), (int) (point.y - min.y), (int) (point.z - min.z)); List<Integer> pos = Arrays.asList((int) (point.getX() - min.getX()), (int) (point.getY() - min.getY()), (int) (point.getZ() - min.getZ()));
if (!block.hasNbtData()) { if (!block.hasNbtData()) {
blocks.add(FaweCache.asMap("state", index, "pos", pos)); blocks.add(FaweCache.asMap("state", index, "pos", pos));
} else { } else {

View File

@ -63,7 +63,7 @@ public abstract class DFSVisitor implements Operation {
} }
public void visit(final Vector pos) { public void visit(final Vector pos) {
Node node = new Node((int) pos.x, (int) pos.y, (int) pos.z); Node node = new Node(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
if (!this.hashQueue.contains(node)) { if (!this.hashQueue.contains(node)) {
isVisitable(pos, pos); // Ignore this, just to initialize mask on this point isVisitable(pos, pos); // Ignore this, just to initialize mask on this point
queue.addFirst(new NodePair(null, node, 0)); queue.addFirst(new NodePair(null, node, 0));

View File

@ -0,0 +1,97 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* Extension of {@code Vector} that that compares with other instances
* using integer components.
*/
public class BlockVector extends Vector {
public static final BlockVector ZERO = new BlockVector(0, 0, 0);
public static final BlockVector UNIT_X = new BlockVector(1, 0, 0);
public static final BlockVector UNIT_Y = new BlockVector(0, 1, 0);
public static final BlockVector UNIT_Z = new BlockVector(0, 0, 1);
public static final BlockVector ONE = new BlockVector(1, 1, 1);
/**
* Construct an instance as a copy of another instance.
*
* @param position the other position
*/
public BlockVector(Vector position) {
super(position);
}
/**
* Construct a new instance.
*
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockVector(int x, int y, int z) {
super(x, y, z);
}
/**
* Construct a new instance.
*
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockVector(float x, float y, float z) {
super(x, y, z);
}
/**
* Construct a new instance.
*
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockVector(double x, double y, double z) {
super(x, y, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector) obj;
return (int) other.getX() == (int) this.getX() && (int) other.getY() == (int) this.getY()
&& (int) other.getZ() == (int) this.getZ();
}
@Override
public int hashCode() {
return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30);
}
@Override
public BlockVector toBlockVector() {
return this;
}
}

View File

@ -531,7 +531,7 @@ public class CuboidClipboard {
} }
if (aroundPlayer) { if (aroundPlayer) {
offset = offset.setX(1 - offset.getX() - width); offset.x = 1 - offset.x - width;
} }
break; break;
@ -565,7 +565,7 @@ public class CuboidClipboard {
} }
if (aroundPlayer) { if (aroundPlayer) {
offset = offset.setZ(1 - offset.getZ() - length); offset.z = 1 - offset.getZ() - length;
} }
break; break;
@ -597,7 +597,7 @@ public class CuboidClipboard {
} }
if (aroundPlayer) { if (aroundPlayer) {
offset = offset.setY(1 - offset.getY() - height); offset.y = 1 - offset.getY() - height;
} }
break; break;

View File

@ -41,6 +41,7 @@ import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory; import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.FastWorldEditExtent; import com.boydti.fawe.object.extent.FastWorldEditExtent;
import com.boydti.fawe.object.extent.FaweRegionExtent; import com.boydti.fawe.object.extent.FaweRegionExtent;
@ -129,12 +130,11 @@ import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.WorldData; import com.sk89q.worldedit.world.registry.WorldData;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -169,6 +169,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
private World world; private World world;
private String worldName; private String worldName;
private FaweQueue queue; private FaweQueue queue;
private boolean wrapped;
private AbstractDelegateExtent extent; private AbstractDelegateExtent extent;
private HistoryExtent history; private HistoryExtent history;
private AbstractDelegateExtent bypassHistory; private AbstractDelegateExtent bypassHistory;
@ -483,6 +484,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
String className = toReturn.getClass().getName().toLowerCase(); String className = toReturn.getClass().getName().toLowerCase();
for (String allowed : Settings.EXTENT.ALLOWED_PLUGINS) { for (String allowed : Settings.EXTENT.ALLOWED_PLUGINS) {
if (className.contains(allowed.toLowerCase())) { if (className.contains(allowed.toLowerCase())) {
this.wrapped = true;
return (AbstractDelegateExtent) toReturn; return (AbstractDelegateExtent) toReturn;
} }
} }
@ -858,10 +860,10 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
@Override @Override
public BaseBlock getLazyBlock(final Vector position) { public BaseBlock getLazyBlock(final Vector position) {
if (position.y > maxY || position.y < 0) { if (position.getY() > maxY || position.getY() < 0) {
return nullBlock; return nullBlock;
} }
return getLazyBlock((int) position.x, (int) position.y, (int) position.z); return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
} }
public BaseBlock getLazyBlock(int x, int y, int z) { public BaseBlock getLazyBlock(int x, int y, int z) {
@ -874,10 +876,10 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
@Override @Override
public BaseBlock getBlock(final Vector position) { public BaseBlock getBlock(final Vector position) {
if (position.y > maxY || position.y < 0) { if (position.getY() > maxY || position.getY() < 0) {
return nullBlock; return nullBlock;
} }
return getLazyBlock((int) position.x, (int) position.y, (int) position.z); return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
} }
/** /**
@ -1335,9 +1337,20 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
* @return the number of found blocks * @return the number of found blocks
*/ */
public int countBlock(final Region region, final Set<Integer> searchIDs) { public int countBlock(final Region region, final Set<Integer> searchIDs) {
if (searchIDs.isEmpty()) {
return 0;
}
if (searchIDs.size() == 1) {
int count = 0;
int id = searchIDs.iterator().next();
for (final Vector pt : region) {
if (this.getBlockType(pt) == id) count++;
}
return count;
}
final boolean[] ids = new boolean[256]; final boolean[] ids = new boolean[256];
for (final int id : searchIDs) { for (final int id : searchIDs) {
if ((id < 256) && (id > 0)) { if ((id < 256) && (id >= 0)) {
ids[id] = true; ids[id] = true;
} }
} }
@ -1345,14 +1358,14 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
public int countBlock(final Region region, final boolean[] ids) { public int countBlock(final Region region, final boolean[] ids) {
int i = 0; int count = 0;
for (final Vector pt : region) { for (final Vector pt : region) {
final int id = this.getBlockType(pt); final int id = this.getBlockType(pt);
if (ids[id]) { if (ids[id]) {
i++; count++;
} }
} }
return i; return count;
} }
/** /**
@ -1363,14 +1376,14 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
* @return the number of blocks that matched the pattern * @return the number of blocks that matched the pattern
*/ */
public int countBlocks(final Region region, final Set<BaseBlock> searchBlocks) { public int countBlocks(final Region region, final Set<BaseBlock> searchBlocks) {
final boolean[] ids = new boolean[256]; BlockMask mask = new BlockMask(extent, searchBlocks);
for (final BaseBlock block : searchBlocks) { int count = 0;
final int id = block.getId(); for (final Vector pt : region) {
if ((id < 256) && (id > 0)) { if (mask.test(pt)) {
ids[id] = true; count++;
} }
} }
return this.countBlock(region, ids); return count;
} }
public int fall(final Region region, boolean fullHeight, BaseBlock replace) { public int fall(final Region region, boolean fullHeight, BaseBlock replace) {
@ -1379,8 +1392,8 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
int startCheckY = fullHeight ? 0 : startPerformY; int startCheckY = fullHeight ? 0 : startPerformY;
int endY = region.getMaximumPoint().getBlockY(); int endY = region.getMaximumPoint().getBlockY();
for (BlockVector pos : flat) { for (BlockVector pos : flat) {
int x = (int) pos.x; int x = pos.getBlockX();
int z = (int) pos.z; int z = pos.getBlockZ();
int freeSpot = startCheckY; int freeSpot = startCheckY;
for (int y = startCheckY; y <= endY; y++) { for (int y = startCheckY; y <= endY; y++) {
if (y < startPerformY) { if (y < startPerformY) {
@ -1527,6 +1540,31 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
return this.replaceBlocks(region, mask, pattern); return this.replaceBlocks(region, mask, pattern);
} }
public boolean canBypassAll(Region region, boolean get, boolean set) {
if (wrapped) return false;
FaweRegionExtent regionExtent = getRegionExtent();
if (regionExtent != null) {
if (!(region instanceof CuboidRegion)) return false;
Vector pos1 = region.getMinimumPoint();
Vector pos2 = region.getMaximumPoint();
boolean contains = false;
for (RegionWrapper current : regionExtent.getRegions()) {
if (current.isIn((int) pos1.getX(), pos1.getBlockZ()) && current.isIn((int) pos2.getX(), pos2.getBlockZ())) {
contains = true;
break;
}
}
if (!contains) return false;
}
long area = region.getArea();
FaweLimit left = getLimitLeft();
if (!left.isUnlimited() && (((get || getChangeTask() != null) && left.MAX_CHECKS <= area) || (set && left.MAX_CHANGES <= area))) return false;
if (getChangeTask() != getChangeSet()) return false;
if (!Masks.isNull(getMask()) || !Masks.isNull(getSourceMask())) return false;
if (getBlockBag() != null) return false;
return true;
}
/** /**
* Sets all the blocks inside a region to a given block type. * Sets all the blocks inside a region to a given block type.
* *
@ -1539,10 +1577,17 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
public int setBlocks(final Region region, final BaseBlock block) throws MaxChangedBlocksException { public int setBlocks(final Region region, final BaseBlock block) throws MaxChangedBlocksException {
checkNotNull(region); checkNotNull(region);
checkNotNull(block); checkNotNull(block);
if (canBypassAll(region, false, true)) {
System.out.println("Can bypass");
return changes = queue.setBlocks((CuboidRegion) region, block.getId(), block.getData());
}
System.out.println("Cannot bypasss");
Iterator<BlockVector> iter = region.iterator(); Iterator<BlockVector> iter = region.iterator();
try { try {
while (iter.hasNext()) { while (iter.hasNext()) {
this.extent.setBlock(iter.next(), block); if (this.extent.setBlock(iter.next(), block)) {
changes++;
}
} }
} catch (final MaxChangedBlocksException e) { } catch (final MaxChangedBlocksException e) {
throw e; throw e;
@ -1564,6 +1609,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
public int setBlocks(final Region region, final Pattern pattern) throws MaxChangedBlocksException { public int setBlocks(final Region region, final Pattern pattern) throws MaxChangedBlocksException {
checkNotNull(region); checkNotNull(region);
checkNotNull(pattern); checkNotNull(pattern);
if (pattern instanceof BlockPattern) {
return setBlocks(region, ((BlockPattern) pattern).getBlock());
}
final BlockReplace replace = new BlockReplace(EditSession.this, Patterns.wrap(pattern)); final BlockReplace replace = new BlockReplace(EditSession.this, Patterns.wrap(pattern));
final RegionVisitor visitor = new RegionVisitor(region, replace); final RegionVisitor visitor = new RegionVisitor(region, replace);
Operations.completeSmart(visitor, new Runnable() { Operations.completeSmart(visitor, new Runnable() {
@ -1587,6 +1635,11 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public int replaceBlocks(final Region region, final Set<BaseBlock> filter, final BaseBlock replacement) throws MaxChangedBlocksException { public int replaceBlocks(final Region region, final Set<BaseBlock> filter, final BaseBlock replacement) throws MaxChangedBlocksException {
// if (canBypassAll()) {
// queue.replaceBlocks(regionWrapper, blocks, block);
// return changes = region.getArea();
// }
// TODO fast replace
return this.replaceBlocks(region, filter, new SingleBlockPattern(replacement)); return this.replaceBlocks(region, filter, new SingleBlockPattern(replacement));
} }
@ -1602,10 +1655,17 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public int replaceBlocks(final Region region, final Set<BaseBlock> filter, final Pattern pattern) throws MaxChangedBlocksException { public int replaceBlocks(final Region region, final Set<BaseBlock> filter, final Pattern pattern) throws MaxChangedBlocksException {
if (pattern instanceof BlockPattern) {
return replaceBlocks(region, filter, ((BlockPattern) pattern).getBlock());
}
final Mask mask = filter == null ? new ExistingBlockMask(this) : new FuzzyBlockMask(this, filter); final Mask mask = filter == null ? new ExistingBlockMask(this) : new FuzzyBlockMask(this, filter);
return this.replaceBlocks(region, mask, pattern); return this.replaceBlocks(region, mask, pattern);
} }
// public int replaceBlocks(final Region region, final Mask mask, final BaseBlock block) throws MaxChangedBlocksException {
// TODO
// }
/** /**
* Replaces all the blocks matching a given mask, within a given region, to a block * Replaces all the blocks matching a given mask, within a given region, to a block
* returned by a given pattern. * returned by a given pattern.
@ -1898,9 +1958,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
@Override @Override
// Only copy what's necessary // Only copy what's necessary
public boolean apply(Vector position) throws WorldEditException { public boolean apply(Vector position) throws WorldEditException {
mutable.x = position.x - displace.x; mutable.x = (position.getX() - displace.getX());
mutable.y = position.y - displace.y; mutable.y = (position.getY() - displace.getY());
mutable.z = position.z - displace.z; mutable.z = (position.getZ() - displace.getZ());
if (region.contains(mutable)) { if (region.contains(mutable)) {
return false; return false;
} }
@ -2099,11 +2159,11 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
return this.changes; return this.changes;
} else if (height < 0) { } else if (height < 0) {
height = -height; height = -height;
pos = pos.subtract(0, height, 0); pos.y -= height;
} }
if (pos.getBlockY() < 0) { if (pos.getBlockY() < 0) {
pos = pos.setY(0); pos.y = 0;
} else if (((pos.getBlockY() + height) - 1) > maxY) { } else if (((pos.getBlockY() + height) - 1) > maxY) {
height = (maxY - pos.getBlockY()) + 1; height = (maxY - pos.getBlockY()) + 1;
} }
@ -2686,7 +2746,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
public int hollowOutRegion(final Region region, final int thickness, final Pattern pattern) throws MaxChangedBlocksException { public int hollowOutRegion(final Region region, final int thickness, final Pattern pattern) throws MaxChangedBlocksException {
final Set<BlockVector> outside = new HashSet<BlockVector>(); final Set outside = new LocalBlockVectorSet();
final Vector min = region.getMinimumPoint(); final Vector min = region.getMinimumPoint();
final Vector max = region.getMaximumPoint(); final Vector max = region.getMaximumPoint();
@ -2720,7 +2780,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
for (int i = 1; i < thickness; ++i) { for (int i = 1; i < thickness; ++i) {
final Set<BlockVector> newOutside = new HashSet<BlockVector>(); final Set newOutside = new LocalBlockVectorSet();
outer: for (final BlockVector position : region) { outer: for (final BlockVector position : region) {
for (final Vector recurseDirection : this.recurseDirections) { for (final Vector recurseDirection : this.recurseDirections) {
final BlockVector neighbor = position.add(recurseDirection).toBlockVector(); final BlockVector neighbor = position.add(recurseDirection).toBlockVector();
@ -2766,7 +2826,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
*/ */
public int drawLine(final Pattern pattern, final Vector pos1, final Vector pos2, final double radius, final boolean filled, boolean flat) throws MaxChangedBlocksException { public int drawLine(final Pattern pattern, final Vector pos1, final Vector pos2, final double radius, final boolean filled, boolean flat) throws MaxChangedBlocksException {
Set<Vector> vset = new HashSet<Vector>(); Set vset = new LocalBlockVectorSet();
boolean notdrawn = true; boolean notdrawn = true;
final int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ(); final int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
@ -2840,7 +2900,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
public int drawSpline(final Pattern pattern, final List<Vector> nodevectors, final double tension, final double bias, final double continuity, final double quality, final double radius, public int drawSpline(final Pattern pattern, final List<Vector> nodevectors, final double tension, final double bias, final double continuity, final double quality, final double radius,
final boolean filled) throws MaxChangedBlocksException { final boolean filled) throws MaxChangedBlocksException {
Set<Vector> vset = new HashSet<Vector>(); Set vset = new LocalBlockVectorSet();
final List<Node> nodes = new ArrayList<Node>(nodevectors.size()); final List<Node> nodes = new ArrayList<Node>(nodevectors.size());
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation(); final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
@ -2885,7 +2945,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
private Set<Vector> getBallooned(final Set<Vector> vset, final double radius) { private Set<Vector> getBallooned(final Set<Vector> vset, final double radius) {
final Set<Vector> returnset = new HashSet<Vector>(); final Set returnset = new LocalBlockVectorSet();
final int ceilrad = (int) Math.ceil(radius); final int ceilrad = (int) Math.ceil(radius);
for (final Vector v : vset) { for (final Vector v : vset) {
@ -2904,7 +2964,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
private Set<Vector> getStretched(final Set<Vector> vset, final double radius) { private Set<Vector> getStretched(final Set<Vector> vset, final double radius) {
final Set<Vector> returnset = new HashSet<Vector>(); final Set returnset = new LocalBlockVectorSet();
final int ceilrad = (int) Math.ceil(radius); final int ceilrad = (int) Math.ceil(radius);
for (final Vector v : vset) { for (final Vector v : vset) {
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ(); final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
@ -2920,7 +2980,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
private Set<Vector> getOutline(final Set<Vector> vset) { private Set<Vector> getOutline(final Set<Vector> vset) {
final Set<Vector> returnset = new HashSet<Vector>(); final Set returnset = new LocalBlockVectorSet();
for (final Vector v : vset) { for (final Vector v : vset) {
final double x = v.getX(), y = v.getY(), z = v.getZ(); final double x = v.getX(), y = v.getY(), z = v.getZ();
if (!(vset.contains(new Vector(x + 1, y, z)) if (!(vset.contains(new Vector(x + 1, y, z))
@ -2933,7 +2993,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
private Set<Vector> getHollowed(final Set<Vector> vset) { private Set<Vector> getHollowed(final Set<Vector> vset) {
final Set<Vector> returnset = new HashSet<Vector>(); final Set returnset = new LocalBlockVectorSet();
for (final Vector v : vset) { for (final Vector v : vset) {
final double x = v.getX(), y = v.getY(), z = v.getZ(); final double x = v.getX(), y = v.getY(), z = v.getZ();
if (!(vset.contains(new Vector(x + 1, y, z)) if (!(vset.contains(new Vector(x + 1, y, z))
@ -2948,7 +3008,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
private void recurseHollow(final Region region, final BlockVector origin, final Set<BlockVector> outside) { private void recurseHollow(final Region region, final BlockVector origin, final Set<BlockVector> outside) {
final LinkedList<BlockVector> queue = new LinkedList<BlockVector>(); final ArrayDeque<BlockVector> queue = new ArrayDeque<BlockVector>();
queue.addLast(origin); queue.addLast(origin);
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
@ -3022,7 +3082,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
@Override @Override
public int getBlockLightLevel(Vector position) { public int getBlockLightLevel(Vector position) {
return queue.getEmmittedLight((int) position.x, (int) position.y, (int) position.z); return queue.getEmmittedLight(position.getBlockX(), position.getBlockY(), position.getBlockZ());
} }
@Override @Override
@ -3052,9 +3112,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
private void setExistingBlocks(Vector pos1, Vector pos2) { private void setExistingBlocks(Vector pos1, Vector pos2) {
for (int x = (int) pos1.x; x <= (int) pos2.x; x++) { for (int x = (int) pos1.getX(); x <= (int) pos2.getX(); x++) {
for (int z = (int) pos1.z; z <= (int) pos2.z; z++) { for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
for (int y = (int) pos1.y; y <= (int) pos2.y; y++) { for (int y = (int) pos1.getY(); y <= (int) pos2.getY(); y++) {
int from = queue.getCombinedId4Data(x, y, z); int from = queue.getCombinedId4Data(x, y, z);
short id = (short) (from >> 4); short id = (short) (from >> 4);
byte data = (byte) (from & 0xf); byte data = (byte) (from & 0xf);

View File

@ -34,7 +34,9 @@ public class Vector implements Comparable<Vector> {
public static final Vector UNIT_Z = new Vector(0, 0, 1); public static final Vector UNIT_Z = new Vector(0, 0, 1);
public static final Vector ONE = new Vector(1, 1, 1); public static final Vector ONE = new Vector(1, 1, 1);
public double x, y, z; public double x;
public double y;
public double z;
/** /**
* Construct an instance. * Construct an instance.
@ -102,7 +104,7 @@ public class Vector implements Comparable<Vector> {
* *
* @return the x coordinate * @return the x coordinate
*/ */
public double getX() { public final double getX() {
return x; return x;
} }
@ -112,7 +114,7 @@ public class Vector implements Comparable<Vector> {
* @return the x coordinate * @return the x coordinate
*/ */
public int getBlockX() { public int getBlockX() {
return (int) x; return (int) getX();
} }
/** /**
@ -122,7 +124,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector setX(double x) { public Vector setX(double x) {
return new Vector(x, y, z); return new Vector(x, getY(), getZ());
} }
/** /**
@ -132,7 +134,7 @@ public class Vector implements Comparable<Vector> {
* @return new vector * @return new vector
*/ */
public Vector setX(int x) { public Vector setX(int x) {
return new Vector(x, y, z); return new Vector(x, getY(), getZ());
} }
/** /**
@ -140,7 +142,7 @@ public class Vector implements Comparable<Vector> {
* *
* @return the y coordinate * @return the y coordinate
*/ */
public double getY() { public final double getY() {
return y; return y;
} }
@ -150,7 +152,7 @@ public class Vector implements Comparable<Vector> {
* @return the y coordinate * @return the y coordinate
*/ */
public int getBlockY() { public int getBlockY() {
return (int) (y); return (int) (getY());
} }
/** /**
@ -160,7 +162,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector setY(double y) { public Vector setY(double y) {
return new Vector(x, y, z); return new Vector(getX(), y, getZ());
} }
/** /**
@ -170,7 +172,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector setY(int y) { public Vector setY(int y) {
return new Vector(x, y, z); return new Vector(getX(), y, getZ());
} }
/** /**
@ -178,7 +180,7 @@ public class Vector implements Comparable<Vector> {
* *
* @return the z coordinate * @return the z coordinate
*/ */
public double getZ() { public final double getZ() {
return z; return z;
} }
@ -188,7 +190,7 @@ public class Vector implements Comparable<Vector> {
* @return the z coordinate * @return the z coordinate
*/ */
public int getBlockZ() { public int getBlockZ() {
return (int) (z); return (int) (getZ());
} }
/** /**
@ -198,7 +200,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector setZ(double z) { public Vector setZ(double z) {
return new Vector(x, y, z); return new Vector(getX(), getY(), z);
} }
/** /**
@ -208,7 +210,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector setZ(int z) { public Vector setZ(int z) {
return new Vector(x, y, z); return new Vector(getX(), getY(), z);
} }
/** /**
@ -218,7 +220,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector add(Vector other) { public Vector add(Vector other) {
return new Vector(x + other.x, y + other.y, z + other.z); return new Vector(getX() + other.getX(), getY() + other.getY(), getZ() + other.getZ());
} }
/** /**
@ -230,7 +232,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector add(double x, double y, double z) { public Vector add(double x, double y, double z) {
return new Vector(this.x + x, this.y + y, this.z + z); return new Vector(this.getX() + x, this.getY() + y, this.getZ() + z);
} }
/** /**
@ -242,7 +244,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector add(int x, int y, int z) { public Vector add(int x, int y, int z) {
return new Vector(this.x + x, this.y + y, this.z + z); return new Vector(this.getX() + x, this.getY() + y, this.getZ() + z);
} }
/** /**
@ -253,12 +255,12 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector add(Vector... others) { public Vector add(Vector... others) {
double newX = x, newY = y, newZ = z; double newX = getX(), newY = getY(), newZ = getZ();
for (Vector other : others) { for (Vector other : others) {
newX += other.x; newX += other.getX();
newY += other.y; newY += other.getY();
newZ += other.z; newZ += other.getZ();
} }
return new Vector(newX, newY, newZ); return new Vector(newX, newY, newZ);
@ -272,7 +274,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector subtract(Vector other) { public Vector subtract(Vector other) {
return new Vector(x - other.x, y - other.y, z - other.z); return new Vector(getX() - other.getX(), getY() - other.getY(), getZ() - other.getZ());
} }
/** /**
@ -285,7 +287,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector subtract(double x, double y, double z) { public Vector subtract(double x, double y, double z) {
return new Vector(this.x - x, this.y - y, this.z - z); return new Vector(this.getX() - x, this.getY() - y, this.getZ() - z);
} }
/** /**
@ -298,7 +300,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector subtract(int x, int y, int z) { public Vector subtract(int x, int y, int z) {
return new Vector(this.x - x, this.y - y, this.z - z); return new Vector(this.getX() - x, this.getY() - y, this.getZ() - z);
} }
/** /**
@ -309,12 +311,12 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector subtract(Vector... others) { public Vector subtract(Vector... others) {
double newX = x, newY = y, newZ = z; double newX = getX(), newY = getY(), newZ = getZ();
for (Vector other : others) { for (Vector other : others) {
newX -= other.x; newX -= other.getX();
newY -= other.y; newY -= other.getY();
newZ -= other.z; newZ -= other.getZ();
} }
return new Vector(newX, newY, newZ); return new Vector(newX, newY, newZ);
@ -327,7 +329,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector multiply(Vector other) { public Vector multiply(Vector other) {
return new Vector(x * other.x, y * other.y, z * other.z); return new Vector(getX() * other.getX(), getY() * other.getY(), getZ() * other.getZ());
} }
/** /**
@ -339,7 +341,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector multiply(double x, double y, double z) { public Vector multiply(double x, double y, double z) {
return new Vector(this.x * x, this.y * y, this.z * z); return new Vector(this.getX() * x, this.getY() * y, this.getZ() * z);
} }
/** /**
@ -351,7 +353,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector multiply(int x, int y, int z) { public Vector multiply(int x, int y, int z) {
return new Vector(this.x * x, this.y * y, this.z * z); return new Vector(this.getX() * x, this.getY() * y, this.getZ() * z);
} }
/** /**
@ -361,12 +363,12 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector multiply(Vector... others) { public Vector multiply(Vector... others) {
double newX = x, newY = y, newZ = z; double newX = getX(), newY = getY(), newZ = getZ();
for (Vector other : others) { for (Vector other : others) {
newX *= other.x; newX *= other.getX();
newY *= other.y; newY *= other.getY();
newZ *= other.z; newZ *= other.getZ();
} }
return new Vector(newX, newY, newZ); return new Vector(newX, newY, newZ);
@ -379,7 +381,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector multiply(double n) { public Vector multiply(double n) {
return new Vector(this.x * n, this.y * n, this.z * n); return new Vector(this.getX() * n, this.getY() * n, this.getZ() * n);
} }
/** /**
@ -389,7 +391,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector multiply(float n) { public Vector multiply(float n) {
return new Vector(this.x * n, this.y * n, this.z * n); return new Vector(this.getX() * n, this.getY() * n, this.getZ() * n);
} }
/** /**
@ -399,7 +401,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector multiply(int n) { public Vector multiply(int n) {
return new Vector(this.x * n, this.y * n, this.z * n); return new Vector(this.getX() * n, this.getY() * n, this.getZ() * n);
} }
/** /**
@ -409,7 +411,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector divide(Vector other) { public Vector divide(Vector other) {
return new Vector(x / other.x, y / other.y, z / other.z); return new Vector(getX() / other.getX(), getY() / other.getY(), getZ() / other.getZ());
} }
/** /**
@ -421,7 +423,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector divide(double x, double y, double z) { public Vector divide(double x, double y, double z) {
return new Vector(this.x / x, this.y / y, this.z / z); return new Vector(this.getX() / x, this.getY() / y, this.getZ() / z);
} }
/** /**
@ -433,7 +435,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector divide(int x, int y, int z) { public Vector divide(int x, int y, int z) {
return new Vector(this.x / x, this.y / y, this.z / z); return new Vector(this.getX() / x, this.getY() / y, this.getZ() / z);
} }
/** /**
@ -443,7 +445,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector divide(int n) { public Vector divide(int n) {
return new Vector(x / n, y / n, z / n); return new Vector(getX() / n, getY() / n, getZ() / n);
} }
/** /**
@ -453,7 +455,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector divide(double n) { public Vector divide(double n) {
return new Vector(x / n, y / n, z / n); return new Vector(getX() / n, getY() / n, getZ() / n);
} }
/** /**
@ -463,7 +465,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector divide(float n) { public Vector divide(float n) {
return new Vector(x / n, y / n, z / n); return new Vector(getX() / n, getY() / n, getZ() / n);
} }
/** /**
@ -472,7 +474,7 @@ public class Vector implements Comparable<Vector> {
* @return length * @return length
*/ */
public double length() { public double length() {
return Math.sqrt(x * x + y * y + z * z); return Math.sqrt(getX() * getX() + getY() * getY() + getZ() * getZ());
} }
/** /**
@ -481,7 +483,7 @@ public class Vector implements Comparable<Vector> {
* @return length, squared * @return length, squared
*/ */
public double lengthSq() { public double lengthSq() {
return x * x + y * y + z * z; return getX() * getX() + getY() * getY() + getZ() * getZ();
} }
/** /**
@ -491,9 +493,9 @@ public class Vector implements Comparable<Vector> {
* @return distance * @return distance
*/ */
public double distance(Vector other) { public double distance(Vector other) {
return Math.sqrt(Math.pow(other.x - x, 2) + return Math.sqrt(Math.pow(other.getX() - getX(), 2) +
Math.pow(other.y - y, 2) + Math.pow(other.getY() - getY(), 2) +
Math.pow(other.z - z, 2)); Math.pow(other.getZ() - getZ(), 2));
} }
/** /**
@ -503,9 +505,9 @@ public class Vector implements Comparable<Vector> {
* @return distance * @return distance
*/ */
public double distanceSq(Vector other) { public double distanceSq(Vector other) {
return Math.pow(other.x - x, 2) + return Math.pow(other.getX() - getX(), 2) +
Math.pow(other.y - y, 2) + Math.pow(other.getY() - getY(), 2) +
Math.pow(other.z - z, 2); Math.pow(other.getZ() - getZ(), 2);
} }
/** /**
@ -525,7 +527,7 @@ public class Vector implements Comparable<Vector> {
* @return the dot product of this and the other vector * @return the dot product of this and the other vector
*/ */
public double dot(Vector other) { public double dot(Vector other) {
return x * other.x + y * other.y + z * other.z; return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
} }
/** /**
@ -536,9 +538,9 @@ public class Vector implements Comparable<Vector> {
*/ */
public Vector cross(Vector other) { public Vector cross(Vector other) {
return new Vector( return new Vector(
y * other.z - z * other.y, getY() * other.getZ() - getZ() * other.getY(),
z * other.x - x * other.z, getZ() * other.getX() - getX() * other.getZ(),
x * other.y - y * other.x getX() * other.getY() - getY() * other.getX()
); );
} }
@ -550,7 +552,7 @@ public class Vector implements Comparable<Vector> {
* @return true if the vector is contained * @return true if the vector is contained
*/ */
public boolean containedWithin(Vector min, Vector max) { public boolean containedWithin(Vector min, Vector max) {
return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z; return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max.getY() && getZ() >= min.getZ() && getZ() <= max.getZ();
} }
/** /**
@ -575,7 +577,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector clampY(int min, int max) { public Vector clampY(int min, int max) {
return new Vector(x, Math.max(min, Math.min(max, y)), z); return new Vector(getX(), Math.max(min, Math.min(max, getY())), getZ());
} }
/** /**
@ -584,7 +586,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector floor() { public Vector floor() {
return new Vector(Math.floor(x), Math.floor(y), Math.floor(z)); return new Vector(Math.floor(getX()), Math.floor(getY()), Math.floor(getZ()));
} }
/** /**
@ -593,7 +595,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector ceil() { public Vector ceil() {
return new Vector(Math.ceil(x), Math.ceil(y), Math.ceil(z)); return new Vector(Math.ceil(getX()), Math.ceil(getY()), Math.ceil(getZ()));
} }
/** /**
@ -604,7 +606,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector round() { public Vector round() {
return new Vector(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5)); return new Vector(Math.floor(getX() + 0.5), Math.floor(getY() + 0.5), Math.floor(getZ() + 0.5));
} }
/** /**
@ -614,7 +616,7 @@ public class Vector implements Comparable<Vector> {
* @return a new vector * @return a new vector
*/ */
public Vector positive() { public Vector positive() {
return new Vector(Math.abs(x), Math.abs(y), Math.abs(z)); return new Vector(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
} }
/** /**
@ -630,14 +632,14 @@ public class Vector implements Comparable<Vector> {
*/ */
public Vector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { public Vector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle); angle = Math.toRadians(angle);
double x = this.x - aboutX; double x = this.getX() - aboutX;
double z = this.z - aboutZ; double z = this.getZ() - aboutZ;
double x2 = x * Math.cos(angle) - z * Math.sin(angle); double x2 = x * Math.cos(angle) - z * Math.sin(angle);
double z2 = x * Math.sin(angle) + z * Math.cos(angle); double z2 = x * Math.sin(angle) + z * Math.cos(angle);
return new Vector( return new Vector(
x2 + aboutX + translateX, x2 + aboutX + translateX,
y, getY(),
z2 + aboutZ + translateZ z2 + aboutZ + translateZ
); );
} }
@ -649,35 +651,35 @@ public class Vector implements Comparable<Vector> {
* @return true if collinear * @return true if collinear
*/ */
public boolean isCollinearWith(Vector other) { public boolean isCollinearWith(Vector other) {
if (x == 0 && y == 0 && z == 0) { if (getX() == 0 && getY() == 0 && getZ() == 0) {
// this is a zero vector // this is a zero vector
return true; return true;
} }
final double otherX = other.x; final double otherX = other.getX();
final double otherY = other.y; final double otherY = other.getY();
final double otherZ = other.z; final double otherZ = other.getZ();
if (otherX == 0 && otherY == 0 && otherZ == 0) { if (otherX == 0 && otherY == 0 && otherZ == 0) {
// other is a zero vector // other is a zero vector
return true; return true;
} }
if ((x == 0) != (otherX == 0)) return false; if ((getX() == 0) != (otherX == 0)) return false;
if ((y == 0) != (otherY == 0)) return false; if ((getY() == 0) != (otherY == 0)) return false;
if ((z == 0) != (otherZ == 0)) return false; if ((getZ() == 0) != (otherZ == 0)) return false;
final double quotientX = otherX / x; final double quotientX = otherX / getX();
if (!Double.isNaN(quotientX)) { if (!Double.isNaN(quotientX)) {
return other.equals(multiply(quotientX)); return other.equals(multiply(quotientX));
} }
final double quotientY = otherY / y; final double quotientY = otherY / getY();
if (!Double.isNaN(quotientY)) { if (!Double.isNaN(quotientY)) {
return other.equals(multiply(quotientY)); return other.equals(multiply(quotientY));
} }
final double quotientZ = otherZ / z; final double quotientZ = otherZ / getZ();
if (!Double.isNaN(quotientZ)) { if (!Double.isNaN(quotientZ)) {
return other.equals(multiply(quotientZ)); return other.equals(multiply(quotientZ));
} }
@ -742,9 +744,9 @@ public class Vector implements Comparable<Vector> {
*/ */
public BlockVector toBlockPoint() { public BlockVector toBlockPoint() {
return new BlockVector( return new BlockVector(
Math.floor(x), Math.floor(getX()),
Math.floor(y), Math.floor(getY()),
Math.floor(z) Math.floor(getZ())
); );
} }
@ -763,7 +765,7 @@ public class Vector implements Comparable<Vector> {
* @return a new {@code Vector2D} * @return a new {@code Vector2D}
*/ */
public Vector2D toVector2D() { public Vector2D toVector2D() {
return new Vector2D(x, z); return new Vector2D(getX(), getZ());
} }
@Override @Override
@ -773,7 +775,7 @@ public class Vector implements Comparable<Vector> {
} }
Vector other = (Vector) obj; Vector other = (Vector) obj;
return other.x == this.x && other.z == this.z && other.y == this.y; return other.getX() == this.getX() && other.getZ() == this.getZ() && other.getY() == this.getY();
} }
@Override @Override
@ -781,20 +783,20 @@ public class Vector implements Comparable<Vector> {
if (other == null) { if (other == null) {
throw new IllegalArgumentException("null not supported"); throw new IllegalArgumentException("null not supported");
} }
if (y != other.y) return Double.compare(y, other.y); if (getY() != other.getY()) return Double.compare(getY(), other.getY());
if (z != other.z) return Double.compare(z, other.z); if (getZ() != other.getZ()) return Double.compare(getZ(), other.getZ());
if (x != other.x) return Double.compare(x, other.x); if (getX() != other.getX()) return Double.compare(getX(), other.getX());
return 0; return 0;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return (int) x ^ ((int) z << 16) ^ ((byte) y << 31); return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30);
} }
@Override @Override
public String toString() { public String toString() {
return "(" + x + ", " + y + ", " + z + ")"; return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
} }
/** /**
@ -806,9 +808,9 @@ public class Vector implements Comparable<Vector> {
*/ */
public static Vector getMinimum(Vector v1, Vector v2) { public static Vector getMinimum(Vector v1, Vector v2) {
return new Vector( return new Vector(
Math.min(v1.x, v2.x), Math.min(v1.getX(), v2.getX()),
Math.min(v1.y, v2.y), Math.min(v1.getY(), v2.getY()),
Math.min(v1.z, v2.z) Math.min(v1.getZ(), v2.getZ())
); );
} }
@ -821,9 +823,9 @@ public class Vector implements Comparable<Vector> {
*/ */
public static Vector getMaximum(Vector v1, Vector v2) { public static Vector getMaximum(Vector v1, Vector v2) {
return new Vector( return new Vector(
Math.max(v1.x, v2.x), Math.max(v1.getX(), v2.getX()),
Math.max(v1.y, v2.y), Math.max(v1.getY(), v2.getY()),
Math.max(v1.z, v2.z) Math.max(v1.getZ(), v2.getZ())
); );
} }
@ -836,9 +838,9 @@ public class Vector implements Comparable<Vector> {
*/ */
public static Vector getMidpoint(Vector v1, Vector v2) { public static Vector getMidpoint(Vector v1, Vector v2) {
return new Vector( return new Vector(
(v1.x + v2.x) / 2, (v1.getX() + v2.getX()) / 2,
(v1.y + v2.y) / 2, (v1.getY() + v2.getY()) / 2,
(v1.z + v2.z) / 2 (v1.getZ() + v2.getZ()) / 2
); );
} }

View File

@ -321,7 +321,7 @@ public class ClipboardCommands {
selector.learnChanges(); selector.learnChanges();
selector.explainRegionAdjust(player, session); selector.explainRegionAdjust(player, session);
} }
BBC.COMMAND_PASTE.send(player); BBC.COMMAND_PASTE.send(player, to);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(player, to); if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(player, to);
} }
@ -367,7 +367,7 @@ public class ClipboardCommands {
pos.x += relx; pos.x += relx;
pos.y += rely; pos.y += rely;
pos.z += relz; pos.z += relz;
if (pos.y >= 0 && pos.y <= maxY) { if (pos.getY() >= 0 && pos.getY() <= maxY) {
editSession.setBlockFast(pos, block); editSession.setBlockFast(pos, block);
} }
} }
@ -387,7 +387,7 @@ public class ClipboardCommands {
loc.x += relx; loc.x += relx;
loc.y += rely; loc.y += rely;
loc.z += relz; loc.z += relz;
if (loc.y >= 0 && loc.y <= maxY) { if (loc.getY() >= 0 && loc.getY() <= maxY) {
editSession.setBlockFast(loc, block); editSession.setBlockFast(loc, block);
} }
} }

View File

@ -301,9 +301,9 @@ public class GenerationCommands {
zero = max.add(min).multiply(0.5); zero = max.add(min).multiply(0.5);
unit = max.subtract(zero); unit = max.subtract(zero);
if (unit.getX() == 0) unit = unit.setX(1.0); if (unit.getX() == 0) unit.x = 1;
if (unit.getY() == 0) unit = unit.setY(1.0); if (unit.getY() == 0) unit.y = 1;
if (unit.getZ() == 0) unit = unit.setZ(1.0); if (unit.getZ() == 0) unit.z = 1;
} }
try { try {
@ -366,9 +366,9 @@ public class GenerationCommands {
zero = max.add(min).multiply(0.5); zero = max.add(min).multiply(0.5);
unit = max.subtract(zero); unit = max.subtract(zero);
if (unit.getX() == 0) unit = unit.setX(1.0); if (unit.getX() == 0) unit.x = 1;
if (unit.getY() == 0) unit = unit.setY(1.0); if (unit.getY() == 0) unit.y = 1;
if (unit.getZ() == 0) unit = unit.setZ(1.0); if (unit.getZ() == 0) unit.z = 1;
} }
try { try {

View File

@ -170,9 +170,9 @@ public class HistoryCommands {
final World world = player.getWorld(); final World world = player.getWorld();
WorldVector origin = player.getPosition(); WorldVector origin = player.getPosition();
Vector bot = origin.subtract(radius, radius, radius); Vector bot = origin.subtract(radius, radius, radius);
bot = bot.setY(Math.max(0, bot.getY())); bot.y = Math.max(0, bot.getY());
Vector top = origin.add(radius, radius, radius); Vector top = origin.add(radius, radius, radius);
top = top.setY(Math.min(255, top.getY())); top.y = Math.min(255, top.getY());
RollbackDatabase database = DBHandler.IMP.getDatabase(world); RollbackDatabase database = DBHandler.IMP.getDatabase(world);
final AtomicInteger count = new AtomicInteger(); final AtomicInteger count = new AtomicInteger();
final FawePlayer fp = FawePlayer.wrap(player); final FawePlayer fp = FawePlayer.wrap(player);

View File

@ -22,13 +22,9 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweLocation; import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.SetQueue;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
@ -48,7 +44,6 @@ import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.generator.ForestGenerator; import com.sk89q.worldedit.function.generator.ForestGenerator;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.NoiseFilter2D; import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
@ -172,7 +167,7 @@ public class RegionCommands {
final int cz = loc.z >> 4; final int cz = loc.z >> 4;
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) SetQueue.IMP.getNewQueue(fp.getWorld(), true, false); final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) SetQueue.IMP.getNewQueue(fp.getWorld(), true, false);
for (Vector pt : region) { for (Vector pt : region) {
queue.setBlockLight((int) pt.x, (int) pt.y, (int) pt.z, value); queue.setBlockLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value);
} }
int count = 0; int count = 0;
for (Vector2D chunk : region.getChunks()) { for (Vector2D chunk : region.getChunks()) {
@ -196,7 +191,7 @@ public class RegionCommands {
final int cz = loc.z >> 4; final int cz = loc.z >> 4;
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) SetQueue.IMP.getNewQueue(fp.getWorld(), true, false); final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) SetQueue.IMP.getNewQueue(fp.getWorld(), true, false);
for (Vector pt : region) { for (Vector pt : region) {
queue.setSkyLight((int) pt.x, (int) pt.y, (int) pt.z, value); queue.setSkyLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value);
} }
int count = 0; int count = 0;
for (Vector2D chunk : region.getChunks()) { for (Vector2D chunk : region.getChunks()) {
@ -320,63 +315,6 @@ public class RegionCommands {
@CommandPermissions("worldedit.region.set") @CommandPermissions("worldedit.region.set")
@Logging(REGION) @Logging(REGION)
public void set(Player player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to) throws WorldEditException { public void set(Player player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to) throws WorldEditException {
if (selection instanceof CuboidRegion && (editSession.hasFastMode() || (editSession.getRegionExtent() == null && editSession.getChangeTask() != null)) && to instanceof BlockPattern && Masks.isNull(session.getMask()) && Masks.isNull(session.getSourceMask())) {
if (session.getMask() == null && session.getSourceMask() == null)
try {
CuboidRegion cuboid = (CuboidRegion) selection;
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
BaseBlock block = ((BlockPattern) to).getBlock();
final FaweQueue queue = editSession.getQueue();
final int minY = cuboid.getMinimumY();
final int maxY = cuboid.getMaximumY();
final int id = block.getId();
final byte data = (byte) block.getData();
final FaweChunk<?> fc = queue.getFaweChunk(0, 0);
fc.fillCuboid(0, 15, minY, maxY, 0, 15, id, data);
fc.optimize();
int bcx = (current.minX) >> 4;
int bcz = (current.minZ) >> 4;
int tcx = (current.maxX) >> 4;
int tcz = (current.maxZ) >> 4;
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
MainUtil.chunkTaskSync(current, new RunnableVal<int[]>() {
@Override
public void run(int[] value) {
FaweChunk newChunk;
if (value[6] == 0) {
newChunk = fc.copy(true);
newChunk.setLoc(queue, value[0], value[1]);
} else {
int bx = value[2] & 15;
int tx = value[4] & 15;
int bz = value[3] & 15;
int tz = value[5] & 15;
if (bx == 0 && tx == 15 && bz == 0 && tz == 15) {
newChunk = fc.copy(true);
newChunk.setLoc(queue, value[0], value[1]);
} else {
newChunk = queue.getFaweChunk(value[0], value[1]);
newChunk.fillCuboid(value[2] & 15, value[4] & 15, minY, maxY, value[3] & 15, value[5] & 15, id, data);
}
}
newChunk.addToQueue();
}
});
int volume = cuboid.getArea();
editSession.setSize(volume);
queue.enqueue();
long start = System.currentTimeMillis();
BBC.OPERATION.send(player, BBC.VISITOR_BLOCK.format(volume));
queue.flush();
BBC.ACTION_COMPLETE.send(player, (System.currentTimeMillis() - start) / 1000d);
return;
} catch (Throwable e) {
MainUtil.handleError(e);
}
}
int affected; int affected;
if (to instanceof BlockPattern) { if (to instanceof BlockPattern) {
affected = editSession.setBlocks(selection, ((BlockPattern) to).getBlock()); affected = editSession.setBlocks(selection, ((BlockPattern) to).getBlock());
@ -657,9 +595,9 @@ public class RegionCommands {
zero = max.add(min).multiply(0.5); zero = max.add(min).multiply(0.5);
unit = max.subtract(zero); unit = max.subtract(zero);
if (unit.getX() == 0) unit = unit.setX(1.0); if (unit.getX() == 0) unit.x = 1;
if (unit.getY() == 0) unit = unit.setY(1.0); if (unit.getY() == 0) unit.y = 1;
if (unit.getZ() == 0) unit = unit.setZ(1.0); if (unit.getZ() == 0) unit.z = 1;
} }
try { try {

View File

@ -337,9 +337,12 @@ public final class CommandManager {
BBC.WORLDEDIT_CANCEL_REASON.send(finalActor, faweException.getMessage()); BBC.WORLDEDIT_CANCEL_REASON.send(finalActor, faweException.getMessage());
} else { } else {
Throwable t = e.getCause(); Throwable t = e.getCause();
finalActor.printError("Please report this error: [See console]"); while (t.getCause() != null) {
t = t.getCause();
}
finalActor.printError("There was an error handling a FAWE command: [See console]");
finalActor.printRaw(t.getClass().getName() + ": " + t.getMessage()); finalActor.printRaw(t.getClass().getName() + ": " + t.getMessage());
log.log(Level.SEVERE, "An unexpected error while handling a WorldEdit command", t); log.log(Level.SEVERE, "An unexpected error occurred while handling a FAWE command", t);
} }
} catch (CommandException e) { } catch (CommandException e) {
String message = e.getMessage(); String message = e.getMessage();

View File

@ -77,9 +77,9 @@ public class SchematicWriter implements ClipboardWriter {
@Override @Override
public void run(Vector point, BaseBlock block) { public void run(Vector point, BaseBlock block) {
int x = (int) point.x; int x = (int) point.getX();
int y = (int) point.y; int y = (int) point.getY();
int z = (int) point.z; int z = (int) point.getZ();
if (this.x == x - 1 && this.y == y && this.z == z) { if (this.x == x - 1 && this.y == y && this.z == z) {
this.x++; this.x++;
index++; index++;
@ -289,9 +289,9 @@ public class SchematicWriter implements ClipboardWriter {
Vector mutable = new Vector(0, 0, 0); Vector mutable = new Vector(0, 0, 0);
ForEach forEach = new ForEach(yarea, zwidth, blocks, blockData, tileEntities); ForEach forEach = new ForEach(yarea, zwidth, blocks, blockData, tileEntities);
for (Vector point : region) { for (Vector point : region) {
mutable.x = point.x - mx; mutable.x = (point.getX() - mx);
mutable.y = point.y - my; mutable.y = (point.getY() - my);
mutable.z = point.z - mz; mutable.z = (point.getZ() - mz);
forEach.run(mutable, clipboard.getBlock(point)); forEach.run(mutable, clipboard.getBlock(point));
} }
addBlocks = forEach.addBlocks; addBlocks = forEach.addBlocks;

View File

@ -101,9 +101,9 @@ public class ExtentBlockCopy implements RegionFunction {
if (direction != null) { if (direction != null) {
Vector applyAbsolute = transform.apply(direction.toVector()); Vector applyAbsolute = transform.apply(direction.toVector());
Vector applyOrigin = transform.apply(Vector.ZERO); Vector applyOrigin = transform.apply(Vector.ZERO);
applyAbsolute.x -= applyOrigin.x; applyAbsolute.x -= applyOrigin.getX();
applyAbsolute.y -= applyOrigin.y; applyAbsolute.y -= applyOrigin.getY();
applyAbsolute.z -= applyOrigin.z; applyAbsolute.z -= applyOrigin.getZ();
Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL); Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);

View File

@ -84,6 +84,10 @@ public class BlockMask extends AbstractExtentMask {
computedLegacyList = null; computedLegacyList = null;
} }
public boolean[] getBlockArray() {
return blockIds;
}
/** /**
* Get the list of blocks that are tested with. * Get the list of blocks that are tested with.
* *

View File

@ -1,6 +1,5 @@
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import java.util.Collection; import java.util.Collection;
@ -15,18 +14,6 @@ public class FuzzyBlockMask extends BlockMask {
super(extent, block); super(extent, block);
} }
@Override
public boolean test(Vector vector) {
Extent extent = getExtent();
Collection<BaseBlock> blocks = getBlocks();
BaseBlock lazyBlock = extent.getBlock(vector);
if (lazyBlock.getData() == -1) {
return test(lazyBlock.getId());
} else {
return test(lazyBlock.getId(), lazyBlock.getData());
}
}
public static Class<?> inject() { public static Class<?> inject() {
return FuzzyBlockMask.class; return FuzzyBlockMask.class;
} }

View File

@ -69,9 +69,9 @@ public class OffsetMask extends AbstractMask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
mutable.x = vector.x + offset.x; mutable.x = (vector.getX() + offset.getX());
mutable.y = vector.y + offset.y; mutable.y = (vector.getY() + offset.getY());
mutable.z = vector.z + offset.z; mutable.z = (vector.getZ() + offset.getZ());
return getMask().test(mutable); return getMask().test(mutable);
} }

View File

@ -40,9 +40,9 @@ public class ClipboardPattern extends AbstractPattern {
if (xp < 0) xp += sx; if (xp < 0) xp += sx;
if (yp < 0) yp += sy; if (yp < 0) yp += sy;
if (zp < 0) zp += sz; if (zp < 0) zp += sz;
mutable.x = min.x + xp; mutable.x = (min.getX() + xp);
mutable.y = min.y + yp; mutable.y = (min.getY() + yp);
mutable.z = min.z + zp; mutable.z = (min.getZ() + zp);
return clipboard.getBlock(mutable); return clipboard.getBlock(mutable);
} }

View File

@ -57,7 +57,7 @@ public abstract class BreadthFirstSearch implements Operation {
} }
public void visit(final Vector pos) { public void visit(final Vector pos) {
Node node = new Node((int) pos.x, (int) pos.y, (int) pos.z); Node node = new Node(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
if (!isVisited(node)) { if (!isVisited(node)) {
isVisitable(pos, pos); // Ignore this, just to initialize mask on this point isVisitable(pos, pos); // Ignore this, just to initialize mask on this point
queue.add(node); queue.add(node);

View File

@ -158,9 +158,9 @@ public class KochanekBartelsInterpolation implements Interpolation {
double r2 = remainder * remainder; double r2 = remainder * remainder;
double r3 = r2 * remainder; double r3 = r2 * remainder;
mutable.x = a.x * r3 + b.x * r2 + c.x * remainder + d.x; mutable.x = (a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX());
mutable.y = a.y * r3 + b.y * r2 + c.y * remainder + d.y; mutable.y = (a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY());
mutable.z = a.z * r3 + b.z * r2 + c.z * remainder + d.z; mutable.z = (a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ());
return mutable; return mutable;
} }

View File

@ -274,13 +274,14 @@ public class AffineTransform implements Transform {
// vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03 // vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03
// vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13 // vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13
// vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23 // vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23
mutable.x = vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03; mutable.x = (vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03);
mutable.y = vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13; mutable.y = (vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13);
mutable.z = vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23; mutable.z = (vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
return new Vector( return mutable;
vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03, // return new Vector(
vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13, // vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23); // vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13,
// vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
} }
public AffineTransform combine(AffineTransform other) { public AffineTransform combine(AffineTransform other) {

View File

@ -20,13 +20,13 @@
package com.sk89q.worldedit.regions; package com.sk89q.worldedit.regions;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.ChunkStore;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
@ -330,7 +330,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override @Override
public Set<Vector> getChunkCubes() { public Set<Vector> getChunkCubes() {
Set<Vector> chunks = new HashSet<Vector>(); Set chunks = new LocalBlockVectorSet();
Vector min = getMinimumPoint(); Vector min = getMinimumPoint();
Vector max = getMaximumPoint(); Vector max = getMaximumPoint();

View File

@ -174,6 +174,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} else { } else {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) { for (Entity entity : ents) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
@ -182,10 +183,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
int x = ((int) Math.round(entity.posX) & 15); int x = ((int) Math.round(entity.posX) & 15);
int z = ((int) Math.round(entity.posZ) & 15); int z = ((int) Math.round(entity.posZ) & 15);
int y = (int) Math.round(entity.posY); int y = (int) Math.round(entity.posY);
if (array == null) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity);
} }
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) { }
}
}
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }
@ -246,17 +256,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
iterator.remove(); iterator.remove();
} }
} }
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
}
}
}
}
// Efficiently merge sections // Efficiently merge sections
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {
int count = this.getCount(j); int count = this.getCount(j);
@ -290,8 +289,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
getParent().setCount(0, count - this.getAir(j), section); getParent().setCount(0, count - this.getAir(j), section);
continue; continue;
} else {
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
} }
} }
IBlockState existing; IBlockState existing;

View File

@ -168,16 +168,22 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
// Set heightmap // Set heightmap
getParent().setHeightMap(this, heightMap); getParent().setHeightMap(this, heightMap);
// Remove entities // Remove entities
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
int count = this.getCount(i); int count = this.getCount(i);
if (count == 0) { if (count == 0) {
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
ClassInheritanceMultiMap<Entity> ents = entities[i];
if (ents != null && !ents.isEmpty()) {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
for (Entity ent : ents) {
nmsWorld.removeEntity(ent);
}
}
} else { } else {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) { for (Entity entity : ents) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
@ -186,10 +192,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
int x = ((int) Math.round(entity.posX) & 15); int x = ((int) Math.round(entity.posX) & 15);
int z = ((int) Math.round(entity.posZ) & 15); int z = ((int) Math.round(entity.posZ) & 15);
int y = (int) Math.round(entity.posY); int y = (int) Math.round(entity.posY);
if (array == null) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity);
} }
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) { }
}
}
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (!entsToRemove.isEmpty()) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }
@ -260,17 +275,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
iterator.remove(); iterator.remove();
} }
} }
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
}
}
}
}
// Efficiently merge sections // Efficiently merge sections
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {
int count = this.getCount(j); int count = this.getCount(j);
@ -304,8 +308,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
getParent().setCount(0, count - this.getAir(j), section); getParent().setCount(0, count - this.getAir(j), section);
continue; continue;
} else {
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
} }
} }
IBlockState existing; IBlockState existing;

View File

@ -150,6 +150,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
entities[i].clear(); entities[i].clear();
} else { } else {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) { for (Entity entity : ents) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
@ -158,10 +159,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
int x = ((int) Math.round(entity.posX) & 15); int x = ((int) Math.round(entity.posX) & 15);
int z = ((int) Math.round(entity.posZ) & 15); int z = ((int) Math.round(entity.posZ) & 15);
int y = (int) Math.round(entity.posY); int y = (int) Math.round(entity.posY);
if (array == null) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity);
} }
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) { }
}
}
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }
@ -220,17 +230,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
iterator.remove(); iterator.remove();
} }
} }
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
}
}
}
}
// Efficiently merge sections // Efficiently merge sections
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {
int count = this.getCount(j); int count = this.getCount(j);

View File

@ -93,6 +93,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} else { } else {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) { for (Entity entity : ents) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
@ -101,10 +102,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
int x = ((int) Math.round(entity.posX) & 15); int x = ((int) Math.round(entity.posX) & 15);
int z = ((int) Math.round(entity.posZ) & 15); int z = ((int) Math.round(entity.posZ) & 15);
int y = (int) Math.round(entity.posY); int y = (int) Math.round(entity.posY);
if (array == null) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity);
} }
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) { }
}
}
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }
@ -163,17 +173,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
iterator.remove(); iterator.remove();
} }
} }
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
}
}
}
}
// Efficiently merge sections // Efficiently merge sections
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {
int count = this.getCount(j); int count = this.getCount(j);

View File

@ -174,6 +174,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} else { } else {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) { for (Entity entity : ents) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
@ -182,10 +183,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
int x = ((int) Math.round(entity.posX) & 15); int x = ((int) Math.round(entity.posX) & 15);
int z = ((int) Math.round(entity.posZ) & 15); int z = ((int) Math.round(entity.posZ) & 15);
int y = (int) Math.round(entity.posY); int y = (int) Math.round(entity.posY);
if (array == null) { if (y < 0 || y > 255) continue;
continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
nmsWorld.removeEntity(entity);
} }
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) { }
}
}
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity); nmsWorld.removeEntity(entity);
} }
} }
@ -244,17 +254,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
iterator.remove(); iterator.remove();
} }
} }
HashSet<UUID> entsToRemove = this.getEntityRemoves();
if (entsToRemove.size() > 0) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
}
}
}
}
// Efficiently merge sections // Efficiently merge sections
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {
int count = this.getCount(j); int count = this.getCount(j);
@ -288,8 +287,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
getParent().setCount(0, count - this.getAir(j), section); getParent().setCount(0, count - this.getAir(j), section);
continue; continue;
} else {
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
} }
} }
IBlockState existing; IBlockState existing;