org.bukkit.Location.add()

Here are the examples of the java api org.bukkit.Location.add() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

100 Examples 7

18 Source : LocationUtils.java
with MIT License
from Redempt

/**
 * Sets the location's coordinates to the center point of its block coordinates, then returns it
 * @param loc The location
 * @return The block location
 */
public static Location center(Location loc) {
    return loc.add(.5, .5, .5);
}

18 Source : TutorialStage.java
with GNU Affero General Public License v3.0
from OvercastNetwork

static boolean isSafe(Location location) {
    Location scratch = location.clone();
    for (int level = 0; level <= 2; level++) {
        // set bottom left corner
        scratch.add(-STEVE_WIDTH / 2, level, -STEVE_WIDTH / 2);
        if (!isValidBlock(scratch))
            return false;
        // set top left corner
        scratch.add(0, 0, STEVE_WIDTH);
        if (!isValidBlock(scratch))
            return false;
        // set top right corner
        scratch.add(STEVE_WIDTH, 0, 0);
        if (!isValidBlock(scratch))
            return false;
        // set bottom right corner
        scratch.add(0, 0, -STEVE_WIDTH);
        if (!isValidBlock(scratch))
            return false;
        // reset
        scratch = location.clone();
    }
    return true;
}

18 Source : CustomBossCommandHandler.java
with GNU General Public License v3.0
from MagmaGuy

public static Location autoSeekSafeSpawnLocation(Location originalLocation) {
    Location newLocation = new Location(originalLocation.getWorld(), originalLocation.getBlockX() + 0.5, originalLocation.getBlockY() + 0.5, originalLocation.getBlockZ() + 0.5);
    for (int i = 0; i < 4; i++) if (newLocation.add(new Vector(0, i, 0)).getBlock().isPreplacedable()) {
        new DebugBlockLocation(newLocation);
        return newLocation;
    }
    return null;
}

18 Source : LocationUtils.java
with GNU General Public License v3.0
from Lix3nn53

public static Location getBlockCenter(Location loc) {
    return loc.add(0.5, 0, 0.5);
}

18 Source : ProjectileUtil.java
with GNU General Public License v3.0
from Lix3nn53

/**
 * Calculates the locations to spawn projectiles to rain them down
 * over a given location.
 *
 * @param loc    the center location to rain on
 * @param radius radius of the circle
 * @param height height above the target to use
 * @param amount amount of locations to calculate
 * @return list of locations to spawn projectiles
 */
public static ArrayList<Location> calcRain(Location loc, double radius, double height, int amount) {
    ArrayList<Location> list = new ArrayList<>();
    if (amount <= 0) {
        return list;
    }
    loc.add(0, height, 0);
    // One would be in the center
    list.add(loc);
    amount--;
    // Calculate locations
    int tiers = (amount + 7) / 8;
    for (int i = 0; i < tiers; i++) {
        double rad = radius * (tiers - i) / tiers;
        int tierNum = Math.min(amount, 8);
        double increment = 360 / tierNum;
        double angle = (i % 2) * 22.5;
        for (int j = 0; j < tierNum; j++) {
            double dx = Math.cos(angle) * rad;
            double dz = Math.sin(angle) * rad;
            Location l = loc.clone();
            l.add(dx, 0, dz);
            list.add(l);
            angle += increment;
        }
        amount -= tierNum;
    }
    return list;
}

18 Source : EllipsoidDrawer.java
with GNU General Public License v3.0
from KennyTV

private void showGrid(final Player player, final int width, final int length, final int height, final Location location, final double heightGrid, final double wideGrid) {
    for (double i = 0; i <= Math.PI; i += wideGrid) {
        for (double j = 0; j <= 2 * Math.PI; j += heightGrid) {
            final double x = width * Math.cos(j) * Math.sin(i);
            final double y = height * Math.cos(i);
            final double z = length * Math.sin(j) * Math.sin(i);
            playEffect(location.add(x, y, z), player);
            location.subtract(x, y, z);
        }
    }
}

18 Source : CylinderDrawer.java
with GNU General Public License v3.0
from KennyTV

private void drawCurves(final Player player, final int width, final int length, final int ticks, final Location location, final double wideGrid, final double heightSpace) {
    final double y = location.getY();
    for (double i = 0; i <= 2 * Math.PI; i += wideGrid) {
        final double x = width * Math.cos(i);
        final double z = length * Math.sin(i);
        location.add(x, -heightSpace, z);
        for (int j = 0; j < ticks; j++) {
            playEffect(location.add(0, heightSpace, 0), player);
        }
        location.subtract(x, 0, z).setY(y);
    }
}

18 Source : AdjacentBlocks.java
with GNU General Public License v3.0
from HawkAnticheat

// loop horizontally around nearby blocks about the size of a player's collision box
public static Set<Block> getBlocksInLocation(Location loc) {
    Location check = loc.clone();
    Set<Block> blocks = new HashSet<>();
    blocks.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    blocks.add(ServerUtils.getBlockAsync(check.add(0.3, 0, 0)));
    blocks.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    blocks.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    blocks.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    blocks.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    blocks.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    blocks.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    blocks.remove(null);
    return blocks;
}

18 Source : SimpleDrop.java
with GNU General Public License v3.0
from CoolLord22

Location randomiseLocation(Location location, Location maxOffset) {
    double x = maxOffset.getX();
    double y = maxOffset.getY();
    double z = maxOffset.getZ();
    return location.add(OtherDrops.rng.nextDouble() * x * (OtherDrops.rng.nextInt() > 0.5 ? 1 : -1), OtherDrops.rng.nextDouble() * y * (OtherDrops.rng.nextInt() > 0.5 ? 1 : -1), OtherDrops.rng.nextDouble() * z * (OtherDrops.rng.nextInt() > 0.5 ? 1 : -1));
}

17 Source : Hologram.java
with MIT License
from TabooLib

/**
 * 使该全息字以特定间隔不断向某个相对坐标位移
 *
 * @param vector 相对坐标
 * @param period 位移周期
 * @param times  位移次数
 * @return 修改后的 Hologram 实例
 */
public Hologram flash(Vector vector, int period, int times) {
    for (int i = 0; i < times; i++) {
        TabooLib.getPlugin().runTask(() -> flash(location.add(vector)), (long) period * i);
    }
    return this;
}

17 Source : EntityMockTest.java
with MIT License
from seeseemelk

@Test
public void teleport_Enreplacedy_LocationSetToEnreplacedy() {
    SimpleEnreplacedyMock enreplacedy2 = new SimpleEnreplacedyMock(server);
    Location location = enreplacedy2.getLocation();
    location.add(0, 5, 0);
    enreplacedy2.teleport(location);
    enreplacedy.teleport(enreplacedy2);
    enreplacedy.replacedertTeleported(location, 0);
}

17 Source : EntityMockTest.java
with MIT License
from seeseemelk

@Test
public void teleport_LocationAndCause_LocationSet() {
    Location location = enreplacedy.getLocation();
    location.add(0, 10.0, 0);
    enreplacedy.teleport(location, TeleportCause.CHORUS_FRUIT);
    enreplacedy.replacedertTeleported(location, 0);
    replacedertEquals(TeleportCause.CHORUS_FRUIT, enreplacedy.getTeleportCause());
}

17 Source : EntityMockTest.java
with MIT License
from seeseemelk

@Test
public void replacedertLocation_CorrectLocation_DoesNotreplacedert() {
    Location location = enreplacedy.getLocation();
    location.add(0, 10.0, 0);
    enreplacedy.teleport(location);
    enreplacedy.replacedertLocation(location, 5.0);
}

17 Source : EntityMockTest.java
with MIT License
from seeseemelk

@Test(expected = replacedertionError.clreplaced)
public void replacedertLocation_WrongLocation_replacederts() {
    Location location = enreplacedy.getLocation();
    location.add(0, 10.0, 0);
    enreplacedy.replacedertLocation(location, 5.0);
}

17 Source : ColorableCloud.java
with GNU General Public License v3.0
from SavageLabs

@Override
public void display(Location origin) {
    // Kinda sucky way to do it, but the ParticleEffect API just wont let me do offsets WITH colors :/.
    getParticleEffect().displayAtLocation(origin.add(0.1, 0, 0), 1, color);
    getParticleEffect().displayAtLocation(origin.add(0, 0, 0.1), 1, color);
    getParticleEffect().displayAtLocation(origin, 1, color);
    getParticleEffect().displayAtLocation(origin.add(0.1, 0, 0.1), 1, color);
    getParticleEffect().displayAtLocation(origin.add(-0.1, 0, -0.1), 1, color);
}

17 Source : SpheroidRegion.java
with MIT License
from Redempt

/**
 * Moves this SpheroidRegion according to a Vector
 * @param vec The vector representing the direction and amount to move
 * @return Itself
 */
@Override
public SpheroidRegion move(Vector vec) {
    center.add(vec);
    clearCached();
    return this;
}

17 Source : PortalSpawnPosition.java
with zlib License
from Lauriethefish

/**
 * Converts this spawn position into an actual portal position, by moving it from the bottom-left frame block to the exact center.
 * @return The converted {@link PortalPosition}.
 */
public PortalPosition toPortalPosition() {
    Location centerPos = position.clone();
    centerPos.add(direction.swapVector(new Vector(1.0, 1.0, 0.5)));
    centerPos.add(direction.swapVector(size.clone().multiply(0.5)));
    return new PortalPosition(centerPos, direction);
}

17 Source : CuboidDrawer.java
with GNU General Public License v3.0
from KennyTV

private void setGrid(final Player player, final Location location, final int gridSpace, final double maxTicks, final double maxGridTicks, final double xAddition, final double zAddition, final DrawedType drawedType) {
    int blocks = 0;
    for (int i = 0; i < maxTicks; i++) {
        // Horizontal grid
        if (settings.hasAdvancedGrid(drawedType) && blocks++ % gridSpace == 0 && i != 0) {
            final Location clone = location.clone();
            for (double j = 0; j < maxGridTicks; j++) {
                clone.add(xAddition, 0, zAddition);
                playEffect(clone, player, drawedType);
            }
        }
        // Pillar
        location.add(0, settings.getParticleSpace(), 0);
        playEffect(location, player, drawedType);
    }
}

17 Source : CuboidDrawer.java
with GNU General Public License v3.0
from KennyTV

private void tickGrid(final Player player, final Location location, final double maxTopGridTicks, final boolean x, final DrawedType drawedType) {
    final Location clone = location.clone();
    for (double j = 0; j < maxTopGridTicks; j++) {
        if (x)
            clone.add(0, 0, settings.getParticleGridSpace(drawedType));
        else
            clone.add(settings.getParticleGridSpace(drawedType), 0, 0);
        playEffect(clone, player, drawedType);
    }
}

17 Source : Ray.java
with GNU General Public License v3.0
from herobrine99dan

public static Location getEyeLocation(Location location, Player player) {
    return location.add(0, player.getEyeHeight(), 0);
}

17 Source : AdjacentBlocks.java
with GNU General Public License v3.0
from HawkAnticheat

/*public static boolean matIsAdjacent(Location loc, Material material) {
        Location check = loc.clone();
        return ServerUtils.getBlockAsync(check.add(0, 0, 0.3)).getType() == material ||
                ServerUtils.getBlockAsync(check.add(0.3, 0, 0)).getType() == material ||
                ServerUtils.getBlockAsync(check.add(0, 0, -0.3)).getType() == material ||
                ServerUtils.getBlockAsync(check.add(0, 0, -0.3)).getType() == material ||
                ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)).getType() == material ||
                ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)).getType() == material ||
                ServerUtils.getBlockAsync(check.add(0, 0, 0.3)).getType() == material ||
                ServerUtils.getBlockAsync(check.add(0, 0, 0.3)).getType() == material;
    }*/
public static boolean matContainsStringIsAdjacent(Location loc, String name) {
    Location check = loc.clone();
    Set<Block> sample = new HashSet<>();
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    for (Block b : sample) {
        if (b != null && b.getType().name().contains(name))
            return true;
    }
    return false;
}

17 Source : AdjacentBlocks.java
with GNU General Public License v3.0
from HawkAnticheat

public static boolean matIsAdjacent(Location loc, Material... materials) {
    Location check = loc.clone();
    Set<Block> sample = new HashSet<>();
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    for (Block b : sample) {
        if (b == null)
            continue;
        for (Material mat : materials) {
            if (b.getType() == mat)
                return true;
        }
    }
    return false;
}

17 Source : AdjacentBlocks.java
with GNU General Public License v3.0
from HawkAnticheat

public static boolean blockAdjacentIsLiquid(Location loc) {
    Location check = loc.clone();
    Set<Block> sample = new HashSet<>();
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    for (Block b : sample) {
        if (b != null && b.isLiquid())
            return true;
    }
    return false;
}

17 Source : AdjacentBlocks.java
with GNU General Public License v3.0
from HawkAnticheat

public static boolean blockAdjacentIsSolid(Location loc) {
    Location check = loc.clone();
    Set<Block> sample = new HashSet<>();
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, -0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(-0.3, 0, 0)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    sample.add(ServerUtils.getBlockAsync(check.add(0, 0, 0.3)));
    for (Block b : sample) {
        if (b != null && b.getType().isSolid())
            return true;
    }
    return false;
}

17 Source : Transform.java
with Apache License 2.0
from GorgeousOne

public Location transformLoc(Location loc) {
    if (!isRotY0Deg()) {
        loc.subtract(rotCenter);
        rotateLoc(loc);
        loc.add(rotCenter);
    }
    if (translation.lengthSquared() != 0) {
        loc.add(translation);
    }
    return loc;
}

17 Source : OldBossBar.java
with GNU General Public License v3.0
from GC-spigot

private Location getWitherLocation(Location location) {
    return location.add(location.getDirection().multiply(60));
}

16 Source : PlayerMoveListener.java
with GNU Affero General Public License v3.0
from PGMDev

/**
 * Modify the to location of the given event to prevent the movement and move the player so they
 * are standing on the center of the block at the from location.
 */
private static void resetPosition(final PlayerMoveEvent event) {
    Location newLoc;
    double yValue = event.getFrom().getY();
    if (yValue <= 0 || event instanceof PlayerTeleportEvent) {
        newLoc = event.getFrom();
    } else {
        newLoc = BlockVectors.center(event.getFrom()).subtract(new Vector(0, 0.5, 0));
        if (newLoc.getBlock() != null) {
            switch(newLoc.getBlock().getType()) {
                case STEP:
                case WOOD_STEP:
                    newLoc.add(new Vector(0, 0.5, 0));
                    break;
                default:
                    break;
            }
        }
    }
    newLoc.setPitch(event.getTo().getPitch());
    newLoc.setYaw(event.getTo().getYaw());
    event.setCancelled(false);
    event.setTo(newLoc);
}

16 Source : SkeletonPillar.java
with GNU General Public License v3.0
from MagmaGuy

private void pillarEffect(Location location, int timer, int offset) {
    location.add(locationMover(location, timer, offset));
    location.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, location, 15, 0.1, 5, 0.1, 0.05);
    pillarDamage(location);
}

16 Source : GenericAntiExploitEvent.java
with GNU General Public License v3.0
from MagmaGuy

private Block defineMaterial(Vector offset) {
    Location clonedLocation = enreplacedy.getLocation().getBlock().getLocation().add(new Vector(0.5, 0.5, 0.5)).clone();
    // Location templocation = clonedLocation.clone().add(offset);
    // new DebugBlockLocation(templocation);
    return clonedLocation.add(offset).getBlock();
}

16 Source : ArrangementFillHemisphere.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.fillHemisphere(location1, particle, radius, amount, dustOptions);
}

16 Source : ArrangementFillHemisphere.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset, float yaw, float pitch) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.fillHemisphere(location1, particle, radius, amount, dustOptions);
}

16 Source : ArrangementFillCircle.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset, float yaw, float pitch) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.fillCircle(location1, particle, radius, amount, dustOptions, direction);
}

16 Source : ArrangementFillCircle.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.fillCircle(location1, particle, radius, amount, dustOptions, direction);
}

16 Source : ArrangementDrawLine.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset, float yaw, float pitch) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.drawLine(location1, particle, dustOptions, length, gap);
}

16 Source : ArrangementDrawLine.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.drawLine(location1, particle, dustOptions, length, gap);
}

16 Source : SimpleWorld.java
with GNU General Public License v3.0
from Incendo

@Override
@Nullable
public Location getSpawn() {
    if (this.bukkitWorld == null) {
        return null;
    }
    final Location location = this.bukkitWorld.getSpawnLocation().clone();
    location.add(0.5, 0, 0.5);
    return location;
}

16 Source : Hologram.java
with MIT License
from Holovid

/**
 * Sends a spawn packet for the hologram to the given player if they weren't already in the tracking set.
 *
 * @param player player
 */
public void addToTracking(final Player player) {
    Preconditions.checkArgument(spawned);
    if (!viewers.add(player))
        return;
    final Location location = baseLocation.clone();
    for (final HologramLine line : lines) {
        final PacketContainer spawnPacket = line.createSpawnPackets(location);
        final PacketContainer metadataPacket = line.createMetadataPacket();
        distributePacket(player, spawnPacket);
        distributePacket(player, metadataPacket);
        location.add(0, 0.225D, 0);
    }
}

16 Source : MovementValuesHelper.java
with GNU General Public License v3.0
from herobrine99dan

public Location getEyeLocation(Location location, Player player) {
    return location.add(0, player.getEyeHeight(), 0);
}

16 Source : Adjacent.java
with GNU General Public License v3.0
from CoolLord22

public boolean matches(Block block, Material mat) {
    if (block == null)
        return false;
    boolean match = false;
    String faceName = "";
    // if (this.name().equalsIgnoreCase("below")) {
    Location checkLoc = block.getLocation().clone().add(-1, -1, -1);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (checkLoc.getBlock().getType() == mat) {
                match = true;
            }
            checkLoc.add(1, 0, 0);
        }
        checkLoc.add(-3, 0, 1);
    }
    // } else if (BlockFace.valueOf(faceName) != null) {
    if (block.getRelative(BlockFace.valueOf(faceName)).getType() == mat)
        match = true;
    // }
    return match;
}

16 Source : ExplosionUpdateCommand.java
with GNU General Public License v3.0
from APDevTeam

@Override
public void doUpdate() {
    // if (explosionStrength > 0) { // don't bother with tiny explosions
    // Location loc = new Lo cation(explosionLocation.getWorld(), explosionLocation.getX() + 0.5, explosionLocation.getY() + 0.5, explosionLocation.getZ());
    if (Settings.Debug) {
        Bukkit.broadcastMessage("Explosion strength: " + explosionStrength + " at " + explosionLocation.toVector().toString());
    }
    this.createExplosion(explosionLocation.add(.5, .5, .5), explosionStrength);
// }
}

15 Source : TargetHelper.java
with MIT License
from zeshan321

/**
 * Checks whether or not the line between the two points is obstructed
 *
 * @param loc1 first location
 * @param loc2 second location
 * @return the location of obstruction or null if not obstructed
 */
public boolean isObstructed(Location loc1, Location loc2) {
    if (loc1.getX() == loc2.getX() && loc1.getY() == loc2.getY() && loc1.getZ() == loc2.getZ()) {
        return false;
    }
    Vector slope = loc2.clone().subtract(loc1).toVector();
    int steps = (int) (slope.length() * 4) + 1;
    slope.multiply(1.0 / steps);
    Location temp = loc1.clone();
    for (int i = 0; i < steps; i++) {
        temp.add(slope);
        if (temp.getBlock().getType().isSolid() && !temp.getBlock().getType().toString().contains("FENCE") && !temp.getBlock().getType().toString().contains("GLreplaced")) {
            return true;
        }
    }
    return false;
}

15 Source : TreasureChest.java
with GNU General Public License v2.0
from PatoTheBest

private Location getChestLocation(int i, Location loc) {
    Location chestLocation = this.center.clone();
    chestLocation.setX(loc.getBlockX() + 0.5D);
    chestLocation.setY(loc.getBlockY() + 1.0D);
    chestLocation.setZ(loc.getBlockZ() + 0.5D);
    switch(i) {
        case 1:
            chestLocation.add(2.0D, 0.0D, 0.0D);
            break;
        case 2:
            chestLocation.add(-2.0D, 0.0D, 0.0D);
            break;
        case 3:
            chestLocation.add(0.0D, 0.0D, 2.0D);
            break;
        case 4:
            chestLocation.add(0.0D, 0.0D, -2.0D);
    }
    return chestLocation;
}

15 Source : ArrangementSingle.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, Vector offset) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.playSingleParticle(location1, particle, dustOptions);
}

15 Source : ArrangementDrawCube.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.drawCube(location1, particle, dustOptions, length, gap, false, 0, 0);
}

15 Source : ArrangementDrawCube.java
with GNU General Public License v3.0
from Lix3nn53

@Override
public void play(Location location, @Nullable Vector offset, float yaw, float pitch) {
    Location location1 = location.clone();
    if (offset != null) {
        location1.add(offset);
    }
    ParticleShapes.drawCube(location1, particle, dustOptions, length, gap, true, yaw, pitch);
}

15 Source : PolygonalDrawer.java
with GNU General Public License v3.0
from KennyTV

private void connect(final Simple2DVector vector, final int bottom, final int top, final int upwardsTicks, final Location location, final Player player) {
    final double length = vector.length();
    final double factor = length * settings.getParticlesPerBlock();
    final double x = vector.getX() / factor;
    final double z = vector.getZ() / factor;
    final int ticks = (int) factor;
    for (int i = 0; i < ticks; i++) {
        playEffect(location.add(x, 0, z), player);
        location.setY(top);
        playEffect(location, player);
        location.setY(bottom);
    }
    for (int j = 1; j < upwardsTicks; j++) {
        location.setY(location.getY() + settings.getParticleSpace());
        playEffect(location, player);
    }
    location.setY(bottom);
}

15 Source : Hologram.java
with MIT License
from Holovid

/**
 * Spawns the hologram and sends spawn packets to players in range.
 *
 * @param location base location
 */
public void spawn(final Location location) {
    Preconditions.checkArgument(!spawned);
    this.baseLocation = location.clone();
    this.spawned = true;
    // Check for players in range
    for (final Player player : Bukkit.getOnlinePlayers()) {
        if (!baseLocation.getWorld().equals(player.getWorld()))
            continue;
        if (player.getLocation().distanceSquared(baseLocation) < TRACKING_DISTANCE_SQUARED) {
            viewers.add(player);
        }
    }
    if (viewers.isEmpty())
        return;
    // Send spawn packets
    for (final HologramLine line : lines) {
        final PacketContainer spawnPacket = line.createSpawnPackets(location);
        final PacketContainer metadataPacket = line.createMetadataPacket();
        for (final Player player : viewers) {
            distributePacket(player, spawnPacket);
            distributePacket(player, metadataPacket);
        }
        location.add(0, 0.225D, 0);
    }
}

15 Source : NessPlayer.java
with GNU General Public License v3.0
from herobrine99dan

/**
 * Drags down the player
 */
// TODO Implement damage, using proportions
public boolean completeDragDown() {
    if (!player.isOnline()) {
        return false;
    }
    final long current = System.nanoTime() / 1000_000L;
    if ((current - setBackTicks) > 40) {
        double ytoAdd = player.getVelocity().getY();
        if (ytoAdd > 0) {
            return false;
        }
        final Location block = player.getLocation().clone().add(0, ytoAdd, 0);
        for (int i = 0; i < 10; i++) {
            if (block.getBlock().getType().isSolid()) {
                block.add(0, 0.1, 0);
            } else {
                break;
            }
        }
        player.teleport(block, TeleportCause.PLUGIN);
    }
    hreplacedetback = true;
    setBackTicks = current;
    setBackTicks++;
    return true;
}

15 Source : SpreadPlayersCommand.java
with GNU General Public License v3.0
from CrucibleMC

private int range(World world, double distance, double xRangeMin, double zRangeMin, double xRangeMax, double zRangeMax, Location[] locations) {
    boolean flag = true;
    double max;
    int i;
    for (i = 0; i < 10000 && flag; ++i) {
        flag = false;
        max = Float.MAX_VALUE;
        Location loc1;
        int j;
        for (int k = 0; k < locations.length; ++k) {
            Location loc2 = locations[k];
            j = 0;
            loc1 = new Location(world, 0, 0, 0);
            for (int l = 0; l < locations.length; ++l) {
                if (k != l) {
                    Location loc3 = locations[l];
                    double dis = loc2.distanceSquared(loc3);
                    max = Math.min(dis, max);
                    if (dis < distance) {
                        ++j;
                        loc1.add(loc3.getX() - loc2.getX(), 0, 0);
                        loc1.add(loc3.getZ() - loc2.getZ(), 0, 0);
                    }
                }
            }
            if (j > 0) {
                loc2.setX(loc2.getX() / j);
                loc2.setZ(loc2.getZ() / j);
                double d7 = Math.sqrt(loc1.getX() * loc1.getX() + loc1.getZ() * loc1.getZ());
                if (d7 > 0.0D) {
                    loc1.setX(loc1.getX() / d7);
                    loc2.add(-loc1.getX(), 0, -loc1.getZ());
                } else {
                    double x = xRangeMin >= xRangeMax ? xRangeMin : random.nextDouble() * (xRangeMax - xRangeMin) + xRangeMin;
                    double z = zRangeMin >= zRangeMax ? zRangeMin : random.nextDouble() * (zRangeMax - zRangeMin) + zRangeMin;
                    loc2.setX(x);
                    loc2.setZ(z);
                }
                flag = true;
            }
            boolean swap = false;
            if (loc2.getX() < xRangeMin) {
                loc2.setX(xRangeMin);
                swap = true;
            } else if (loc2.getX() > xRangeMax) {
                loc2.setX(xRangeMax);
                swap = true;
            }
            if (loc2.getZ() < zRangeMin) {
                loc2.setZ(zRangeMin);
                swap = true;
            } else if (loc2.getZ() > zRangeMax) {
                loc2.setZ(zRangeMax);
                swap = true;
            }
            if (swap) {
                flag = true;
            }
        }
        if (!flag) {
            Location[] locs = locations;
            int i1 = locations.length;
            for (j = 0; j < i1; ++j) {
                loc1 = locs[j];
                if (world.getHighestBlockYAt(loc1) == 0) {
                    double x = xRangeMin >= xRangeMax ? xRangeMin : random.nextDouble() * (xRangeMax - xRangeMin) + xRangeMin;
                    double z = zRangeMin >= zRangeMax ? zRangeMin : random.nextDouble() * (zRangeMax - zRangeMin) + zRangeMin;
                    locations[i] = (new Location(world, x, 0, z));
                    loc1.setX(x);
                    loc1.setZ(z);
                    flag = true;
                }
            }
        }
    }
    if (i >= 10000) {
        return -1;
    } else {
        return i;
    }
}

14 Source : Util.java
with GNU General Public License v3.0
from PolyhedralDev

public static boolean tpBiome(Player p, String[] args) {
    if (args[0].equalsIgnoreCase("END") || args[0].equalsIgnoreCase("SHATTERED_END") || args[0].equalsIgnoreCase("VOID") || args[0].equalsIgnoreCase("STARFIELD") || args[0].equalsIgnoreCase("SHATTERED_FOREST") || args[0].equalsIgnoreCase("AETHER") || args[0].equalsIgnoreCase("AETHER_HIGHLANDS") || (BetterEnd.isPremium() && args[0].equalsIgnoreCase("AETHER_HIGHLANDS_FOREST")) || (BetterEnd.isPremium() && args[0].equalsIgnoreCase("AETHER_FOREST"))) {
        LangUtil.send("commands.locating-biome", p, args[0]);
        int tries = 0;
        Location candidate = p.getLocation();
        while (tries < 400000) {
            Location candidateN = candidate.add(tries, 0, 0);
            if (EndBiomeGrid.fromWorld(p.getWorld()).getBiome(candidateN).equals(EndBiome.valueOf(args[0].toUpperCase())) && Math.sqrt(Math.pow(candidateN.getBlockX(), 2) + Math.pow(candidateN.getBlockZ(), 2)) > 1000) {
                LangUtil.send("commands.tp", p);
                p.teleport(candidateN);
                return true;
            }
            candidateN = candidate.add(-tries, 0, 0);
            if (EndBiomeGrid.fromWorld(p.getWorld()).getBiome(candidateN).equals(EndBiome.valueOf(args[0].toUpperCase())) && Math.sqrt(Math.pow(candidateN.getBlockX(), 2) + Math.pow(candidateN.getBlockZ(), 2)) > 1000) {
                LangUtil.send("commands.tp", p);
                p.teleport(candidateN);
                return true;
            }
            candidateN = candidate.add(0, 0, tries);
            if (EndBiomeGrid.fromWorld(p.getWorld()).getBiome(candidateN).equals(EndBiome.valueOf(args[0].toUpperCase())) && Math.sqrt(Math.pow(candidateN.getBlockX(), 2) + Math.pow(candidateN.getBlockZ(), 2)) > 1000) {
                LangUtil.send("commands.tp", p);
                p.teleport(candidateN);
                return true;
            }
            candidateN = candidate.add(0, 0, -tries);
            if (EndBiomeGrid.fromWorld(p.getWorld()).getBiome(candidateN).equals(EndBiome.valueOf(args[0].toUpperCase())) && Math.sqrt(Math.pow(candidateN.getBlockX(), 2) + Math.pow(candidateN.getBlockZ(), 2)) > 1000) {
                LangUtil.send("commands.tp", p);
                p.teleport(candidateN);
                return true;
            }
            tries++;
        }
        LangUtil.send("commands.unable-to-locate", p);
        return true;
    } else
        return false;
}

See More Examples