mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Added getChunkCubes() to Region to get 16^3 chunks a region overlaps with
This commit is contained in:
parent
3bfb12c051
commit
03f7d4ecfb
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
@ -302,11 +303,27 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
Vector min = getMinimumPoint();
|
Vector min = getMinimumPoint();
|
||||||
Vector max = getMaximumPoint();
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
|
chunks.add(new BlockVector2D(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
|
z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Vector> getChunkCubes() {
|
||||||
|
Set<Vector> chunks = new HashSet<Vector>();
|
||||||
|
|
||||||
|
Vector min = getMinimumPoint();
|
||||||
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
chunks.add(new BlockVector(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
chunks.add(ChunkStore.toChunk(pt));
|
y >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,7 +393,33 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return new Iterable<Vector2D>() {
|
return new Iterable<Vector2D>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Vector2D> iterator() {
|
public Iterator<Vector2D> iterator() {
|
||||||
return new FlatRegionIterator(CuboidRegion.this);
|
return new Iterator<Vector2D>() {
|
||||||
|
private Vector min = getMinimumPoint();
|
||||||
|
private Vector max = getMaximumPoint();
|
||||||
|
private int nextX = min.getBlockX();
|
||||||
|
private int nextZ = min.getBlockZ();
|
||||||
|
|
||||||
|
public boolean hasNext() {
|
||||||
|
return (nextX != Integer.MIN_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2D next() {
|
||||||
|
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||||
|
Vector2D answer = new Vector2D(nextX, nextZ);
|
||||||
|
if (++nextX > max.getBlockX()) {
|
||||||
|
nextX = min.getBlockX();
|
||||||
|
if (++nextZ > max.getBlockZ()) {
|
||||||
|
nextX = Integer.MIN_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,9 @@ package com.sk89q.worldedit.regions;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.BlockVector;
|
||||||
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
@ -61,7 +64,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
* Construct the region.
|
* Construct the region.
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world
|
||||||
* @param points
|
* @param center
|
||||||
|
* @param radius
|
||||||
* @param minY
|
* @param minY
|
||||||
* @param maxY
|
* @param maxY
|
||||||
*/
|
*/
|
||||||
@ -310,9 +314,30 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
Vector pt = new Vector(x, minY, z);
|
if (contains(new BlockVector(x, minY, z))) {
|
||||||
if (contains(pt)) {
|
chunks.add(new BlockVector2D(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
chunks.add(ChunkStore.toChunk(pt));
|
z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Vector> getChunkCubes() {
|
||||||
|
Set<Vector> chunks = new HashSet<Vector>();
|
||||||
|
|
||||||
|
Vector min = getMinimumPoint();
|
||||||
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
|
if (contains(new BlockVector(x, y, z))) {
|
||||||
|
chunks.add(new BlockVector(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
|
y >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.BlockVector;
|
||||||
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
@ -198,7 +200,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
/**
|
/**
|
||||||
* Set radiuses.
|
* Set radiuses.
|
||||||
*
|
*
|
||||||
* @param radiuses
|
* @param radius
|
||||||
*/
|
*/
|
||||||
public void setRadius(Vector radius) {
|
public void setRadius(Vector radius) {
|
||||||
this.radius = radius.add(0.5, 0.5, 0.5);
|
this.radius = radius.add(0.5, 0.5, 0.5);
|
||||||
@ -218,8 +220,31 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
if (contains(new BlockVector(x, y, z))) {
|
||||||
chunks.add(ChunkStore.toChunk(pt));
|
chunks.add(new BlockVector2D(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
|
z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Vector> getChunkCubes() {
|
||||||
|
Set<Vector> chunks = new HashSet<Vector>();
|
||||||
|
|
||||||
|
Vector min = getMinimumPoint();
|
||||||
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
|
if (contains(new BlockVector(x, y, z))) {
|
||||||
|
chunks.add(new BlockVector(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
|
y >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
/**
|
/**
|
||||||
* Expand the region.
|
* Expand the region.
|
||||||
*
|
*
|
||||||
* @param change
|
* @param changes
|
||||||
*/
|
*/
|
||||||
public void expand(Vector... changes) throws RegionOperationException {
|
public void expand(Vector... changes) throws RegionOperationException {
|
||||||
for (Vector change : changes) {
|
for (Vector change : changes) {
|
||||||
@ -292,7 +292,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
/**
|
/**
|
||||||
* Contract the region.
|
* Contract the region.
|
||||||
*
|
*
|
||||||
* @param change
|
* @param changes
|
||||||
*/
|
*/
|
||||||
public void contract(Vector... changes) throws RegionOperationException {
|
public void contract(Vector... changes) throws RegionOperationException {
|
||||||
for (Vector change : changes) {
|
for (Vector change : changes) {
|
||||||
@ -415,12 +415,31 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
Vector min = getMinimumPoint();
|
Vector min = getMinimumPoint();
|
||||||
Vector max = getMaximumPoint();
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
|
if (contains(new BlockVector(x, minY, z))) { // Not the best
|
||||||
|
chunks.add(new BlockVector2D(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
|
z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Vector> getChunkCubes() {
|
||||||
|
Set<Vector> chunks = new HashSet<Vector>();
|
||||||
|
|
||||||
|
Vector min = getMinimumPoint();
|
||||||
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
if (contains(new BlockVector(x, y, z))) { // Not the best
|
||||||
if (contains(pt)) { // Not the best
|
chunks.add(new BlockVector(x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
chunks.add(ChunkStore.toChunk(pt));
|
y >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,13 @@ public interface Region extends Iterable<BlockVector> {
|
|||||||
*/
|
*/
|
||||||
public Set<Vector2D> getChunks();
|
public Set<Vector2D> getChunks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of 16*16*16 chunks in a region
|
||||||
|
*
|
||||||
|
* @return The chunk cubes this region overlaps with
|
||||||
|
*/
|
||||||
|
public Set<Vector> getChunkCubes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the world the selection is in
|
* Get the world the selection is in
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user