mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-29 12:37:53 +01:00
Various
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:
parent
674d40f19c
commit
bc677f823e
@ -208,6 +208,7 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
|
||||
Collection<Entity> ents = entities[i];
|
||||
if (!ents.isEmpty()) {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
ents = new ArrayList<>(entities[i]);
|
||||
synchronized (BukkitQueue_0.adapter) {
|
||||
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 z = ((int) Math.round(entity.locZ) & 15);
|
||||
int y = (int) Math.round(entity.locY);
|
||||
if (array == null || y < 0 || y > 255) {
|
||||
continue;
|
||||
}
|
||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
if (y < 0 || y > 255) continue;
|
||||
if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
nmsWorld.removeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
@ -186,9 +186,24 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
|
||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||
// copy
|
||||
// BukkitChunk_1_11 copy = getParent().getFaweChunk(getX(), getZ()); // TODO
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
// 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++) {
|
||||
int count = this.getCount(i);
|
||||
if (count == 0) {
|
||||
@ -196,6 +211,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
} else if (count >= 4096) {
|
||||
Collection<Entity> ents = entities[i];
|
||||
if (!ents.isEmpty()) {
|
||||
// copy.storeEntities(this, i);
|
||||
synchronized (BukkitQueue_0.adapter) {
|
||||
ents.clear();
|
||||
}
|
||||
@ -204,6 +220,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
Collection<Entity> ents = entities[i];
|
||||
if (!ents.isEmpty()) {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
ents = new ArrayList<>(entities[i]);
|
||||
synchronized (BukkitQueue_0.adapter) {
|
||||
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 z = ((int) Math.round(entity.locZ) & 15);
|
||||
int y = (int) Math.round(entity.locY);
|
||||
if (array == null || y < 0 || y > 255) {
|
||||
continue;
|
||||
}
|
||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
if (y < 0 || y > 255) continue;
|
||||
if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
// copy.storeEntity(this, 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<CompoundTag> entitiesToSpawn = this.getEntities();
|
||||
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
|
||||
Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
|
||||
HashMap<BlockPosition, TileEntity> toRemove = null;
|
||||
@ -316,6 +314,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
}
|
||||
}
|
||||
if (toRemove != null) {
|
||||
// copy.storeTiles(this, toRemove);
|
||||
for (Map.Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
|
||||
BlockPosition bp = entry.getKey();
|
||||
TileEntity tile = entry.getValue();
|
||||
@ -338,6 +337,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
continue;
|
||||
}
|
||||
ChunkSection section = sections[j];
|
||||
// copy.storeBlocks(this, section);
|
||||
if (section == null) {
|
||||
if (count == countAir) {
|
||||
continue;
|
||||
@ -349,8 +349,8 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
continue;
|
||||
} else {
|
||||
sections[j] = getParent().newChunkSection(j << 4, flag, array);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
} else if (count >= 4096) {
|
||||
if (countAir >= 4096) {
|
||||
sections[j] = null;
|
||||
@ -362,8 +362,8 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
continue;
|
||||
} else {
|
||||
sections[j] = getParent().newChunkSection(j << 4, flag, array);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int by = j << 4;
|
||||
DataPaletteBlock nibble = section.getBlocks();
|
||||
@ -407,6 +407,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
// Set biomes
|
||||
int[][] biomes = this.biomes;
|
||||
if (biomes != null) {
|
||||
// copy.storeBiomes(this);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int[] array = biomes[x];
|
||||
if (array == null) {
|
||||
@ -436,6 +437,10 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
tileEntity.a(tag); // ReadTagIntoTile
|
||||
}
|
||||
}
|
||||
// Change task?
|
||||
// if (getParent().getChangeTask() != null) { // TODO
|
||||
// getParent().getChangeTask().run(copy, this);
|
||||
// }
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
|
@ -170,6 +170,7 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
||||
Collection<Entity> ents = entities[i];
|
||||
if (!ents.isEmpty()) {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
ents = new ArrayList<>(entities[i]);
|
||||
synchronized (BukkitQueue_0.adapter) {
|
||||
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 z = ((int) Math.round(entity.locZ) & 15);
|
||||
int y = (int) Math.round(entity.locY);
|
||||
if (array == null || y < 0 || y > 255) {
|
||||
continue;
|
||||
}
|
||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
if (y < 0 || y > 255) continue;
|
||||
if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
nmsWorld.removeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
||||
Collection<Entity> ents = entities[i];
|
||||
if (!ents.isEmpty()) {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
ents = new ArrayList<>(entities[i]);
|
||||
synchronized (BukkitQueue_0.adapter) {
|
||||
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 z = ((int) Math.round(entity.locZ) & 15);
|
||||
int y = (int) Math.round(entity.locY);
|
||||
if (array == null || y < 0 || y > 255) {
|
||||
continue;
|
||||
}
|
||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
if (y < 0 || y > 255) continue;
|
||||
if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
nmsWorld.removeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
@ -210,6 +210,7 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
||||
Collection<Entity> ents = entities[i];
|
||||
if (!ents.isEmpty()) {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
ents = new ArrayList<>(entities[i]);
|
||||
synchronized (BukkitQueue_0.adapter) {
|
||||
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 z = ((int) Math.round(entity.locZ) & 15);
|
||||
int y = (int) Math.round(entity.locY);
|
||||
if (array == null || y < 0 || y > 255) {
|
||||
continue;
|
||||
}
|
||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
if (y < 0 || y > 255) continue;
|
||||
if (array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||
nmsWorld.removeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,11 @@ public class Settings extends Config {
|
||||
" - History on disk or memory will be deleted",
|
||||
})
|
||||
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;
|
||||
@Comment({
|
||||
"Should WorldEdit use inventory?",
|
||||
|
@ -52,7 +52,7 @@ public class MCAWorld extends LocalWorld {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -372,7 +372,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
public void setSelection(final RegionWrapper region) {
|
||||
final Player player = this.getPlayer();
|
||||
Vector top = region.getTopVector();
|
||||
top.setY(getWorld().getMaxY());
|
||||
top.y = getWorld().getMaxY();
|
||||
final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), top);
|
||||
this.getSession().setRegionSelector(player.getWorld(), selector);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
@ -138,6 +139,48 @@ public abstract class FaweQueue {
|
||||
|
||||
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 boolean setBlock(int x, int y, int z, int id) {
|
||||
|
@ -97,12 +97,12 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
|
@ -123,9 +123,9 @@ public class SplineBrush implements DoubleActionBrush {
|
||||
private Vector getCentroid(Collection<Vector> points) {
|
||||
Vector sum = new Vector();
|
||||
for (Vector p : points) {
|
||||
sum.x += p.x;
|
||||
sum.y += p.y;
|
||||
sum.z += p.z;
|
||||
sum.x += p.getX();
|
||||
sum.y += p.getY();
|
||||
sum.z += p.getZ();
|
||||
}
|
||||
return sum.multiply(1.0 / points.size());
|
||||
}
|
||||
@ -147,15 +147,15 @@ public class SplineBrush implements DoubleActionBrush {
|
||||
|
||||
Vector r = new Vector();
|
||||
for (Vector p : points) {
|
||||
r.x = p.x - centroid.x;
|
||||
r.y = p.y - centroid.y;
|
||||
r.z = p.z - centroid.z;
|
||||
xx += r.x * r.x;
|
||||
xy += r.x * r.y;
|
||||
xz += r.x * r.z;
|
||||
yy += r.y * r.y;
|
||||
yz += r.y * r.z;
|
||||
zz += r.z * r.z;
|
||||
r.x = (p.getX() - centroid.getX());
|
||||
r.y = (p.getY() - centroid.getY());
|
||||
r.z = (p.getZ() - centroid.getZ());
|
||||
xx += r.getX() * r.getX();
|
||||
xy += r.getX() * r.getY();
|
||||
xz += r.getX() * r.getZ();
|
||||
yy += r.getY() * r.getY();
|
||||
yz += r.getY() * r.getZ();
|
||||
zz += r.getZ() * r.getZ();
|
||||
}
|
||||
|
||||
double det_x = yy*zz - yz*yz;
|
||||
|
@ -61,7 +61,7 @@ public class ScalableHeightMap {
|
||||
int clipHeight = maxY - minY + 1;
|
||||
HashSet<IntegerPair> visited = new HashSet<>();
|
||||
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)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ public abstract class FaweClipboard {
|
||||
CompoundTag tag = block.getNbtData();
|
||||
if (tag != null) {
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
|
||||
values.put("x", new IntTag((int) pos.x));
|
||||
values.put("y", new IntTag((int) pos.y));
|
||||
values.put("z", new IntTag((int) pos.z));
|
||||
values.put("x", new IntTag(pos.getBlockX()));
|
||||
values.put("y", new IntTag(pos.getBlockY()));
|
||||
values.put("z", new IntTag(pos.getBlockZ()));
|
||||
tiles.add(tag);
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +59,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
CompoundTag tag = block.getNbtData();
|
||||
if (tag != null) {
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
|
||||
values.put("x", new IntTag((int) pos.x));
|
||||
values.put("y", new IntTag((int) pos.y));
|
||||
values.put("z", new IntTag((int) pos.z));
|
||||
values.put("x", new IntTag(pos.getBlockX()));
|
||||
values.put("y", new IntTag(pos.getBlockY()));
|
||||
values.put("z", new IntTag(pos.getBlockZ()));
|
||||
}
|
||||
task.run(pos, block);
|
||||
}
|
||||
@ -81,9 +81,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
CompoundTag tag = block.getNbtData();
|
||||
if (tag != null) {
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
|
||||
values.put("x", new IntTag((int) pos.x));
|
||||
values.put("y", new IntTag((int) pos.y));
|
||||
values.put("z", new IntTag((int) pos.z));
|
||||
values.put("x", new IntTag(pos.getBlockX()));
|
||||
values.put("y", new IntTag(pos.getBlockY()));
|
||||
values.put("z", new IntTag(pos.getBlockZ()));
|
||||
}
|
||||
task.run(pos, block);
|
||||
}
|
||||
@ -108,9 +108,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
CompoundTag tag = block.getNbtData();
|
||||
if (tag != null) {
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
|
||||
values.put("x", new IntTag((int) pos.x));
|
||||
values.put("y", new IntTag((int) pos.y));
|
||||
values.put("z", new IntTag((int) pos.z));
|
||||
values.put("x", new IntTag(pos.getBlockX()));
|
||||
values.put("y", new IntTag(pos.getBlockY()));
|
||||
values.put("z", new IntTag(pos.getBlockZ()));
|
||||
}
|
||||
task.run(pos, block);
|
||||
} else if (air) {
|
||||
|
@ -23,9 +23,9 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||
mutable.x = location.x + dx;
|
||||
mutable.y = location.y + dy;
|
||||
mutable.z = location.z + dz;
|
||||
mutable.x = (location.getX() + dx);
|
||||
mutable.y = (location.getY() + dy);
|
||||
mutable.z = (location.getZ() + dz);
|
||||
return extent.setBlock(mutable, block);
|
||||
}
|
||||
|
||||
@ -49,12 +49,12 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
|
@ -93,12 +93,12 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import java.util.Collection;
|
||||
|
||||
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 Collection<RegionWrapper> getRegions();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
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.world.biome.BaseBiome;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NullExtent extends FaweRegionExtent {
|
||||
@ -88,6 +91,11 @@ public class NullExtent extends FaweRegionExtent {
|
||||
@Override
|
||||
public boolean contains(int x, int y, int z) { return false; }
|
||||
|
||||
@Override
|
||||
public Collection<RegionWrapper> getRegions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Operation commitBefore() {
|
||||
return null;
|
||||
|
@ -33,13 +33,13 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
if (min == null) {
|
||||
min = new Vector(pos);
|
||||
}
|
||||
mutable.x = (pos.x - min.x);
|
||||
mutable.y = (pos.y - min.y);
|
||||
mutable.z = (pos.z - min.z);
|
||||
mutable.x = ((pos.getX() - min.getX()));
|
||||
mutable.y = ((pos.getY() - min.getY()));
|
||||
mutable.z = ((pos.getZ() - min.getZ()));
|
||||
Vector tmp = transform.apply(mutable);
|
||||
tmp.x += min.x;
|
||||
tmp.y += min.y;
|
||||
tmp.z += min.z;
|
||||
tmp.x = (tmp.getX() + min.getX());
|
||||
tmp.y = (tmp.getY() + min.getY());
|
||||
tmp.z = (tmp.getZ() + min.getZ());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -47,13 +47,13 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
if (min == null) {
|
||||
min = new Vector(x, y, z);
|
||||
}
|
||||
mutable.x = (x - min.x);
|
||||
mutable.y = (y - min.y);
|
||||
mutable.z = (z - min.z);
|
||||
mutable.x = ((x - min.getX()));
|
||||
mutable.y = ((y - min.getY()));
|
||||
mutable.z = ((z - min.getZ()));
|
||||
Vector tmp = transform.apply(mutable);
|
||||
tmp.x += min.x;
|
||||
tmp.y += min.y;
|
||||
tmp.z += min.z;
|
||||
tmp.x = (tmp.getX() + min.getX());
|
||||
tmp.y = (tmp.getY() + min.getY());
|
||||
tmp.z = (tmp.getZ() + min.getZ());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ProcessedWEExtent extends FaweRegionExtent {
|
||||
@ -31,6 +33,11 @@ public class ProcessedWEExtent extends FaweRegionExtent {
|
||||
this.extent = (AbstractDelegateExtent) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RegionWrapper> getRegions() {
|
||||
return Arrays.asList(mask);
|
||||
}
|
||||
|
||||
public void setLimit(FaweLimit other) {
|
||||
this.limit.set(other);
|
||||
}
|
||||
@ -89,12 +96,12 @@ public class ProcessedWEExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
@ -133,7 +140,7 @@ public class ProcessedWEExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
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()) {
|
||||
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
return false;
|
||||
|
@ -37,9 +37,9 @@ public class ScaleTransform extends ResettableExtent {
|
||||
if (min == null) {
|
||||
min = new Vector(pos);
|
||||
}
|
||||
mutable.x = min.x + (pos.x - min.x) * dx;
|
||||
mutable.y = min.y + (pos.y - min.y) * dy;
|
||||
mutable.z = min.z + (pos.z - min.z) * dz;
|
||||
mutable.x = (min.getX() + (pos.getX() - min.getX()) * dx);
|
||||
mutable.y = (min.getY() + (pos.getY() - min.getY()) * dy);
|
||||
mutable.z = (min.getZ() + (pos.getZ() - min.getZ()) * dz);
|
||||
return mutable;
|
||||
}
|
||||
|
||||
@ -47,9 +47,9 @@ public class ScaleTransform extends ResettableExtent {
|
||||
if (min == null) {
|
||||
min = new Vector(x, y, z);
|
||||
}
|
||||
mutable.x = min.x + (x - min.x) * dx;
|
||||
mutable.y = min.y + (y - min.y) * dy;
|
||||
mutable.z = min.z + (z - min.z) * dz;
|
||||
mutable.x = (min.getX() + (x - min.getX()) * dx);
|
||||
mutable.y = (min.getY() + (y - min.getY()) * dy);
|
||||
mutable.z = (min.getZ() + (z - min.getZ()) * dz);
|
||||
return mutable;
|
||||
}
|
||||
|
||||
@ -58,9 +58,9 @@ public class ScaleTransform extends ResettableExtent {
|
||||
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||
boolean result = false;
|
||||
Vector pos = getPos(location);
|
||||
double sx = pos.x;
|
||||
double sy = pos.y;
|
||||
double sz = pos.z;
|
||||
double sx = pos.getX();
|
||||
double sy = pos.getY();
|
||||
double sz = pos.getZ();
|
||||
double ex = sx + dx;
|
||||
double ey = Math.min(maxy, sy + dy);
|
||||
double ez = sz + dz;
|
||||
@ -78,12 +78,12 @@ public class ScaleTransform extends ResettableExtent {
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
boolean result = false;
|
||||
Vector pos = getPos(position.getBlockX(), 0, position.getBlockZ());
|
||||
double sx = pos.x;
|
||||
double sz = pos.z;
|
||||
double ex = pos.x + dx;
|
||||
double ez = pos.z + dz;
|
||||
for (pos.z = sz; pos.z < ez; pos.z++) {
|
||||
for (pos.x = sx; pos.x < ex; pos.x++) {
|
||||
double sx = pos.getX();
|
||||
double sz = pos.getZ();
|
||||
double ex = pos.getX() + dx;
|
||||
double ez = pos.getZ() + dz;
|
||||
for (pos.z = sz; pos.z < ez; pos.z++) {
|
||||
for (pos.x = sx; pos.x < ex; pos.x++) {
|
||||
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 {
|
||||
boolean result = false;
|
||||
Vector pos = getPos(x1, y1, z1);
|
||||
double sx = pos.x;
|
||||
double sy = pos.y;
|
||||
double sz = pos.z;
|
||||
double ex = pos.x + dx;
|
||||
double sx = pos.getX();
|
||||
double sy = pos.getY();
|
||||
double sz = pos.getZ();
|
||||
double ex = pos.getX() + dx;
|
||||
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.z = sz; pos.z < ez; pos.z++) {
|
||||
for (pos.x = sx; pos.x < ex; pos.x++) {
|
||||
|
@ -40,7 +40,7 @@ public class SourceMaskExtent extends TemporalExtent {
|
||||
}
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
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 super.getBlock(position);
|
||||
@ -62,7 +62,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
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 super.getLazyBlock(position);
|
||||
|
@ -35,13 +35,13 @@ public class TransformExtent extends BlockTransformExtent {
|
||||
if (min == null) {
|
||||
min = new Vector(pos);
|
||||
}
|
||||
mutable.x = (pos.x - min.x);
|
||||
mutable.y = (pos.y - min.y);
|
||||
mutable.z = (pos.z - min.z);
|
||||
mutable.x = ((pos.getX() - min.getX()));
|
||||
mutable.y = ((pos.getY() - min.getY()));
|
||||
mutable.z = ((pos.getZ() - min.getZ()));
|
||||
Vector tmp = getTransform().apply(mutable);
|
||||
tmp.x += min.x;
|
||||
tmp.y += min.y;
|
||||
tmp.z += min.z;
|
||||
tmp.x = (tmp.getX() + min.getX());
|
||||
tmp.y = (tmp.getY() + min.getY());
|
||||
tmp.z = (tmp.getZ() + min.getZ());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -49,13 +49,13 @@ public class TransformExtent extends BlockTransformExtent {
|
||||
if (min == null) {
|
||||
min = new Vector(x, y, z);
|
||||
}
|
||||
mutable.x = (x - min.x);
|
||||
mutable.y = (y - min.y);
|
||||
mutable.z = (z - min.z);
|
||||
mutable.x = ((x - min.getX()));
|
||||
mutable.y = ((y - min.getY()));
|
||||
mutable.z = ((z - min.getZ()));
|
||||
Vector tmp = getTransform().apply(mutable);
|
||||
tmp.x += min.x;
|
||||
tmp.y += min.y;
|
||||
tmp.z += min.z;
|
||||
tmp.x = (tmp.getX() + min.getX());
|
||||
tmp.y = (tmp.getY() + min.getY());
|
||||
tmp.z = (tmp.getZ() + min.getZ());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,9 @@ public class AdjacentMask extends BlockMask {
|
||||
@Override
|
||||
public boolean test(Vector v) {
|
||||
int count = 0;
|
||||
double x = v.x;
|
||||
double y = v.y;
|
||||
double z = v.z;
|
||||
double x = v.getX();
|
||||
double y = v.getY();
|
||||
double z = v.getZ();
|
||||
v.x = x + 1;
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; }
|
||||
v.x = x - 1;
|
||||
|
@ -21,7 +21,7 @@ public class BlockLightMask implements Mask {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
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 false;
|
||||
|
@ -21,7 +21,7 @@ public class BrightnessMask implements Mask {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
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 false;
|
||||
|
@ -21,7 +21,7 @@ public class LightMask implements Mask {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
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 false;
|
||||
|
@ -21,7 +21,7 @@ public class OpacityMask implements Mask {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
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 false;
|
||||
|
@ -26,9 +26,9 @@ public class RadiusMask implements Mask, ResettableMask{
|
||||
if (pos == null) {
|
||||
pos = new Vector(to);
|
||||
}
|
||||
int dx = Math.abs((int) (pos.x - to.x));
|
||||
int dy = Math.abs((int) (pos.y - to.y));
|
||||
int dz = Math.abs((int) (pos.z - to.z));
|
||||
int dx = Math.abs((int) (pos.getX() - to.getX()));
|
||||
int dy = Math.abs((int) (pos.getY() - to.getY()));
|
||||
int dz = Math.abs((int) (pos.getZ() - to.getZ()));
|
||||
int d = dx * dx;
|
||||
if (d < minSqr || d > maxSqr) {
|
||||
return false;
|
||||
|
@ -21,7 +21,7 @@ public class SkyLightMask implements Mask {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
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 false;
|
||||
|
@ -18,9 +18,9 @@ public class WallMask extends BlockMask {
|
||||
@Override
|
||||
public boolean test(Vector v) {
|
||||
int count = 0;
|
||||
double x = v.x;
|
||||
double y = v.y;
|
||||
double z = v.z;
|
||||
double x = v.getX();
|
||||
double y = v.getY();
|
||||
double z = v.getZ();
|
||||
v.x = x + 1;
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; }
|
||||
v.x = x - 1;
|
||||
|
@ -17,8 +17,8 @@ public class NoXPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector pos) {
|
||||
mutable.y = pos.y;
|
||||
mutable.z = pos.z;
|
||||
mutable.y = (pos.getY());
|
||||
mutable.z = (pos.getZ());
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ public class NoYPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector pos) {
|
||||
mutable.x = pos.x;
|
||||
mutable.z = pos.z;
|
||||
mutable.x = (pos.getX());
|
||||
mutable.z = (pos.getZ());
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ public class NoZPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector pos) {
|
||||
mutable.x = pos.x;
|
||||
mutable.y = pos.y;
|
||||
mutable.x = (pos.getX());
|
||||
mutable.y = (pos.getY());
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ public class OffsetPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
mutable.x = position.x + dx;
|
||||
mutable.y = position.y + dy;
|
||||
mutable.z = position.z + dz;
|
||||
mutable.x = (position.getX() + dx);
|
||||
mutable.y = (position.getY() + dy);
|
||||
mutable.z = (position.getZ() + dz);
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
||||
@Override
|
||||
public BaseBlock getBlock(Vector 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;
|
||||
} else {
|
||||
block = null;
|
||||
|
@ -25,9 +25,9 @@ public class RandomOffsetPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
mutable.x = position.x + r.nextInt(dx2) - dx;
|
||||
mutable.y = position.y + r.nextInt(dy2) - dy;
|
||||
mutable.z = position.z + r.nextInt(dz2) - dz;
|
||||
mutable.x = (position.getX() + r.nextInt(dx2) - dx);
|
||||
mutable.y = (position.getY() + r.nextInt(dy2) - dy);
|
||||
mutable.z = (position.getZ() + r.nextInt(dz2) - dz);
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
|
||||
if (origin == null) {
|
||||
origin = new Vector(pos);
|
||||
}
|
||||
mutable.x = pos.x - origin.x;
|
||||
mutable.y = pos.y - origin.y;
|
||||
mutable.z = pos.z - origin.z;
|
||||
mutable.x = (pos.getX() - origin.getX());
|
||||
mutable.y = (pos.getY() - origin.getY());
|
||||
mutable.z = (pos.getZ() - origin.getZ());
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,9 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
mutable.x = position.x + r.nextInt(dx2) - dx;
|
||||
mutable.y = position.y + r.nextInt(dy2) - dy;
|
||||
mutable.z = position.z + r.nextInt(dz2) - dz;
|
||||
mutable.x = (position.getX() + r.nextInt(dx2) - dx);
|
||||
mutable.y = (position.getY() + r.nextInt(dy2) - dy);
|
||||
mutable.z = (position.getZ() + r.nextInt(dz2) - dz);
|
||||
BaseBlock block = pattern.apply(mutable);
|
||||
if (solid[FaweCache.getCombined(block)]) {
|
||||
return block;
|
||||
|
@ -35,9 +35,9 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
mutable.x = position.x + r.nextInt(dx2) - dx;
|
||||
mutable.y = position.y + r.nextInt(dy2) - dy;
|
||||
mutable.z = position.z + r.nextInt(dz2) - dz;
|
||||
mutable.x = (position.getX() + r.nextInt(dx2) - dx);
|
||||
mutable.y = (position.getY() + r.nextInt(dy2) - dy);
|
||||
mutable.z = (position.getZ() + r.nextInt(dz2) - dz);
|
||||
BaseBlock block = pattern.apply(mutable);
|
||||
if (solid[FaweCache.getCombined(block)]) {
|
||||
mutable.y++;
|
||||
|
@ -150,7 +150,7 @@ public class FuzzyRegion extends AbstractRegion {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -73,7 +73,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
|
||||
positions.clear();
|
||||
positions.add(position);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
this.positions.add(position);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
||||
BaseBlock block = clipboard.getBlock(point);
|
||||
int combined = FaweCache.getCombined(block);
|
||||
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()) {
|
||||
blocks.add(FaweCache.asMap("state", index, "pos", pos));
|
||||
} else {
|
||||
|
@ -63,7 +63,7 @@ public abstract class DFSVisitor implements Operation {
|
||||
}
|
||||
|
||||
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)) {
|
||||
isVisitable(pos, pos); // Ignore this, just to initialize mask on this point
|
||||
queue.addFirst(new NodePair(null, node, 0));
|
||||
|
97
core/src/main/java/com/sk89q/worldedit/BlockVector.java
Normal file
97
core/src/main/java/com/sk89q/worldedit/BlockVector.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -531,7 +531,7 @@ public class CuboidClipboard {
|
||||
}
|
||||
|
||||
if (aroundPlayer) {
|
||||
offset = offset.setX(1 - offset.getX() - width);
|
||||
offset.x = 1 - offset.x - width;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -565,7 +565,7 @@ public class CuboidClipboard {
|
||||
}
|
||||
|
||||
if (aroundPlayer) {
|
||||
offset = offset.setZ(1 - offset.getZ() - length);
|
||||
offset.z = 1 - offset.getZ() - length;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -597,7 +597,7 @@ public class CuboidClipboard {
|
||||
}
|
||||
|
||||
if (aroundPlayer) {
|
||||
offset = offset.setY(1 - offset.getY() - height);
|
||||
offset.y = 1 - offset.getY() - height;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -41,6 +41,7 @@ import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet;
|
||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
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.extent.FastWorldEditExtent;
|
||||
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.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.registry.WorldData;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -169,6 +169,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
private World world;
|
||||
private String worldName;
|
||||
private FaweQueue queue;
|
||||
private boolean wrapped;
|
||||
private AbstractDelegateExtent extent;
|
||||
private HistoryExtent history;
|
||||
private AbstractDelegateExtent bypassHistory;
|
||||
@ -483,6 +484,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
String className = toReturn.getClass().getName().toLowerCase();
|
||||
for (String allowed : Settings.EXTENT.ALLOWED_PLUGINS) {
|
||||
if (className.contains(allowed.toLowerCase())) {
|
||||
this.wrapped = true;
|
||||
return (AbstractDelegateExtent) toReturn;
|
||||
}
|
||||
}
|
||||
@ -858,10 +860,10 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
|
||||
@Override
|
||||
public BaseBlock getLazyBlock(final Vector position) {
|
||||
if (position.y > maxY || position.y < 0) {
|
||||
if (position.getY() > maxY || position.getY() < 0) {
|
||||
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) {
|
||||
@ -874,10 +876,10 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(final Vector position) {
|
||||
if (position.y > maxY || position.y < 0) {
|
||||
if (position.getY() > maxY || position.getY() < 0) {
|
||||
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
|
||||
*/
|
||||
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];
|
||||
for (final int id : searchIDs) {
|
||||
if ((id < 256) && (id > 0)) {
|
||||
if ((id < 256) && (id >= 0)) {
|
||||
ids[id] = true;
|
||||
}
|
||||
}
|
||||
@ -1345,14 +1358,14 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
}
|
||||
|
||||
public int countBlock(final Region region, final boolean[] ids) {
|
||||
int i = 0;
|
||||
int count = 0;
|
||||
for (final Vector pt : region) {
|
||||
final int id = this.getBlockType(pt);
|
||||
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
|
||||
*/
|
||||
public int countBlocks(final Region region, final Set<BaseBlock> searchBlocks) {
|
||||
final boolean[] ids = new boolean[256];
|
||||
for (final BaseBlock block : searchBlocks) {
|
||||
final int id = block.getId();
|
||||
if ((id < 256) && (id > 0)) {
|
||||
ids[id] = true;
|
||||
BlockMask mask = new BlockMask(extent, searchBlocks);
|
||||
int count = 0;
|
||||
for (final Vector pt : region) {
|
||||
if (mask.test(pt)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return this.countBlock(region, ids);
|
||||
return count;
|
||||
}
|
||||
|
||||
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 endY = region.getMaximumPoint().getBlockY();
|
||||
for (BlockVector pos : flat) {
|
||||
int x = (int) pos.x;
|
||||
int z = (int) pos.z;
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
int freeSpot = startCheckY;
|
||||
for (int y = startCheckY; y <= endY; y++) {
|
||||
if (y < startPerformY) {
|
||||
@ -1527,6 +1540,31 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
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.
|
||||
*
|
||||
@ -1539,10 +1577,17 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
public int setBlocks(final Region region, final BaseBlock block) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
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();
|
||||
try {
|
||||
while (iter.hasNext()) {
|
||||
this.extent.setBlock(iter.next(), block);
|
||||
if (this.extent.setBlock(iter.next(), block)) {
|
||||
changes++;
|
||||
}
|
||||
}
|
||||
} catch (final MaxChangedBlocksException 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 {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
if (pattern instanceof BlockPattern) {
|
||||
return setBlocks(region, ((BlockPattern) pattern).getBlock());
|
||||
}
|
||||
final BlockReplace replace = new BlockReplace(EditSession.this, Patterns.wrap(pattern));
|
||||
final RegionVisitor visitor = new RegionVisitor(region, replace);
|
||||
Operations.completeSmart(visitor, new Runnable() {
|
||||
@ -1587,6 +1635,11 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
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));
|
||||
}
|
||||
|
||||
@ -1602,10 +1655,17 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
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);
|
||||
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
|
||||
* returned by a given pattern.
|
||||
@ -1898,9 +1958,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
@Override
|
||||
// Only copy what's necessary
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
mutable.x = position.x - displace.x;
|
||||
mutable.y = position.y - displace.y;
|
||||
mutable.z = position.z - displace.z;
|
||||
mutable.x = (position.getX() - displace.getX());
|
||||
mutable.y = (position.getY() - displace.getY());
|
||||
mutable.z = (position.getZ() - displace.getZ());
|
||||
if (region.contains(mutable)) {
|
||||
return false;
|
||||
}
|
||||
@ -2099,11 +2159,11 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
return this.changes;
|
||||
} else if (height < 0) {
|
||||
height = -height;
|
||||
pos = pos.subtract(0, height, 0);
|
||||
pos.y -= height;
|
||||
}
|
||||
|
||||
if (pos.getBlockY() < 0) {
|
||||
pos = pos.setY(0);
|
||||
pos.y = 0;
|
||||
} else if (((pos.getBlockY() + height) - 1) > maxY) {
|
||||
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 {
|
||||
|
||||
|
||||
final Set<BlockVector> outside = new HashSet<BlockVector>();
|
||||
final Set outside = new LocalBlockVectorSet();
|
||||
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
@ -2720,7 +2780,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
}
|
||||
|
||||
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) {
|
||||
for (final Vector recurseDirection : this.recurseDirections) {
|
||||
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 {
|
||||
|
||||
Set<Vector> vset = new HashSet<Vector>();
|
||||
Set vset = new LocalBlockVectorSet();
|
||||
boolean notdrawn = true;
|
||||
|
||||
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,
|
||||
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 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) {
|
||||
final Set<Vector> returnset = new HashSet<Vector>();
|
||||
final Set returnset = new LocalBlockVectorSet();
|
||||
final int ceilrad = (int) Math.ceil(radius);
|
||||
|
||||
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) {
|
||||
final Set<Vector> returnset = new HashSet<Vector>();
|
||||
final Set returnset = new LocalBlockVectorSet();
|
||||
final int ceilrad = (int) Math.ceil(radius);
|
||||
for (final Vector v : vset) {
|
||||
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) {
|
||||
final Set<Vector> returnset = new HashSet<Vector>();
|
||||
final Set returnset = new LocalBlockVectorSet();
|
||||
for (final Vector v : vset) {
|
||||
final double x = v.getX(), y = v.getY(), z = v.getZ();
|
||||
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) {
|
||||
final Set<Vector> returnset = new HashSet<Vector>();
|
||||
final Set returnset = new LocalBlockVectorSet();
|
||||
for (final Vector v : vset) {
|
||||
final double x = v.getX(), y = v.getY(), z = v.getZ();
|
||||
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) {
|
||||
final LinkedList<BlockVector> queue = new LinkedList<BlockVector>();
|
||||
final ArrayDeque<BlockVector> queue = new ArrayDeque<BlockVector>();
|
||||
queue.addLast(origin);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
@ -3022,7 +3082,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
|
||||
@Override
|
||||
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
|
||||
@ -3052,9 +3112,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
}
|
||||
|
||||
private void setExistingBlocks(Vector pos1, Vector pos2) {
|
||||
for (int x = (int) pos1.x; x <= (int) pos2.x; x++) {
|
||||
for (int z = (int) pos1.z; z <= (int) pos2.z; z++) {
|
||||
for (int y = (int) pos1.y; y <= (int) pos2.y; y++) {
|
||||
for (int x = (int) pos1.getX(); x <= (int) pos2.getX(); x++) {
|
||||
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
|
||||
for (int y = (int) pos1.getY(); y <= (int) pos2.getY(); y++) {
|
||||
int from = queue.getCombinedId4Data(x, y, z);
|
||||
short id = (short) (from >> 4);
|
||||
byte data = (byte) (from & 0xf);
|
||||
|
@ -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 ONE = new Vector(1, 1, 1);
|
||||
|
||||
public double x, y, z;
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
@ -102,7 +104,7 @@ public class Vector implements Comparable<Vector> {
|
||||
*
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public double getX() {
|
||||
public final double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -112,7 +114,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public int getBlockX() {
|
||||
return (int) x;
|
||||
return (int) getX();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +124,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return a new vector
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public double getY() {
|
||||
public final double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@ -150,7 +152,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return the y coordinate
|
||||
*/
|
||||
public int getBlockY() {
|
||||
return (int) (y);
|
||||
return (int) (getY());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,7 +162,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return a new vector
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public double getZ() {
|
||||
public final double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@ -188,7 +190,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return the z coordinate
|
||||
*/
|
||||
public int getBlockZ() {
|
||||
return (int) (z);
|
||||
return (int) (getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +200,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return a new vector
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public Vector add(Vector... others) {
|
||||
double newX = x, newY = y, newZ = z;
|
||||
double newX = getX(), newY = getY(), newZ = getZ();
|
||||
|
||||
for (Vector other : others) {
|
||||
newX += other.x;
|
||||
newY += other.y;
|
||||
newZ += other.z;
|
||||
newX += other.getX();
|
||||
newY += other.getY();
|
||||
newZ += other.getZ();
|
||||
}
|
||||
|
||||
return new Vector(newX, newY, newZ);
|
||||
@ -272,7 +274,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return a new vector
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public Vector subtract(Vector... others) {
|
||||
double newX = x, newY = y, newZ = z;
|
||||
double newX = getX(), newY = getY(), newZ = getZ();
|
||||
|
||||
for (Vector other : others) {
|
||||
newX -= other.x;
|
||||
newY -= other.y;
|
||||
newZ -= other.z;
|
||||
newX -= other.getX();
|
||||
newY -= other.getY();
|
||||
newZ -= other.getZ();
|
||||
}
|
||||
|
||||
return new Vector(newX, newY, newZ);
|
||||
@ -327,7 +329,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return a new vector
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public Vector multiply(Vector... others) {
|
||||
double newX = x, newY = y, newZ = z;
|
||||
double newX = getX(), newY = getY(), newZ = getZ();
|
||||
|
||||
for (Vector other : others) {
|
||||
newX *= other.x;
|
||||
newY *= other.y;
|
||||
newZ *= other.z;
|
||||
newX *= other.getX();
|
||||
newY *= other.getY();
|
||||
newZ *= other.getZ();
|
||||
}
|
||||
|
||||
return new Vector(newX, newY, newZ);
|
||||
@ -379,7 +381,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return a new vector
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public double distance(Vector other) {
|
||||
return Math.sqrt(Math.pow(other.x - x, 2) +
|
||||
Math.pow(other.y - y, 2) +
|
||||
Math.pow(other.z - z, 2));
|
||||
return Math.sqrt(Math.pow(other.getX() - getX(), 2) +
|
||||
Math.pow(other.getY() - getY(), 2) +
|
||||
Math.pow(other.getZ() - getZ(), 2));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -503,9 +505,9 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return distance
|
||||
*/
|
||||
public double distanceSq(Vector other) {
|
||||
return Math.pow(other.x - x, 2) +
|
||||
Math.pow(other.y - y, 2) +
|
||||
Math.pow(other.z - z, 2);
|
||||
return Math.pow(other.getX() - getX(), 2) +
|
||||
Math.pow(other.getY() - getY(), 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
|
||||
*/
|
||||
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) {
|
||||
return new Vector(
|
||||
y * other.z - z * other.y,
|
||||
z * other.x - x * other.z,
|
||||
x * other.y - y * other.x
|
||||
getY() * other.getZ() - getZ() * other.getY(),
|
||||
getZ() * other.getX() - getX() * other.getZ(),
|
||||
getX() * other.getY() - getY() * other.getX()
|
||||
);
|
||||
}
|
||||
|
||||
@ -550,7 +552,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return true if the vector is contained
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
angle = Math.toRadians(angle);
|
||||
double x = this.x - aboutX;
|
||||
double z = this.z - aboutZ;
|
||||
double x = this.getX() - aboutX;
|
||||
double z = this.getZ() - aboutZ;
|
||||
double x2 = x * Math.cos(angle) - z * Math.sin(angle);
|
||||
double z2 = x * Math.sin(angle) + z * Math.cos(angle);
|
||||
|
||||
return new Vector(
|
||||
x2 + aboutX + translateX,
|
||||
y,
|
||||
getY(),
|
||||
z2 + aboutZ + translateZ
|
||||
);
|
||||
}
|
||||
@ -649,35 +651,35 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return true if collinear
|
||||
*/
|
||||
public boolean isCollinearWith(Vector other) {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
if (getX() == 0 && getY() == 0 && getZ() == 0) {
|
||||
// this is a zero vector
|
||||
return true;
|
||||
}
|
||||
|
||||
final double otherX = other.x;
|
||||
final double otherY = other.y;
|
||||
final double otherZ = other.z;
|
||||
final double otherX = other.getX();
|
||||
final double otherY = other.getY();
|
||||
final double otherZ = other.getZ();
|
||||
|
||||
if (otherX == 0 && otherY == 0 && otherZ == 0) {
|
||||
// other is a zero vector
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((x == 0) != (otherX == 0)) return false;
|
||||
if ((y == 0) != (otherY == 0)) return false;
|
||||
if ((z == 0) != (otherZ == 0)) return false;
|
||||
if ((getX() == 0) != (otherX == 0)) return false;
|
||||
if ((getY() == 0) != (otherY == 0)) return false;
|
||||
if ((getZ() == 0) != (otherZ == 0)) return false;
|
||||
|
||||
final double quotientX = otherX / x;
|
||||
final double quotientX = otherX / getX();
|
||||
if (!Double.isNaN(quotientX)) {
|
||||
return other.equals(multiply(quotientX));
|
||||
}
|
||||
|
||||
final double quotientY = otherY / y;
|
||||
final double quotientY = otherY / getY();
|
||||
if (!Double.isNaN(quotientY)) {
|
||||
return other.equals(multiply(quotientY));
|
||||
}
|
||||
|
||||
final double quotientZ = otherZ / z;
|
||||
final double quotientZ = otherZ / getZ();
|
||||
if (!Double.isNaN(quotientZ)) {
|
||||
return other.equals(multiply(quotientZ));
|
||||
}
|
||||
@ -742,9 +744,9 @@ public class Vector implements Comparable<Vector> {
|
||||
*/
|
||||
public BlockVector toBlockPoint() {
|
||||
return new BlockVector(
|
||||
Math.floor(x),
|
||||
Math.floor(y),
|
||||
Math.floor(z)
|
||||
Math.floor(getX()),
|
||||
Math.floor(getY()),
|
||||
Math.floor(getZ())
|
||||
);
|
||||
}
|
||||
|
||||
@ -763,7 +765,7 @@ public class Vector implements Comparable<Vector> {
|
||||
* @return a new {@code Vector2D}
|
||||
*/
|
||||
public Vector2D toVector2D() {
|
||||
return new Vector2D(x, z);
|
||||
return new Vector2D(getX(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -773,7 +775,7 @@ public class Vector implements Comparable<Vector> {
|
||||
}
|
||||
|
||||
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
|
||||
@ -781,20 +783,20 @@ public class Vector implements Comparable<Vector> {
|
||||
if (other == null) {
|
||||
throw new IllegalArgumentException("null not supported");
|
||||
}
|
||||
if (y != other.y) return Double.compare(y, other.y);
|
||||
if (z != other.z) return Double.compare(z, other.z);
|
||||
if (x != other.x) return Double.compare(x, other.x);
|
||||
if (getY() != other.getY()) return Double.compare(getY(), other.getY());
|
||||
if (getZ() != other.getZ()) return Double.compare(getZ(), other.getZ());
|
||||
if (getX() != other.getX()) return Double.compare(getX(), other.getX());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) x ^ ((int) z << 16) ^ ((byte) y << 31);
|
||||
return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return new Vector(
|
||||
Math.min(v1.x, v2.x),
|
||||
Math.min(v1.y, v2.y),
|
||||
Math.min(v1.z, v2.z)
|
||||
Math.min(v1.getX(), v2.getX()),
|
||||
Math.min(v1.getY(), v2.getY()),
|
||||
Math.min(v1.getZ(), v2.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
@ -821,9 +823,9 @@ public class Vector implements Comparable<Vector> {
|
||||
*/
|
||||
public static Vector getMaximum(Vector v1, Vector v2) {
|
||||
return new Vector(
|
||||
Math.max(v1.x, v2.x),
|
||||
Math.max(v1.y, v2.y),
|
||||
Math.max(v1.z, v2.z)
|
||||
Math.max(v1.getX(), v2.getX()),
|
||||
Math.max(v1.getY(), v2.getY()),
|
||||
Math.max(v1.getZ(), v2.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
@ -836,9 +838,9 @@ public class Vector implements Comparable<Vector> {
|
||||
*/
|
||||
public static Vector getMidpoint(Vector v1, Vector v2) {
|
||||
return new Vector(
|
||||
(v1.x + v2.x) / 2,
|
||||
(v1.y + v2.y) / 2,
|
||||
(v1.z + v2.z) / 2
|
||||
(v1.getX() + v2.getX()) / 2,
|
||||
(v1.getY() + v2.getY()) / 2,
|
||||
(v1.getZ() + v2.getZ()) / 2
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ public class ClipboardCommands {
|
||||
selector.learnChanges();
|
||||
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);
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ public class ClipboardCommands {
|
||||
pos.x += relx;
|
||||
pos.y += rely;
|
||||
pos.z += relz;
|
||||
if (pos.y >= 0 && pos.y <= maxY) {
|
||||
if (pos.getY() >= 0 && pos.getY() <= maxY) {
|
||||
editSession.setBlockFast(pos, block);
|
||||
}
|
||||
}
|
||||
@ -387,7 +387,7 @@ public class ClipboardCommands {
|
||||
loc.x += relx;
|
||||
loc.y += rely;
|
||||
loc.z += relz;
|
||||
if (loc.y >= 0 && loc.y <= maxY) {
|
||||
if (loc.getY() >= 0 && loc.getY() <= maxY) {
|
||||
editSession.setBlockFast(loc, block);
|
||||
}
|
||||
}
|
||||
|
@ -301,9 +301,9 @@ public class GenerationCommands {
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
||||
if (unit.getX() == 0) unit.x = 1;
|
||||
if (unit.getY() == 0) unit.y = 1;
|
||||
if (unit.getZ() == 0) unit.z = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -366,9 +366,9 @@ public class GenerationCommands {
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
||||
if (unit.getX() == 0) unit.x = 1;
|
||||
if (unit.getY() == 0) unit.y = 1;
|
||||
if (unit.getZ() == 0) unit.z = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -170,9 +170,9 @@ public class HistoryCommands {
|
||||
final World world = player.getWorld();
|
||||
WorldVector origin = player.getPosition();
|
||||
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);
|
||||
top = top.setY(Math.min(255, top.getY()));
|
||||
top.y = Math.min(255, top.getY());
|
||||
RollbackDatabase database = DBHandler.IMP.getDatabase(world);
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
final FawePlayer fp = FawePlayer.wrap(player);
|
||||
|
@ -22,13 +22,9 @@ package com.sk89q.worldedit.command;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweLocation;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
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.SetQueue;
|
||||
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.mask.ExistingBlockMask;
|
||||
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.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
@ -172,7 +167,7 @@ public class RegionCommands {
|
||||
final int cz = loc.z >> 4;
|
||||
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) SetQueue.IMP.getNewQueue(fp.getWorld(), true, false);
|
||||
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;
|
||||
for (Vector2D chunk : region.getChunks()) {
|
||||
@ -196,7 +191,7 @@ public class RegionCommands {
|
||||
final int cz = loc.z >> 4;
|
||||
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) SetQueue.IMP.getNewQueue(fp.getWorld(), true, false);
|
||||
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;
|
||||
for (Vector2D chunk : region.getChunks()) {
|
||||
@ -320,63 +315,6 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.region.set")
|
||||
@Logging(REGION)
|
||||
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;
|
||||
if (to instanceof BlockPattern) {
|
||||
affected = editSession.setBlocks(selection, ((BlockPattern) to).getBlock());
|
||||
@ -657,9 +595,9 @@ public class RegionCommands {
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
||||
if (unit.getX() == 0) unit.x = 1;
|
||||
if (unit.getY() == 0) unit.y = 1;
|
||||
if (unit.getZ() == 0) unit.z = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -337,9 +337,12 @@ public final class CommandManager {
|
||||
BBC.WORLDEDIT_CANCEL_REASON.send(finalActor, faweException.getMessage());
|
||||
} else {
|
||||
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());
|
||||
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) {
|
||||
String message = e.getMessage();
|
||||
|
@ -77,9 +77,9 @@ public class SchematicWriter implements ClipboardWriter {
|
||||
|
||||
@Override
|
||||
public void run(Vector point, BaseBlock block) {
|
||||
int x = (int) point.x;
|
||||
int y = (int) point.y;
|
||||
int z = (int) point.z;
|
||||
int x = (int) point.getX();
|
||||
int y = (int) point.getY();
|
||||
int z = (int) point.getZ();
|
||||
if (this.x == x - 1 && this.y == y && this.z == z) {
|
||||
this.x++;
|
||||
index++;
|
||||
@ -289,9 +289,9 @@ public class SchematicWriter implements ClipboardWriter {
|
||||
Vector mutable = new Vector(0, 0, 0);
|
||||
ForEach forEach = new ForEach(yarea, zwidth, blocks, blockData, tileEntities);
|
||||
for (Vector point : region) {
|
||||
mutable.x = point.x - mx;
|
||||
mutable.y = point.y - my;
|
||||
mutable.z = point.z - mz;
|
||||
mutable.x = (point.getX() - mx);
|
||||
mutable.y = (point.getY() - my);
|
||||
mutable.z = (point.getZ() - mz);
|
||||
forEach.run(mutable, clipboard.getBlock(point));
|
||||
}
|
||||
addBlocks = forEach.addBlocks;
|
||||
|
@ -101,9 +101,9 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
if (direction != null) {
|
||||
Vector applyAbsolute = transform.apply(direction.toVector());
|
||||
Vector applyOrigin = transform.apply(Vector.ZERO);
|
||||
applyAbsolute.x -= applyOrigin.x;
|
||||
applyAbsolute.y -= applyOrigin.y;
|
||||
applyAbsolute.z -= applyOrigin.z;
|
||||
applyAbsolute.x -= applyOrigin.getX();
|
||||
applyAbsolute.y -= applyOrigin.getY();
|
||||
applyAbsolute.z -= applyOrigin.getZ();
|
||||
|
||||
Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||
|
||||
|
@ -84,6 +84,10 @@ public class BlockMask extends AbstractExtentMask {
|
||||
computedLegacyList = null;
|
||||
}
|
||||
|
||||
public boolean[] getBlockArray() {
|
||||
return blockIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of blocks that are tested with.
|
||||
*
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import java.util.Collection;
|
||||
@ -15,18 +14,6 @@ public class FuzzyBlockMask extends BlockMask {
|
||||
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() {
|
||||
return FuzzyBlockMask.class;
|
||||
}
|
||||
|
@ -69,9 +69,9 @@ public class OffsetMask extends AbstractMask {
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
mutable.x = vector.x + offset.x;
|
||||
mutable.y = vector.y + offset.y;
|
||||
mutable.z = vector.z + offset.z;
|
||||
mutable.x = (vector.getX() + offset.getX());
|
||||
mutable.y = (vector.getY() + offset.getY());
|
||||
mutable.z = (vector.getZ() + offset.getZ());
|
||||
return getMask().test(mutable);
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,9 @@ public class ClipboardPattern extends AbstractPattern {
|
||||
if (xp < 0) xp += sx;
|
||||
if (yp < 0) yp += sy;
|
||||
if (zp < 0) zp += sz;
|
||||
mutable.x = min.x + xp;
|
||||
mutable.y = min.y + yp;
|
||||
mutable.z = min.z + zp;
|
||||
mutable.x = (min.getX() + xp);
|
||||
mutable.y = (min.getY() + yp);
|
||||
mutable.z = (min.getZ() + zp);
|
||||
return clipboard.getBlock(mutable);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
|
||||
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)) {
|
||||
isVisitable(pos, pos); // Ignore this, just to initialize mask on this point
|
||||
queue.add(node);
|
||||
|
@ -158,9 +158,9 @@ public class KochanekBartelsInterpolation implements Interpolation {
|
||||
|
||||
double r2 = remainder * remainder;
|
||||
double r3 = r2 * remainder;
|
||||
mutable.x = a.x * r3 + b.x * r2 + c.x * remainder + d.x;
|
||||
mutable.y = a.y * r3 + b.y * r2 + c.y * remainder + d.y;
|
||||
mutable.z = a.z * r3 + b.z * r2 + c.z * remainder + d.z;
|
||||
mutable.x = (a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX());
|
||||
mutable.y = (a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY());
|
||||
mutable.z = (a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ());
|
||||
return mutable;
|
||||
}
|
||||
|
||||
|
@ -274,13 +274,14 @@ public class AffineTransform implements Transform {
|
||||
// vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03
|
||||
// vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13
|
||||
// vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23
|
||||
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.z = vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23;
|
||||
return new Vector(
|
||||
vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
|
||||
vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13,
|
||||
vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
|
||||
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.z = (vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
|
||||
return mutable;
|
||||
// return new Vector(
|
||||
// vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
|
||||
// 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) {
|
||||
|
@ -20,13 +20,13 @@
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
@ -330,7 +330,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
@Override
|
||||
public Set<Vector> getChunkCubes() {
|
||||
Set<Vector> chunks = new HashSet<Vector>();
|
||||
Set chunks = new LocalBlockVectorSet();
|
||||
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
|
@ -174,6 +174,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
} else {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||
for (Entity entity : ents) {
|
||||
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 z = ((int) Math.round(entity.posZ) & 15);
|
||||
int y = (int) Math.round(entity.posY);
|
||||
if (array == null) {
|
||||
continue;
|
||||
if (y < 0 || y > 255) 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);
|
||||
}
|
||||
}
|
||||
@ -246,17 +256,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
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
|
||||
for (int j = 0; j < sections.length; 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().setCount(0, count - this.getAir(j), section);
|
||||
continue;
|
||||
} else {
|
||||
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
|
||||
}
|
||||
}
|
||||
IBlockState existing;
|
||||
|
@ -168,16 +168,22 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
|
||||
// Remove entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int count = this.getCount(i);
|
||||
if (count == 0) {
|
||||
continue;
|
||||
} else if (count >= 4096) {
|
||||
entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
ClassInheritanceMultiMap<Entity> ents = entities[i];
|
||||
if (ents != null && !ents.isEmpty()) {
|
||||
entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
for (Entity ent : ents) {
|
||||
nmsWorld.removeEntity(ent);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||
for (Entity entity : ents) {
|
||||
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 z = ((int) Math.round(entity.posZ) & 15);
|
||||
int y = (int) Math.round(entity.posY);
|
||||
if (array == null) {
|
||||
continue;
|
||||
if (y < 0 || y > 255) 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);
|
||||
}
|
||||
}
|
||||
@ -260,17 +275,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
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
|
||||
for (int j = 0; j < sections.length; 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().setCount(0, count - this.getAir(j), section);
|
||||
continue;
|
||||
} else {
|
||||
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
|
||||
}
|
||||
}
|
||||
IBlockState existing;
|
||||
|
@ -150,6 +150,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
entities[i].clear();
|
||||
} else {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||
for (Entity entity : ents) {
|
||||
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 z = ((int) Math.round(entity.posZ) & 15);
|
||||
int y = (int) Math.round(entity.posY);
|
||||
if (array == null) {
|
||||
continue;
|
||||
if (y < 0 || y > 255) 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);
|
||||
}
|
||||
}
|
||||
@ -220,17 +230,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
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
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
int count = this.getCount(j);
|
||||
|
@ -93,6 +93,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
} else {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||
for (Entity entity : ents) {
|
||||
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 z = ((int) Math.round(entity.posZ) & 15);
|
||||
int y = (int) Math.round(entity.posY);
|
||||
if (array == null) {
|
||||
continue;
|
||||
if (y < 0 || y > 255) 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);
|
||||
}
|
||||
}
|
||||
@ -163,17 +173,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
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
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
int count = this.getCount(j);
|
||||
|
@ -174,6 +174,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
} else {
|
||||
char[] array = this.getIdArray(i);
|
||||
if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
|
||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||
for (Entity entity : ents) {
|
||||
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 z = ((int) Math.round(entity.posZ) & 15);
|
||||
int y = (int) Math.round(entity.posY);
|
||||
if (array == null) {
|
||||
continue;
|
||||
if (y < 0 || y > 255) 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);
|
||||
}
|
||||
}
|
||||
@ -244,17 +254,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
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
|
||||
for (int j = 0; j < sections.length; 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().setCount(0, count - this.getAir(j), section);
|
||||
continue;
|
||||
} else {
|
||||
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
|
||||
}
|
||||
}
|
||||
IBlockState existing;
|
||||
|
Loading…
Reference in New Issue
Block a user