Java Code Examples for org.bukkit.Location#getZ()
The following examples show how to use
org.bukkit.Location#getZ() .
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: NMSHacks.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
public static void showFakeItems(Plugin plugin, Player viewer, Location location, org.bukkit.inventory.ItemStack item, int count, Duration duration) { if(count <= 0) return; final EntityPlayer nmsPlayer = ((CraftPlayer) viewer).getHandle(); final int[] entityIds = new int[count]; for(int i = 0; i < count; i++) { final EntityItem entity = new EntityItem(nmsPlayer.getWorld(), location.getX(), location.getY(), location.getZ(), CraftItemStack.asNMSCopy(item)); entity.motX = randomEntityVelocity(); entity.motY = randomEntityVelocity(); entity.motZ = randomEntityVelocity(); sendPacket(viewer, new PacketPlayOutSpawnEntity(entity, ENTITY_TYPE_IDS.get(org.bukkit.entity.Item.class))); sendPacket(viewer, new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true)); entityIds[i] = entity.getId(); } scheduleEntityDestroy(plugin, viewer.getUniqueId(), duration, entityIds); }
Example 2
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 3
Source File: NPCPath.java From NPCFactory with MIT License | 6 votes |
public static NPCPath find(NPCEntity entity, Location to, double range, double speed) { if(speed > 1) { throw new IllegalArgumentException("Speed cannot be higher than 1!"); } try { BlockPosition posFrom = new BlockPosition(entity); BlockPosition posTo = new BlockPosition(to.getX(), to.getY(), to.getZ()); int k = (int) (range + 8.0); ChunkCache chunkCache = new ChunkCache(entity.world, posFrom.a(-k, -k, -k), posFrom.a(k, k, k), 0); PathEntity path = entity.getPathfinder().a(chunkCache, entity, posTo, (float) range); if(path != null) { return new NPCPath(entity, path, speed); } else { return null; } } catch(Exception e) { return null; } }
Example 4
Source File: MethodAPI_v1_7_R4.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: BoundingBoxUtil.java From QualityArmory with GNU General Public License v3.0 | 5 votes |
public static boolean within2DWidth(Entity e, Location closest, double minDist, double centerOffset) { double xS = (e.getLocation().getX()) - (closest.getX()); xS *= xS; double zS = (e.getLocation().getZ()) - (closest.getZ()); zS *= zS; double distancesqr = xS + zS; return distancesqr <= (minDist*minDist); }
Example 6
Source File: ProjectileParticlesModule.java From CardinalPGM with MIT License | 5 votes |
public static void sendArrowParticle(Projectile arrow, float x, float y, float z) { Location loc = arrow.getLocation(); PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(EnumParticle.REDSTONE, true, (float)loc.getX(), (float)loc.getY(), (float)loc.getZ(), x, y, z, 1f, 0); PacketUtils.broadcastPacketByUUID(packet, allArrows); if (arrow.getShooter() instanceof Player && selfArrows.contains(((Player) arrow.getShooter()).getUniqueId())) PacketUtils.sendPacket((Player) arrow.getShooter(), packet); }
Example 7
Source File: LocationBuilder.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Initializes a new LocationBuilder from the given BukkitLocation * * @param location location */ public LocationBuilder(Location location) { super(); if (location == null) throw new IllegalArgumentException("Location cannot be null!"); this.world = location.getWorld().getName(); this.x = location.getX(); this.y = location.getY(); this.z = location.getZ(); this.yaw = location.getYaw(); this.pitch = location.getPitch(); }
Example 8
Source File: CUIListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerMove(PlayerMoveEvent event) { Location from = event.getFrom(); Location to = event.getTo(); if ((int) from.getX() >> 2 != (int) to.getX() >> 2 || (int) from.getZ() >> 2 != (int) to.getZ() >> 2 || (int) from.getY() >> 2 != (int) to.getY() >> 2) { FawePlayer<Object> player = FawePlayer.wrap(event.getPlayer()); CUI cui = player.getMeta("CUI"); if (cui instanceof StructureCUI) { StructureCUI sCui = (StructureCUI) cui; sCui.update(); } } }
Example 9
Source File: TownManager.java From Civs with GNU General Public License v3.0 | 5 votes |
public Town getTownAt(Location location) { ItemManager itemManager = ItemManager.getInstance(); for (Town town : sortedTowns) { TownType townType = (TownType) itemManager.getItemType(town.getType()); int radius = townType.getBuildRadius(); int radiusY = townType.getBuildRadiusY(); Location townLocation = town.getLocation(); if (townLocation.getWorld() == null) { continue; } if (!townLocation.getWorld().equals(location.getWorld())) { continue; } if (townLocation.getX() - radius >= location.getX()) { break; } if (townLocation.getX() + radius >= location.getX() && townLocation.getZ() + radius >= location.getZ() && townLocation.getZ() - radius <= location.getZ() && townLocation.getY() - radiusY <= location.getY() && townLocation.getY() + radiusY >= location.getY()) { return town; } } return null; }
Example 10
Source File: Hologram.java From Holograms with MIT License | 5 votes |
private void reorganize() { Location location = getLocation(); double y = location.getY(); for (int i = 0 ; i < lines.size() ; i++) { HologramLine line = getLine(i); if (line instanceof ItemLine) { y -= 0.2; } Location lineLocation = new Location(location.getWorld(), location.getX(), y, location.getZ()); y -= line.getHeight(); y -= HologramLine.SPACE_BETWEEN_LINES; line.setLocation(lineLocation); } }
Example 11
Source File: Uncarried.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
protected boolean inPickupRange(Location playerLoc) { Location flagLoc = this.getLocation(); if (playerLoc.getY() < flagLoc.getY() + 2 && playerLoc.getY() >= flagLoc.getY() - 2) { double dx = playerLoc.getX() - flagLoc.getX(); double dz = playerLoc.getZ() - flagLoc.getZ(); if (dx * dx + dz * dz <= 1) { return true; } } return false; }
Example 12
Source File: BlockVectors.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
static boolean isInside(Vector point, Location blockLocation) { return blockLocation.getX() <= point.getX() && point.getX() <= blockLocation.getX() + 1 && blockLocation.getY() <= point.getY() && point.getY() <= blockLocation.getY() + 1 && blockLocation.getZ() <= point.getZ() && point.getZ() <= blockLocation.getZ() + 1; }
Example 13
Source File: TNTSheep.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public TNTSheep(Location location, Player target) { super(((CraftWorld) location.getWorld()).getHandle()); this.world = location.getWorld(); this.locX = location.getX(); this.locY = location.getY(); this.locZ = location.getZ(); try { Field b = this.goalSelector.getClass().getDeclaredField("b"); b.setAccessible(true); b.set(this.goalSelector, new ArrayList<>()); this.getAttributeInstance(GenericAttributes.b).setValue(128D); this.getAttributeInstance(GenericAttributes.d) .setValue( BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D)); } catch (Exception e) { BedwarsRel.getInstance().getBugsnag().notify(e); e.printStackTrace(); } this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, EntityHuman.class, 1D, false)); this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()), EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, false); ((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target); }
Example 14
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 15
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 16
Source File: NMSHandler.java From askyblock with GNU General Public License v2.0 | 5 votes |
@Override public void setFlowerPotBlock(Block block, ItemStack itemStack) { Location loc = block.getLocation(); CraftWorld cw = (CraftWorld)block.getWorld(); BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ()); TileEntityFlowerPot te = (TileEntityFlowerPot)cw.getHandle().getTileEntity(bp); //Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString())); net.minecraft.server.v1_8_R2.ItemStack cis = CraftItemStack.asNMSCopy(itemStack); te.a(cis.getItem(), cis.getData()); te.update(); }
Example 17
Source File: MethodAPI_v1_8_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 18
Source File: WorldBorderUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static boolean clampToBorder(Location location) { WorldBorder border = location.getWorld().getWorldBorder(); Location center = border.getCenter(); double radius = border.getSize() / 2d; double xMin = center.getX() - radius; double xMax = center.getX() + radius; double zMin = center.getZ() - radius; double zMax = center.getZ() + radius; boolean moved = false; if(location.getX() < xMin) { location.setX(xMin); moved = true; } if(location.getX() > xMax) { location.setX(xMax); moved = true; } if(location.getZ() < zMin) { location.setZ(zMin); moved = true; } if(location.getZ() > zMax) { location.setZ(zMax); moved = true; } return moved; }
Example 19
Source File: MiscUtils.java From BedWars with GNU Lesser General Public License v3.0 | 4 votes |
public static String setLocationToString(Location location) { return location.getX() + ";" + location.getY() + ";" + location.getZ() + ";" + location.getYaw() + ";" + location.getPitch(); }
Example 20
Source File: ExprCoordinate.java From Skript with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("null") @Override public Double convert(final Location l) { return axis == 0 ? l.getX() : axis == 1 ? l.getY() : l.getZ(); }