Java Code Examples for org.bukkit.util.Vector#getBlockZ()
The following examples show how to use
org.bukkit.util.Vector#getBlockZ() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClaimChecks.java From WildernessTp with MIT License | 6 votes |
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; }
Example 2
Source File: ClaimChecks.java From WildernessTp with MIT License | 5 votes |
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; }
Example 3
Source File: Utils.java From AreaShop with GNU General Public License v3.0 | 5 votes |
/** * 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; }
Example 4
Source File: ArenaDuplicator.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
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(); } }
Example 5
Source File: MoveEvent.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
@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); } } }
Example 6
Source File: ClaimChecks.java From WildernessTp with MIT License | 5 votes |
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; }
Example 7
Source File: ClaimChecks.java From WildernessTp with MIT License | 5 votes |
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; }
Example 8
Source File: ClaimChecks.java From WildernessTp with MIT License | 5 votes |
@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; }
Example 9
Source File: ClaimChecks.java From WildernessTp with MIT License | 5 votes |
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; }
Example 10
Source File: ClaimChecks.java From WildernessTp with MIT License | 5 votes |
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; }
Example 11
Source File: Region.java From WildernessTp with MIT License | 5 votes |
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; }
Example 12
Source File: CuboidBlockIterator.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public CuboidBlockIterator(Vector min, Vector max) { this( min.getBlockX(), min.getBlockY(), min.getBlockZ(), max.getBlockX(), max.getBlockY(), max.getBlockZ()); }
Example 13
Source File: BlockVectors.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
static BlockVector center(Vector blockPos) { return new BlockVector( blockPos.getBlockX() + 0.5, blockPos.getBlockY() + 0.5, blockPos.getBlockZ() + 0.5); }
Example 14
Source File: BlockRegion.java From CardinalPGM with MIT License | 4 votes |
@Override public boolean contains(Vector vector) { return vector.getBlockX() == getVector().getBlockX() && vector.getBlockY() == getVector().getBlockY() && vector.getBlockZ() == getVector().getBlockZ(); }
Example 15
Source File: BlockRegion.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public BlockRegion(Vector block) { this.location = new Vector(block.getBlockX(), block.getBlockY(), block.getBlockZ()); }
Example 16
Source File: BlockRegion.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean contains(Vector point) { return this.location.getBlockX() == point.getBlockX() && this.location.getBlockY() == point.getBlockY() && this.location.getBlockZ() == point.getBlockZ(); }
Example 17
Source File: BlockRegion.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public BlockRegion(Vector block) { this.location = new Vector(block.getBlockX(), block.getBlockY(), block.getBlockZ()); }
Example 18
Source File: DeathContext.java From UHC with MIT License | 4 votes |
public String blockCoords() { final Vector coords = rawCoords(); return coords.getBlockX() + "," + coords.getBlockY() + "," + coords.getBlockZ(); }
Example 19
Source File: FastAsyncWorldEditWorldGuardHandler.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@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())); }
Example 20
Source File: GeneralRegion.java From AreaShop with GNU General Public License v3.0 | 4 votes |
/** * 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(); } }