Package org.bukkit.util

Examples of org.bukkit.util.Vector


        assertThat((double) location.getPitch(), is(closeTo(pitch, δ)));
    }

    @Test
    public void testExpectedXYZ() {
        Vector vector = getLocation().getDirection();

        assertThat(vector.getX(), is(closeTo(x, δ)));
        assertThat(vector.getY(), is(closeTo(y, δ)));
        assertThat(vector.getZ(), is(closeTo(z, δ)));
    }
View Full Code Here


        assertThat(vector.getY(), is(closeTo(y, δ)));
        assertThat(vector.getZ(), is(closeTo(z, δ)));
    }

    private Vector getVector() {
        return new Vector(x, y, z);
    }
View Full Code Here

            ny *= speed;
            nz *= speed;
            float f3 = (float) Math.sqrt(nx * nx + nz * nz);

            SmallFireball f = BukkitUtil.toSign(getSign()).getWorld().spawn(shootLoc, SmallFireball.class);
            f.setVelocity(new Vector(nx,ny,nz));
            f.getLocation().setYaw((float) (Math.atan2(nx, nz) * 180.0D / 3.1415927410125732D));
            f.getLocation().setPitch((float) (Math.atan2(ny, f3) * 180.0D / 3.1415927410125732D));
        }
    }
View Full Code Here

        boolean isNew = false;

        if(ar == null || !ar.isValid() || ar.isDead() || !ar.getLocation().getBlock().equals(block)) {
            if(ar != null && !ar.getLocation().getBlock().equals(block))
                ar.remove();
            ar = block.getWorld().spawnArrow(BlockUtil.getBlockCentre(block).subtract(0, 0.5, 0), new Vector(0,-0.1,0), 0.01f, 0);
            isNew = true;
        }
        if (!chairs.containsKey(player.getName()))
            CraftBookPlugin.inst().wrapPlayer(player).print("mech.chairs.sit");
        // Attach the player to said arrow.
View Full Code Here

    /**
     * WorldEdit's Vector type collides with Bukkit's Vector type here. It's not pleasant.
     */
    public static Vector propel(BlockFace face) {

        return new Vector(face.getModX() * 0.2, face.getModY() * 0.2, face.getModZ() * 0.2);
    }
View Full Code Here

            }
        }
        Minecart cart = blocks.rail.getWorld().spawn(location, type.toClass());
        if(minecartDispenserPropel) {
            BlockFace dir = SignUtil.getBack(blocks.sign);
            Vector vel = new Vector(dir.getModX(), dir.getModY(), dir.getModZ());
            cart.setVelocity(vel.normalize());
        }
    }
View Full Code Here

                cancel();
                return;
            }

            item.teleport(BlockUtil.getBlockCentre(block).add(0, 0.5, 0));
            item.setVelocity(new Vector(0,0.01,0));
        }
View Full Code Here

        MaterialData d = dis.getBlock().getState().getData();
        BlockFace face = ((org.bukkit.material.Dispenser) d).getFacing();
        Location dispenserLoc = dis.getBlock().getRelative(face).getLocation();
        for (Entity e : dis.getWorld().getChunkAt(dispenserLoc).getEntities()) {
            if (EntityUtil.isEntityInBlock(e, dispenserLoc.getBlock())) {
                Vector dir = new Vector(((DirectionalContainer) dis.getData()).getFacing().getModX(),((DirectionalContainer) dis.getData()).getFacing().getModY(),((DirectionalContainer) dis.getData()).getFacing().getModZ());
                e.setVelocity(e.getVelocity().add(dir).normalize().multiply(10));
            }
        }
        return true;
    }
View Full Code Here

            mult = Double.parseDouble(signState.getLine(2));
        } catch (Exception e) {
            mult = 1;
        }

        Vector vel = new Vector(piston.getFacing().getModX(), piston.getFacing().getModY(), piston.getFacing().getModZ()).multiply(mult);
        if (trigger.getRelative(piston.getFacing()).getType() == Material.AIR || trigger.getRelative(piston.getFacing()).getState() != null && InventoryUtil.doesBlockHaveInventory(trigger.getRelative(piston.getFacing())) || trigger.getRelative(piston.getFacing()).getType() == Material.PISTON_MOVING_PIECE || trigger.getRelative(piston.getFacing()).getType() == Material.PISTON_EXTENSION || pistonsBounceBlacklist.contains(new ItemInfo(trigger.getRelative(piston.getFacing())))) {
            for (Entity ent : trigger.getRelative(piston.getFacing()).getChunk().getEntities()) {
                if (EntityUtil.isEntityInBlock(ent, trigger.getRelative(piston.getFacing()))) {
                    ent.setVelocity(ent.getVelocity().add(vel));
                }
View Full Code Here

        BlockFace face = SignUtil.getBack(signBlock);
        Block targetDir = signBlock.getRelative(face).getRelative(face);

        double x = targetDir.getX() - signBlock.getX();
        double z = targetDir.getZ() - signBlock.getZ();
        Vector velocity = new Vector(x, vert, z);
        Location shootLoc = new Location(BukkitUtil.toSign(getSign()).getWorld(), targetDir.getX() + 0.5,
                targetDir.getY() + 0.5,
                targetDir.getZ() + 0.5);

        if(!shootLoc.getChunk().isLoaded())
View Full Code Here

TOP

Related Classes of org.bukkit.util.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.