Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Extracted an AbstractRegion class with some common functionality of all the region types.
Dieser Commit ist enthalten in:
Ursprung
2cc0087524
Commit
4d708a5003
34
src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java
Normale Datei
34
src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java
Normale Datei
@ -0,0 +1,34 @@
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
|
||||
public abstract class AbstractRegion implements Region {
|
||||
/**
|
||||
* Stores the world.
|
||||
*/
|
||||
protected LocalWorld world;
|
||||
|
||||
public AbstractRegion(LocalWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iterator.
|
||||
*
|
||||
* @return iterator of points inside the region
|
||||
*/
|
||||
public Iterator<BlockVector> iterator() {
|
||||
return new RegionIterator(this);
|
||||
}
|
||||
|
||||
public LocalWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public void setWorld(LocalWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ import java.util.HashSet;
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CuboidRegion implements Region {
|
||||
public class CuboidRegion extends AbstractRegion {
|
||||
/**
|
||||
* Store the first point.
|
||||
*/
|
||||
@ -41,11 +41,6 @@ public class CuboidRegion implements Region {
|
||||
* Store the second point.
|
||||
*/
|
||||
private Vector pos2;
|
||||
/**
|
||||
* Stores the world.
|
||||
*/
|
||||
private LocalWorld world;
|
||||
|
||||
/**
|
||||
* Construct a new instance of this cuboid region.
|
||||
*
|
||||
@ -64,8 +59,8 @@ public class CuboidRegion implements Region {
|
||||
* @param pos2
|
||||
*/
|
||||
public CuboidRegion(LocalWorld world, Vector pos1, Vector pos2) {
|
||||
super(world);
|
||||
this.pos1 = pos1;
|
||||
this.world = world;
|
||||
this.pos2 = pos2;
|
||||
}
|
||||
|
||||
@ -327,6 +322,7 @@ public class CuboidRegion implements Region {
|
||||
*
|
||||
* @return iterator of points inside the region
|
||||
*/
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
return new Iterator<BlockVector>() {
|
||||
private Vector min = getMinimumPoint();
|
||||
@ -370,12 +366,4 @@ public class CuboidRegion implements Region {
|
||||
public String toString() {
|
||||
return getMinimumPoint() + " - " + getMaximumPoint();
|
||||
}
|
||||
|
||||
public LocalWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public void setWorld(LocalWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.data.ChunkStore;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -32,7 +30,7 @@ import java.util.HashSet;
|
||||
*
|
||||
* @author TomyLobo
|
||||
*/
|
||||
public class EllipsoidRegion implements Region {
|
||||
public class EllipsoidRegion extends AbstractRegion {
|
||||
/**
|
||||
* Stores the center.
|
||||
*/
|
||||
@ -41,11 +39,6 @@ public class EllipsoidRegion implements Region {
|
||||
* Stores the radiuses plus 0.5 on each axis.
|
||||
*/
|
||||
private Vector radius;
|
||||
/**
|
||||
* Stores the world.
|
||||
*/
|
||||
private LocalWorld world;
|
||||
|
||||
/**
|
||||
* Construct a new instance of this ellipsoid region.
|
||||
*
|
||||
@ -64,7 +57,7 @@ public class EllipsoidRegion implements Region {
|
||||
* @param radius
|
||||
*/
|
||||
public EllipsoidRegion(LocalWorld world, Vector center, Vector radius) {
|
||||
this.world = world;
|
||||
super(world);
|
||||
this.center = center;
|
||||
this.radius = radius;
|
||||
}
|
||||
@ -211,15 +204,6 @@ public class EllipsoidRegion implements Region {
|
||||
return pt.subtract(center).divide(radius).lengthSq() <= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iterator.
|
||||
*
|
||||
* @return iterator of points inside the region
|
||||
*/
|
||||
public Iterator<BlockVector> iterator() {
|
||||
return new RegionIterator(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string representation in the format
|
||||
* "(centerX, centerY, centerZ) - (radiusX, radiusY, radiusZ)".
|
||||
@ -231,14 +215,6 @@ public class EllipsoidRegion implements Region {
|
||||
return center + " - " + getRadius();
|
||||
}
|
||||
|
||||
public LocalWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public void setWorld(LocalWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void extendRadius(Vector minRadius) {
|
||||
setRadius(Vector.getMaximum(minRadius, getRadius()));
|
||||
}
|
||||
|
@ -37,14 +37,13 @@ import com.sk89q.worldedit.data.ChunkStore;
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class Polygonal2DRegion implements Region {
|
||||
public class Polygonal2DRegion extends AbstractRegion {
|
||||
private List<BlockVector2D> points;
|
||||
private BlockVector min;
|
||||
private BlockVector max;
|
||||
private int minY;
|
||||
private int maxY;
|
||||
private boolean hasY = false;
|
||||
private LocalWorld world;
|
||||
|
||||
/**
|
||||
* Construct the region
|
||||
@ -72,11 +71,11 @@ public class Polygonal2DRegion implements Region {
|
||||
* @param maxY
|
||||
*/
|
||||
public Polygonal2DRegion(LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
super(world);
|
||||
this.points = new ArrayList<BlockVector2D>(points);
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
hasY = true;
|
||||
this.world = world;
|
||||
recalculate();
|
||||
}
|
||||
|
||||
@ -440,6 +439,7 @@ public class Polygonal2DRegion implements Region {
|
||||
*
|
||||
* @return iterator of points inside the region
|
||||
*/
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
return new Polygonal2DRegionIterator(this);
|
||||
|
||||
@ -603,12 +603,4 @@ public class Polygonal2DRegion implements Region {
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public LocalWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public void setWorld(LocalWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren