public StructureGrowEvent(final Location location, final TreeType species, final boolean bonemeal, final Player player, final List<BlockState> blocks) { super(location.getWorld()); this.location = location; this.species = species; this.bonemeal = bonemeal; this.player = player; this.blocks = blocks; }
/** * Adds the location by another. * * @see Vector * @param vec The other location * @return the same location * @throws IllegalArgumentException for differing worlds */ public Location add(Location vec) { if (vec == null || vec.getWorld() != getWorld()) { throw new IllegalArgumentException("Cannot add Locations of differing worlds"); } x += vec.x; y += vec.y; z += vec.z; return this; }
/** * Subtracts the location by another. * * @see Vector * @param vec The other location * @return the same location * @throws IllegalArgumentException for differing worlds */ public Location subtract(Location vec) { if (vec == null || vec.getWorld() != getWorld()) { throw new IllegalArgumentException("Cannot add Locations of differing worlds"); } x -= vec.x; y -= vec.y; z -= vec.z; return this; }
/** * Sets the new respawn location * * @param respawnLocation new location for the respawn */ public void setRespawnLocation(Location respawnLocation) { Validate.notNull(respawnLocation, "Respawn location can not be null"); Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null"); this.respawnLocation = respawnLocation; }
/** * Plays the sound to all players at the given location. * * @param location Location at which to play the sound */ public void play(Location location) { location.getWorld().playSound(location, sound, volume, pitch); }
/** * Get the squared distance between this location and another. * * @see Vector * @param o The other location * @return the distance * @throws IllegalArgumentException for differing worlds */ public double distanceSquared(Location o) { if (o == null) { throw new IllegalArgumentException("Cannot measure distance to a null location"); } else if (o.getWorld() == null || getWorld() == null) { throw new IllegalArgumentException("Cannot measure distance to a null world"); } else if (o.getWorld() != getWorld()) { throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName()); } return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z); }
private Collection<Entity> getNearbyEntities() { return location.getWorld().getNearbyEntities(location, power, power, power); }
/** * Constructs the BlockIterator. * * @param loc The location for the start of the ray trace * @param yOffset The trace begins vertically offset from the start vector * by this value */ public BlockIterator(Location loc, double yOffset) { this(loc.getWorld(), loc.toVector(), loc.getDirection(), yOffset, 0); }
/** * Constructs the BlockIterator * * @param loc The location for the start of the ray trace * @param yOffset The trace begins vertically offset from the start vector * by this value * @param maxDistance This is the maximum distance in blocks for the * trace. Setting this value above 140 may lead to problems with * unloaded chunks. A value of 0 indicates no limit */ public BlockIterator(Location loc, double yOffset, int maxDistance) { this(loc.getWorld(), loc.toVector(), loc.getDirection(), yOffset, maxDistance); }
private Location getLocation() { return new Location(lowCorner.getWorld(), lowCorner.getBlockX() + x, lowCorner.getBlockY() + y, lowCorner.getBlockZ() + iteratorZ.next()); } }
/** * Attempts to grow this tree at its current location. If successful, the associated {@link * BlockStateDelegate} is instructed to set blocks to wood and leaves. * * @param loc the base of the trunk * @return true if successfully grown; false otherwise * @deprecated use {@link #generate(World, Random, int, int, int)} */ @Deprecated public boolean generate(Location loc) { return generate(loc.getWorld(), ThreadLocalRandom.current(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); }
/** * Create a WorldEdit location from a Bukkit location. * * @param location the Bukkit location * @return a WorldEdit location */ public static Location adapt(org.bukkit.Location location) { checkNotNull(location); Vector3 position = asVector(location); return new com.sk89q.worldedit.util.Location( adapt(location.getWorld()), position, location.getYaw(), location.getPitch()); }
/** * Checks if this entity is within the visible radius of a location. * * @param loc The location. * @return {@code true} if the entities can see each other, {@code false} if not. */ public boolean isWithinDistance(Location loc) { double dx = Math.abs(location.getX() - loc.getX()); double dz = Math.abs(location.getZ() - loc.getZ()); return loc.getWorld() == getWorld() && dx <= server.getViewDistance() * GlowChunk.WIDTH && dz <= server.getViewDistance() * GlowChunk.HEIGHT; }
private void spawnSnowman(Location location) { if (SNOWMAN_PATTERN.matches(location, true, 0, 0)) { location.getWorld() .spawnEntity(location.clone().subtract(-0.5, 2, -0.5), EntityType.SNOWMAN); } } }
@Override public void setBeamTarget(Location location) { if (location == null) { metadata.set(MetadataIndex.ENDERCRYSTAL_BEAM_TARGET, (BlockVector) null); } else if (!location.getWorld().equals(getWorld())) { throw new IllegalArgumentException( "Cannot set beam target location to different world"); } else { metadata.set(MetadataIndex.ENDERCRYSTAL_BEAM_TARGET, new BlockVector(location.getBlockX(), location.getBlockY(), location.getBlockZ())); } } }
private boolean spawnIronGolem(Location location) { if (IRONGOLEM_PATTERN.matches(location, true, 1, 0)) { Entity entity = location.getWorld() .spawnEntity(location.clone().subtract(-0.5, 2, -0.5), EntityType.IRON_GOLEM); ((GlowIronGolem) entity).setPlayerCreated(true); return true; } return false; }
private void updateActiveChunkCollection(GlowEntity entity) { // build a set of chunkManager around each player in this world, the // server view distance is taken here int radius = server.getViewDistance(); Location playerLocation = entity.getLocation(); if (playerLocation.getWorld() == this) { int cx = playerLocation.getBlockX() >> 4; int cz = playerLocation.getBlockZ() >> 4; for (int x = cx - radius; x <= cx + radius; x++) { for (int z = cz - radius; z <= cz + radius; z++) { if (isChunkLoaded(cx, cz)) { activeChunksSet.add(GlowChunk.Key.of(x, z)); } } } } }
/** * Creates a new region at the given corner with the same dimensions as this region. * @param lowCorner The corner to base the new region off of. * @return The new region. */ public RectangularRegion moveTo(Location lowCorner) { return new RectangularRegion( lowCorner, new Location( lowCorner.getWorld(), lowCorner.getBlockX() + widthX, lowCorner.getBlockY() + widthY, lowCorner.getBlockZ() + widthZ ) ); }
private void kill(boolean dropArmorStand) { active = false; ((GlowWorld) location.getWorld()) .showParticle(location.clone().add(0, 1.317, 0), Effect.TILE_DUST, Material.WOOD.getId(), 0, 0.125f, 0.494f, 0.125f, 0.1f, 10, 10); for (ItemStack stack : equipment.getArmorContents()) { if (InventoryUtil.isEmpty(stack)) { continue; } getWorld().dropItemNaturally(location, stack); } if (dropArmorStand) { getWorld().dropItemNaturally(location, new ItemStack(Material.ARMOR_STAND)); } }
private void createEffectCloud() { AreaEffectCloud cloud = (AreaEffectCloud) location.getWorld().spawnEntity(location, EntityType.AREA_EFFECT_CLOUD); cloud.setRadius(3); cloud.setRadiusPerTick(-.005f); ItemMeta meta = getItem().getItemMeta(); if (meta instanceof PotionMeta) { PotionMeta potionMeta = (PotionMeta) meta; cloud.setColor(potionMeta.getColor()); cloud.setBasePotionData(potionMeta.getBasePotionData()); for (PotionEffect effect : getEffects()) { cloud.addCustomEffect(effect, true); } } remove(); } }