下面列出了org.bukkit.util.Vector#getBlockY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public CuboidBlockIterator(Vector min, Vector max) {
this(
min.getBlockX(),
min.getBlockY(),
min.getBlockZ(),
max.getBlockX(),
max.getBlockY(),
max.getBlockZ());
}
public boolean contains(Vector position) {
double x = position.getX();
double y = position.getY();
double z = position.getZ();
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
if (x >= min.getBlockX() && x <= max.getBlockX()
&& y >= min.getBlockY() && y <= max.getBlockY()
&& z >= min.getBlockZ() && z <= max.getBlockZ())
return true;
else
return false;
}
public void startDupe(Vector v1, Vector v2){
int factor = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
factor = 4;
int xspan = v2.getBlockX() - v1.getBlockX();
int maxx = GameManager.getInstance().getGame(1).getArena().getMax().getBlockX();
for(Game g: GameManager.getInstance().getGames()){
Location a1 = g.getArena().getMin();
Location a2 = g.getArena().getMax();
if(a1.getBlockX()>maxx){
maxx = a1.getBlockX();
}
if(a2.getBlockX()>maxx){
maxx = a2.getBlockX();
}
}
int divf = xspan / factor;
background = new background(Math.abs(v2.getBlockX()-v1.getBlockX()) * Math.abs(v2.getBlockY()-v1.getBlockY()) * Math.abs(v1.getBlockZ()-v2.getBlockZ()));
background.start();
for(int a = 1; a<=factor; a++){
System.out.println(xspan);
int sp1 = divf * a + v1.getBlockX();
int sp2 = divf * (a+1) + v1.getBlockX();
int y1 = v1.getBlockY();
int y2 = v2.getBlockY();
int z1 = v1.getBlockZ();
int z2 = v2.getBlockZ();
Vector s1 = new Vector((sp1<sp2)?sp1:sp2 , (y1<y2)?y1:y2 , (z1<z2)?z1:z2);
Vector s2 = new Vector((sp1>sp2)?sp1:sp2 , (y1>y2)?y1:y2 , (z1>z2)?z1:z2);
System.out.println(s1);
System.out.println(s2);
new DupeThread(s1,s2, maxx - v1.getBlockX(), 0, a).start();
}
}
/**
* Get all WorldGuard regions intersecting with a WorldEdit selection.
* @param selection The selection to check
* @return A list with all the WorldGuard regions intersecting with the selection
*/
public static List<ProtectedRegion> getWorldEditRegionsInSelection(WorldEditSelection selection) {
// Get all regions inside or intersecting with the WorldEdit selection of the player
World world = selection.getWorld();
RegionManager regionManager = AreaShop.getInstance().getRegionManager(world);
ArrayList<ProtectedRegion> result = new ArrayList<>();
Location selectionMin = selection.getMinimumLocation();
Location selectionMax = selection.getMaximumLocation();
for(ProtectedRegion region : regionManager.getRegions().values()) {
Vector regionMin = AreaShop.getInstance().getWorldGuardHandler().getMinimumPoint(region);
Vector regionMax = AreaShop.getInstance().getWorldGuardHandler().getMaximumPoint(region);
if(
( // x part, resolves to true if the selection and region overlap anywhere on the x-axis
(regionMin.getBlockX() <= selectionMax.getBlockX() && regionMin.getBlockX() >= selectionMin.getBlockX())
|| (regionMax.getBlockX() <= selectionMax.getBlockX() && regionMax.getBlockX() >= selectionMin.getBlockX())
|| (selectionMin.getBlockX() >= regionMin.getBlockX() && selectionMin.getBlockX() <= regionMax.getBlockX())
|| (selectionMax.getBlockX() >= regionMin.getBlockX() && selectionMax.getBlockX() <= regionMax.getBlockX())
) && ( // Y part, resolves to true if the selection and region overlap anywhere on the y-axis
(regionMin.getBlockY() <= selectionMax.getBlockY() && regionMin.getBlockY() >= selectionMin.getBlockY())
|| (regionMax.getBlockY() <= selectionMax.getBlockY() && regionMax.getBlockY() >= selectionMin.getBlockY())
|| (selectionMin.getBlockY() >= regionMin.getBlockY() && selectionMin.getBlockY() <= regionMax.getBlockY())
|| (selectionMax.getBlockY() >= regionMin.getBlockY() && selectionMax.getBlockY() <= regionMax.getBlockY())
) && ( // Z part, resolves to true if the selection and region overlap anywhere on the z-axis
(regionMin.getBlockZ() <= selectionMax.getBlockZ() && regionMin.getBlockZ() >= selectionMin.getBlockZ())
|| (regionMax.getBlockZ() <= selectionMax.getBlockZ() && regionMax.getBlockZ() >= selectionMin.getBlockZ())
|| (selectionMin.getBlockZ() >= regionMin.getBlockZ() && selectionMin.getBlockZ() <= regionMax.getBlockZ())
|| (selectionMax.getBlockZ() >= regionMin.getBlockZ() && selectionMax.getBlockZ() <= regionMax.getBlockZ())
)
) {
result.add(region);
}
}
return result;
}
static BlockVector center(Vector blockPos) {
return new BlockVector(
blockPos.getBlockX() + 0.5, blockPos.getBlockY() + 0.5, blockPos.getBlockZ() + 0.5);
}
public BlockRegion(Vector block) {
this.location = new Vector(block.getBlockX(), block.getBlockY(), block.getBlockZ());
}
@Override
public boolean contains(Vector point) {
return this.location.getBlockX() == point.getBlockX()
&& this.location.getBlockY() == point.getBlockY()
&& this.location.getBlockZ() == point.getBlockZ();
}
public BlockRegion(Vector block) {
this.location = new Vector(block.getBlockX(), block.getBlockY(), block.getBlockZ());
}
@Override
public boolean contains(Vector point) {
return this.location.getBlockX() == point.getBlockX() &&
this.location.getBlockY() == point.getBlockY() &&
this.location.getBlockZ() == point.getBlockZ();
}
public String blockCoords() {
final Vector coords = rawCoords();
return coords.getBlockX() + "," + coords.getBlockY() + "," + coords.getBlockZ();
}
@Override
public ProtectedCuboidRegion createCuboidRegion(String name, Vector corner1, Vector corner2) {
return new ProtectedCuboidRegion(name, new BlockVector(corner1.getBlockX(), corner1.getBlockY(), corner1.getBlockZ()), new BlockVector(corner2.getBlockX(), corner2.getBlockY(), corner2.getBlockZ()));
}
@Override
public boolean contains(Vector vector) {
return vector.getBlockX() == getVector().getBlockX() &&
vector.getBlockY() == getVector().getBlockY() &&
vector.getBlockZ() == getVector().getBlockZ();
}