use of com.fastasyncworldedit.core.math.IntTriple in project FastAsyncWorldEdit by IntellectualSites.
the class DiskOptimizedClipboard method toBaseBlock.
private BaseBlock toBaseBlock(BlockState state, int i) {
if (state.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
CompoundTag nbt;
if (nbtMap.size() < 4) {
nbt = null;
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple key = entry.getKey();
int index = getIndex(key.x(), key.y(), key.z());
if (index == i) {
nbt = entry.getValue();
break;
}
}
} else {
int y = i / getArea();
int newI = i - y * getArea();
int z = newI / getWidth();
int x = newI - z * getWidth();
nbt = nbtMap.get(new IntTriple(x, y, z));
}
return state.toBaseBlock(nbt);
}
return state.toBaseBlock();
}
use of com.fastasyncworldedit.core.math.IntTriple in project FastAsyncWorldEdit by IntellectualSites.
the class MemoryOptimizedClipboard method toBaseBlock.
private BaseBlock toBaseBlock(BlockState state, int i) {
if (state.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
CompoundTag nbt;
if (nbtMap.size() < 4) {
nbt = null;
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple trio = entry.getKey();
int index = getIndex(trio.x(), trio.y(), trio.z());
if (index == i) {
nbt = entry.getValue();
break;
}
}
} else {
int y = i / getArea();
int newI = i - y * getArea();
int z = newI / getWidth();
int x = newI - z * getWidth();
nbt = nbtMap.get(new IntTriple(x, y, z));
}
return state.toBaseBlock(nbt);
}
return state.toBaseBlock();
}
use of com.fastasyncworldedit.core.math.IntTriple in project FastAsyncWorldEdit by IntellectualSites.
the class MemoryOptimizedClipboard method setTile.
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
final Map<String, Tag> values = new HashMap<>(tag.getValue());
values.put("x", new IntTag(x));
values.put("y", new IntTag(y));
values.put("z", new IntTag(z));
nbtMap.put(new IntTriple(x, y, z), new CompoundTag(values));
return true;
}
use of com.fastasyncworldedit.core.math.IntTriple in project FastAsyncWorldEdit by IntellectualSites.
the class DFSVisitor method getIntDirections.
private IntTriple[] getIntDirections() {
IntTriple[] array = new IntTriple[directions.size()];
for (int i = 0; i < array.length; i++) {
BlockVector3 dir = directions.get(i);
array[i] = new IntTriple(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());
}
return array;
}
use of com.fastasyncworldedit.core.math.IntTriple in project FastAsyncWorldEdit by IntellectualSites.
the class DFSVisitor method resume.
@Override
public Operation resume(RunContext run) throws WorldEditException {
MutableBlockVector3 mutable = new MutableBlockVector3();
MutableBlockVector3 mutable2 = new MutableBlockVector3();
IntTriple[] dirs = getIntDirections();
while (!queue.isEmpty()) {
NodePair current = queue.poll();
Node from = current.to;
hashQueue.remove(from);
if (visited.containsKey(from)) {
continue;
}
mutable.mutX(from.getX());
mutable.mutY(from.getY());
mutable.mutZ(from.getZ());
function.apply(mutable);
int countAdd = 0;
int countAttempt = 0;
for (IntTriple direction : dirs) {
mutable2.mutX(from.getX() + direction.x());
mutable2.mutY(from.getY() + direction.y());
mutable2.mutZ(from.getZ() + direction.z());
if (isVisitable(mutable, mutable2)) {
Node adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ());
if (!adjacent.equals(current.from)) {
AtomicInteger adjacentCount = visited.get(adjacent);
if (adjacentCount == null) {
if (countAdd++ < maxBranch) {
if (!hashQueue.contains(adjacent)) {
if (current.depth == maxDepth) {
countAttempt++;
} else {
hashQueue.add(adjacent);
queue.addFirst(new NodePair(from, adjacent, current.depth + 1));
}
} else {
countAttempt++;
}
} else {
countAttempt++;
}
} else if (adjacentCount.decrementAndGet() == 0) {
visited.remove(adjacent);
} else if (hashQueue.contains(adjacent)) {
countAttempt++;
}
}
}
}
if (countAttempt > 0) {
visited.put(from, new AtomicInteger(countAttempt));
}
affected++;
}
return null;
}
Aggregations