org.bukkit.util.Vector#getBlockZ ( )源码实例Demo

下面列出了org.bukkit.util.Vector#getBlockZ ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: WildernessTp   文件: ClaimChecks.java
private boolean checkSurroundingWGClaims(Location loc){
    if(wild.getConfig().getBoolean("WorldGuard")){
            int distance = range / 2;
            Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
            Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
            for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
                for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
                    loc.setX(x);
                    loc.setY(Bukkit.getWorld(loc.getWorld().getName()).getHighestBlockYAt(x, z));
                    loc.setZ(z);
                    if (!WorldGuardWrapper.getInstance().getRegions(loc).isEmpty())
                        return true;
                }
            }
        }
    return false;
}
 
源代码2 项目: PGM   文件: CuboidBlockIterator.java
public CuboidBlockIterator(Vector min, Vector max) {
  this(
      min.getBlockX(),
      min.getBlockY(),
      min.getBlockZ(),
      max.getBlockX(),
      max.getBlockY(),
      max.getBlockZ());
}
 
源代码3 项目: WildernessTp   文件: Region.java
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;

}
 
源代码4 项目: WildernessTp   文件: ClaimChecks.java
private boolean checkSurroundingTowns(Location loc) {
    int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            Block block = new Location(loc.getWorld(), x, loc.getWorld().getHighestBlockYAt(x, z), z).getBlock();
            if (!TownyUniverse.isWilderness(block))
                return true;
        }
    }
    return false;
}
 
源代码5 项目: WildernessTp   文件: ClaimChecks.java
private boolean checkSurroundingFactions(Location loc) {
    int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            if (BoardColl.get().getFactionAt(PS.valueOf(new Location(loc.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z))).isNone())
                return true;
        }
    }
    return false;
}
 
源代码6 项目: WildernessTp   文件: ClaimChecks.java
@SuppressWarnings("deprecation")
private boolean checkSurroundingFactionsUUID(Location loc) {
    //Board board = co;
    int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            if (Board.getFactionAt(new FLocation(new Location(loc.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z))).isNone())
                return true;
        }
    }
    return false;
}
 
源代码7 项目: WildernessTp   文件: ClaimChecks.java
private boolean checkSurroundingLegacyFactions(Location loc) {
    net.redstoneore.legacyfactions.entity.Board board = net.redstoneore.legacyfactions.entity.Board.get();        int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            if (board.getFactionAt(new net.redstoneore.legacyfactions.FLocation(new Location(loc.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z))).isWilderness())
                return true;
        }
    }
    return false;
}
 
源代码8 项目: WildernessTp   文件: ClaimChecks.java
private boolean checkSurroundingsClaims(Location loc) {
    int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            if (GriefPrevention.instance.dataStore.getClaimAt(new Location(loc.getWorld(), x, loc.getWorld().getHighestBlockYAt(x, z), z), false, null) != null)
                return true;
        }
    }

    return false;
}
 
源代码9 项目: WildernessTp   文件: ClaimChecks.java
private boolean checkSurroundingKingdoms(Location loc) {
    int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            if (GameManagement.getLandManager().getOrLoadLand(new SimpleChunkLocation(new Location(loc.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z).getChunk())) != null)
                return true;
        }
    }
    return false;

}
 
源代码10 项目: Survival-Games   文件: MoveEvent.java
@EventHandler(priority = EventPriority.HIGHEST)
public void frozenSpawnHandler(PlayerMoveEvent e) {
    /*  Optimization for single game world. No longer works since support for multiple worlds was added
     *if(e.getPlayer().getWorld()!=SettingsManager.getGameWorld())
        return;*/
    if(GameManager.getInstance().getPlayerGameId(e.getPlayer()) == -1){
        playerpos.remove(e.getPlayer());
        return;
    }
    if(GameManager.getInstance().getGame(GameManager.getInstance().getPlayerGameId(e.getPlayer())).getMode() == Game.GameMode.INGAME)
        return;
    GameMode mo3 = GameManager.getInstance().getGameMode(GameManager.getInstance().getPlayerGameId(e.getPlayer()));
    if(GameManager.getInstance().isPlayerActive(e.getPlayer()) && mo3 != Game.GameMode.INGAME){
        if(playerpos.get(e.getPlayer()) == null){
            playerpos.put(e.getPlayer(), e.getPlayer().getLocation().toVector());
            return;
        }
        Location l = e.getPlayer().getLocation();
        Vector v = playerpos.get(e.getPlayer());
        if(l.getBlockX() != v.getBlockX()  || l.getBlockZ() != v.getBlockZ()){
            l.setX(v.getBlockX() + .5);
            l.setZ(v.getBlockZ() + .5);
            l.setYaw(e.getPlayer().getLocation().getYaw());
            l.setPitch(e.getPlayer().getLocation().getPitch());
            e.getPlayer().teleport(l);
        }
    }
}
 
源代码11 项目: Survival-Games   文件: ArenaDuplicator.java
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();
        }


    }
 
源代码12 项目: AreaShop   文件: Utils.java
/**
 * 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;
}
 
源代码13 项目: PGM   文件: BlockVectors.java
static BlockVector center(Vector blockPos) {
  return new BlockVector(
      blockPos.getBlockX() + 0.5, blockPos.getBlockY() + 0.5, blockPos.getBlockZ() + 0.5);
}
 
源代码14 项目: PGM   文件: BlockRegion.java
public BlockRegion(Vector block) {
  this.location = new Vector(block.getBlockX(), block.getBlockY(), block.getBlockZ());
}
 
源代码15 项目: PGM   文件: BlockRegion.java
@Override
public boolean contains(Vector point) {
  return this.location.getBlockX() == point.getBlockX()
      && this.location.getBlockY() == point.getBlockY()
      && this.location.getBlockZ() == point.getBlockZ();
}
 
源代码16 项目: ProjectAres   文件: BlockRegion.java
public BlockRegion(Vector block) {
    this.location = new Vector(block.getBlockX(), block.getBlockY(), block.getBlockZ());
}
 
源代码17 项目: CardinalPGM   文件: BlockRegion.java
@Override
public boolean contains(Vector vector) {
    return vector.getBlockX() == getVector().getBlockX() &&
            vector.getBlockY() == getVector().getBlockY() &&
            vector.getBlockZ() == getVector().getBlockZ();
}
 
源代码18 项目: UHC   文件: DeathContext.java
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()));
}
 
源代码20 项目: AreaShop   文件: GeneralRegion.java
/**
 * Calculate the volume of the region (could be expensive for polygon regions).
 * @return Number of blocks in the region
 */
private long calculateVolume() {
	// Use own calculation for polygon regions, as WorldGuard does not implement it and returns 0
	ProtectedRegion region = getRegion();
	if(region instanceof ProtectedPolygonalRegion) {
		Vector min = getMinimumPoint();
		Vector max = getMaximumPoint();

		// Exact, but slow algorithm
		if(getWidth() * getDepth() < 100) {
			long surface = 0;
			for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
				for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
					if (region.contains(x, min.getBlockY(), z)) {
						surface++;
					}
				}
			}
			return surface * getHeight();
		}
		// Estimate, but quick algorithm
		else {
			List<Vector> points = plugin.getWorldGuardHandler().getRegionPoints(region);
			int numPoints = points.size();
			if(numPoints < 3) {
				return 0;
			}

			double area = 0;
			int x1, x2, z1, z2;
			for(int i = 0; i <= numPoints - 2; i++) {
				x1 = points.get(i).getBlockX();
				z1 = points.get(i).getBlockZ();

				x2 = points.get(i + 1).getBlockX();
				z2 = points.get(i + 1).getBlockZ();

				area += ((z1 + z2) * (x1 - x2));
			}

			x1 = points.get(numPoints - 1).getBlockX();
			z1 = points.get(numPoints - 1).getBlockZ();
			x2 = points.get(0).getBlockX();
			z2 = points.get(0).getBlockZ();

			area += ((z1 + z2) * (x1 - x2));
			area = Math.ceil(Math.abs(area) / 2);
			return (long)(area * getHeight());
		}
	} else {
		return region.volume();
	}
}