Java Code Examples for org.bukkit.Location#getX()
The following examples show how to use
org.bukkit.Location#getX() .
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: TownManager.java From Civs with GNU General Public License v3.0 | 6 votes |
public List<Town> checkIntersect(Location location, TownType townType, int modifier) { int buildRadius = townType.getBuildRadius() + modifier; int buildRadiusY = townType.getBuildRadiusY() + modifier; List<Town> towns = new ArrayList<>(); for (Town town : getTowns()) { if (!location.getWorld().equals(town.getLocation().getWorld())) { continue; } TownType currentTownType = (TownType) ItemManager.getInstance().getItemType(town.getType()); if (location.getX() + buildRadius >= town.getLocation().getX() - currentTownType.getBuildRadius() && location.getX() - buildRadius <= town.getLocation().getX() + currentTownType.getBuildRadius() && location.getZ() + buildRadius >= town.getLocation().getZ() - currentTownType.getBuildRadius() && location.getZ() - buildRadius <= town.getLocation().getZ() + currentTownType.getBuildRadius() && Math.max(location.getY() - buildRadiusY, 0) <= Math.max(town.getLocation().getY() + currentTownType.getBuildRadiusY(), 0) && Math.min(location.getY() + buildRadiusY, location.getWorld().getMaxHeight()) >= Math.min(town.getLocation().getY() - currentTownType.getBuildRadiusY(), town.getLocation().getWorld().getMaxHeight())) { towns.add(town); } } return towns; }
Example 2
Source File: NMS_v1_9_R2.java From Crazy-Crates with MIT License | 6 votes |
@Override public List<Location> getLocations(File f, Location loc) { loc = loc.subtract(2, 1, 2); List<Location> locations = new ArrayList<>(); try { FileInputStream fis = new FileInputStream(f); NBTTagCompound nbt = NBTCompressedStreamTools.a(fis); short width = nbt.getShort("Width"); short height = nbt.getShort("Height"); short length = nbt.getShort("Length"); fis.close(); //paste for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { for (int z = 0; z < length; ++z) { final Location l = new Location(loc.getWorld(), x + loc.getX(), y + loc.getY(), z + loc.getZ()); locations.add(l); } } } } catch (Exception e) { e.printStackTrace(); } return locations; }
Example 3
Source File: ArrowTurret.java From Civs with GNU General Public License v3.0 | 6 votes |
private boolean hasCleanShot(Location shootHere, Location targetHere) { double x = shootHere.getX(); double y = shootHere.getY(); double z = shootHere.getZ(); double x1 = targetHere.getX(); double y1 = targetHere.getY(); double z1 = targetHere.getZ(); Vector start = new Vector(x, y, z); Vector end = new Vector (x1, y1, z1); BlockIterator bi = new BlockIterator(shootHere.getWorld(), start, end, 0, (int) shootHere.distance(targetHere)); while (bi.hasNext()) { Block block = bi.next(); // System.out.println(Civs.getPrefix() + ((int) block.getLocation().getX()) + // ":" + ((int) block.getLocation().getY()) + ":" + // ((int) block.getLocation().getZ()) + " " + !Util.isSolidBlock(block.getType())); if (!Util.isSolidBlock(block.getType())) { return false; } } return true; }
Example 4
Source File: MethodAPI_v1_13_R1.java From TAB with Apache License 2.0 | 5 votes |
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) { EntityLiving entity = (EntityLiving) entityliving; entity.locX = loc.getX(); entity.locY = loc.getY(); entity.locZ = loc.getZ(); entity.yaw = loc.getYaw(); entity.pitch = loc.getPitch(); return new PacketPlayOutEntityTeleport(entity); }
Example 5
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 6
Source File: FishingBoat.java From civcraft with GNU General Public License v2.0 | 5 votes |
@Override protected Location repositionCenter(Location center, String dir, double x_size, double z_size) { Location loc = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ(), center.getYaw(), center.getPitch()); // Reposition tile improvements if (this.isTileImprovement()) { // just put the center at 0,0 of this chunk? loc = center.getChunk().getBlock(0, center.getBlockY(), 0).getLocation(); //loc = center.getChunk().getBlock(arg0, arg1, arg2) } else { if (dir.equalsIgnoreCase("east")) { loc.setZ(loc.getZ() - (z_size / 2)); loc.setX(loc.getX() + SHIFT_OUT); } else if (dir.equalsIgnoreCase("west")) { loc.setZ(loc.getZ() - (z_size / 2)); loc.setX(loc.getX() - (SHIFT_OUT+x_size)); } else if (dir.equalsIgnoreCase("north")) { loc.setX(loc.getX() - (x_size / 2)); loc.setZ(loc.getZ() - (SHIFT_OUT+z_size)); } else if (dir.equalsIgnoreCase("south")) { loc.setX(loc.getX() - (x_size / 2)); loc.setZ(loc.getZ() + SHIFT_OUT); } } if (this.getTemplateYShift() != 0) { // Y-Shift based on the config, this allows templates to be built underground. loc.setY(WATER_LEVEL + this.getTemplateYShift()); } return loc; }
Example 7
Source File: MethodAPI_v1_13_R2.java From TAB with Apache License 2.0 | 5 votes |
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) { EntityLiving entity = (EntityLiving) entityliving; entity.locX = loc.getX(); entity.locY = loc.getY(); entity.locZ = loc.getZ(); entity.yaw = loc.getYaw(); entity.pitch = loc.getPitch(); return new PacketPlayOutEntityTeleport(entity); }
Example 8
Source File: SpawnEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onUpkeep(RegionUpkeepEvent event) { Location location = event.getRegion().getLocation(); if (!event.getRegion().getEffects().containsKey(KEY) || !Util.isLocationWithinSightOfPlayer(location)) { return; } EntityType entityType; try { entityType = EntityType.valueOf(event.getRegion().getEffects().get(KEY)); } catch (Exception ex) { Civs.logger.severe("Wrong entity type " + event.getRegion().getEffects().get(KEY) + " for " + event.getRegion().getType()); return; } RegionType regionType = (RegionType) ItemManager.getInstance().getItemType(event.getRegion().getType()); // int entityCount = 0; //TODO fix this so that it detects the correct type of entity int radius = Math.max(regionType.getEffectRadius(), regionType.getBuildRadius()); // for (Entity e : location.getWorld().getNearbyEntities(location, // radius, radius, radius)) { // if (entityType.getEntityClass().isAssignableFrom(e.getClass())) { // entityCount++; // if (entityCount > 5) { // return; // } // } // } if (location.getWorld().getNearbyEntities(location, radius, radius, radius).size() > 5) { return; } Location spawnLocation = new Location(location.getWorld(), location.getX(), location.getY() + 1, location.getZ()); location.getWorld().spawnEntity(spawnLocation, entityType); }
Example 9
Source File: BlockLogger.java From Civs with GNU General Public License v3.0 | 5 votes |
public CVItem getBlock(Location location) { CVItem returnBlock = blocks.get(Region.locationToString(location)); if (returnBlock == null) { Location newLocation = new Location(location.getWorld(), location.getX() + 0.5, location.getY() + 0.5, location.getZ() + 0.5); returnBlock = blocks.get(Region.locationToString(newLocation)); } return returnBlock; }
Example 10
Source File: BlockLineIterator.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("null") private static Vector fitInWorld(final Location l, final Vector dir) { if (0 <= l.getBlockY() && l.getBlockY() < l.getWorld().getMaxHeight()) return l.toVector(); final double y = Math2.fit(0, l.getY(), l.getWorld().getMaxHeight()); if (Math.abs(dir.getY()) < Skript.EPSILON) return new Vector(l.getX(), y, l.getZ()); final double dy = y - l.getY(); final double n = dy / dir.getY(); return l.toVector().add(dir.clone().multiply(n)); }
Example 11
Source File: WorldGuardHandler5.java From AreaShop with GNU General Public License v3.0 | 5 votes |
@Override public Set<ProtectedRegion> getApplicableRegionsSet(Location location) { Set<ProtectedRegion> result = new HashSet<>(); Vector vector = new Vector(location.getX(), location.getY(), location.getZ()); for(ProtectedRegion region : pluginInterface.getWorldGuard().getRegionManager(location.getWorld()).getRegions().values()) { if(region.contains(vector)) { result.add(region); } } return result; }
Example 12
Source File: NMSHacks.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static Packet spawnPlayerPacket(int entityId, UUID uuid, Location location, Player player) { return new PacketPlayOutNamedEntitySpawn(entityId, uuid, location.getX(), location.getY(), location.getZ(), encodeAngle(location.getYaw()), encodeAngle(location.getPitch()), copyEntityMetadata(player)); }
Example 13
Source File: Arena.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
public boolean containsBlock(Location v) { if (v.getWorld() != min.getWorld()) return false; final double x = v.getX(); final double y = v.getY(); final double z = v.getZ(); return x >= min.getBlockX() && x < max.getBlockX() + 1 && y >= min.getBlockY() && y < max.getBlockY() + 1 && z >= min.getBlockZ() && z < max.getBlockZ() + 1; }
Example 14
Source File: XParticle.java From XSeries with MIT License | 5 votes |
/** * Display a rendered image repeatedly. * * @param render the rendered image map. * @param location the dynamic location to display the image at. * @param quality the quality of the image is exactly the number of particles display for each pixel. Recommended value is 1 * @param speed the speed is exactly the same value as the speed of particles. Recommended amount is 0 * @param size the size of the particle. Recommended amount is 0.8 * @since 1.0.0 */ public static void displayRenderedImage(Map<Location, Color> render, Location location, int quality, int speed, float size) { for (Map.Entry<Location, Color> pixel : render.entrySet()) { Particle.DustOptions data = new Particle.DustOptions(pixel.getValue(), size); Location pixelLoc = pixel.getKey(); Location loc = new Location(location.getWorld(), location.getX() - pixelLoc.getX(), location.getY() - pixelLoc.getY(), location.getZ() - pixelLoc.getZ()); loc.getWorld().spawnParticle(Particle.REDSTONE, loc, quality, 0, 0, 0, speed, data); } }
Example 15
Source File: RegionManager.java From Civs with GNU General Public License v3.0 | 5 votes |
private Region treeSort(double maxdex, UUID worldUuid, Location location) { int index; double mindex = 0; double prevIndex = -5; double prevDiff = 999999; boolean roundUp = false; for (;;) { if (roundUp) { index = (int) Math.ceil(((maxdex - mindex) / 2) + mindex); } else { index = (int) Math.floor(((maxdex - mindex) / 2) + mindex); } Region r = regions.get(worldUuid).get(index); if (withinRegion(r, location)) { return r; } else if (location.getX() < r.getLocation().getX() - r.getRadiusXN()) { maxdex = index; roundUp = false; } else if (location.getX() > r.getLocation().getX() + r.getRadiusXN()) { mindex = index; roundUp = true; } else { return findRegion((int) mindex, (int) maxdex, location, index); } if (prevIndex == index || prevDiff == Math.abs(maxdex - mindex)) { return null; } prevDiff = Math.abs(maxdex - mindex); prevIndex = index; } }
Example 16
Source File: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static boolean isInArea(Location l, Location p1, Location p2) { if (!p1.getWorld().equals(l.getWorld())) { return false; } Location min = new Location(p1.getWorld(), Math.min(p1.getX(), p2.getX()), Math.min(p1.getY(), p2.getY()), Math.min(p1.getZ(), p2.getZ())); Location max = new Location(p1.getWorld(), Math.max(p1.getX(), p2.getX()), Math.max(p1.getY(), p2.getY()), Math.max(p1.getZ(), p2.getZ())); return (min.getX() <= l.getX() && min.getY() <= l.getY() && min.getZ() <= l.getZ() && max.getX() >= l.getX() && max.getY() >= l.getY() && max.getZ() >= l.getZ()); }
Example 17
Source File: Position.java From WorldBorderAPI with MIT License | 4 votes |
public Position(Location location){ this(location.getX(),location.getZ()); }
Example 18
Source File: Calculator.java From CS-CoreLib with GNU General Public License v3.0 | 4 votes |
public static Location centerPosition(Location l ) { double x = l.getX(); double z = l.getZ(); String[] rawX = String.valueOf(x).split("."); String[] rawZ = String.valueOf(z).split("."); String newX = rawX[0] + ".5"; String newZ = rawZ[0] + ".5"; l.setX(Double.parseDouble(newX)); l.setZ(Double.parseDouble(newZ)); return l; }
Example 19
Source File: Locations.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public static double horizontalDistance(Location a, Location b) { if(a.getWorld() != b.getWorld()) throw new IllegalArgumentException("Locations are in different worlds"); double dx = b.getX() - a.getX(); double dz = b.getZ() - a.getZ(); return Math.sqrt(dx * dx + dz * dz); }
Example 20
Source File: BlockCollisionUtil.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
public static boolean isSolid(Block b, Location l) { if(b.getType().name().equals("SNOW")) return false; if(b.getType().name().contains("SIGN")) return false; if (b.getType().name().endsWith("CARPET")) { return false; } if (b.getType() == Material.WATER) { if (QAMain.blockbullet_water) return true; } if (b.getType().name().contains("LEAVE")) { if (QAMain.blockbullet_leaves) return true; } if (b.getType().name().contains("SLAB") || b.getType().name().contains("STEP")) { if (!QAMain.blockbullet_halfslabs && ((l.getY() - l.getBlockY() > 0.5 && b.getData() == 0) || (l.getY() - l.getBlockY() <= 0.5 && b.getData() == 1))) return false; return true; } if (b.getType().name().contains("BED_") || b.getType().name().contains("_BED") || b.getType().name().contains("DAYLIGHT_DETECTOR")) { if (!QAMain.blockbullet_halfslabs && (l.getY() - l.getBlockY() > 0.5)) return false; return true; } if (b.getType().name().contains("DOOR")) { if (QAMain.blockbullet_door) return true; return false; } if (b.getType().name().contains("GLASS")) { if (QAMain.blockbullet_glass) return true; return false; } if (b.getType().name().contains("STAIR")) { if (b.getData() < 4 && (l.getY() - l.getBlockY() < 0.5)) return true; if (b.getData() >= 4 && (l.getY() - l.getBlockY() > 0.5)) return true; switch (b.getData()) { case 0: case 4: return l.getX() - (0.5 + l.getBlockX()) > 0; case 1: case 5: return l.getX() - (0.5 + l.getBlockX()) < 0; case 2: case 6: return l.getZ() - (0.5 + l.getBlockZ()) > 0; case 3: case 7: return l.getZ() - (0.5 + l.getBlockZ()) < 0; } } if (b.getType().name().endsWith("FERN")) { return false; } if (b.getType().isOccluding()) { return true; } return false; }