Package org.bukkit.block

Examples of org.bukkit.block.BlockFace


                case 1:
                    return SignUtil.getLeftBlock(BukkitUtil.toSign(sign).getBlock());
                case 2:
                    return SignUtil.getRightBlock(BukkitUtil.toSign(sign).getBlock());
                case 3:
                    BlockFace face = SignUtil.getBack(BukkitUtil.toSign(sign).getBlock());
                    return BukkitUtil.toSign(sign).getBlock().getRelative(face).getRelative(face);
                default:
                    return null;
            }
        }
View Full Code Here


        item.setAmount(amount);
        if (inv == null) return false;
        HashMap<Integer, ItemStack> over = inv.removeItem(item.clone());
        if (over.isEmpty()) {

            BlockFace back = SignUtil.getBack(BukkitUtil.toSign(getSign()).getBlock());
            Block pipe = getBackBlock().getRelative(back);

            PipeRequestEvent event = new PipeRequestEvent(pipe, new ArrayList<ItemStack>(Arrays.asList(item.clone())), getBackBlock());
            Bukkit.getPluginManager().callEvent(event);

            if(!event.isValid())
                return true;

            for(ItemStack stack : event.getItems())
                BukkitUtil.toSign(getSign()).getWorld().dropItemNaturally(BukkitUtil.toSign(getSign()).getLocation(), stack);
            return true;
        } else {

            BlockFace back = SignUtil.getBack(BukkitUtil.toSign(getSign()).getBlock());
            Block pipe = getBackBlock().getRelative(back);

            PipeRequestEvent event = new PipeRequestEvent(pipe, new ArrayList<ItemStack>(over.values()), getBackBlock());
            Bukkit.getPluginManager().callEvent(event);
View Full Code Here

                Location chairLoc = event.getClickedBlock().getLocation().add(0.5,0,0.5);

                if(chairFacing && event.getClickedBlock().getState().getData() instanceof Directional) {

                    BlockFace direction = ((Directional) event.getClickedBlock().getState().getData()).getFacing();

                    double dx = direction.getModX();
                    double dy = direction.getModY();
                    double dz = direction.getModZ();

                    if (dx != 0) {
                        if (dx < 0)
                            chairLoc.setYaw((float) (1.5 * Math.PI));
                        else
View Full Code Here

    }

    public void shootFire(int n) {

        Block signBlock = BukkitUtil.toSign(getSign()).getBlock();
        BlockFace face = SignUtil.getBack(signBlock);
        Block targetDir = signBlock.getRelative(face).getRelative(face);

        double x = targetDir.getX() - signBlock.getX();
        double z = targetDir.getZ() - signBlock.getZ();
        Location shootLoc = new Location(BukkitUtil.toSign(getSign()).getWorld(), targetDir.getX() + 0.5,targetDir.getY() + 0.5,targetDir.getZ() + 0.5);
View Full Code Here

    private void dispense(CartMechanismBlocks blocks, Inventory inv, CartType type) {

        Location location = BukkitUtil.center(blocks.rail.getLocation());

        if(minecartDispenserLegacy) {
            BlockFace direction =  SignUtil.getFront(blocks.sign).getOppositeFace();
            location = blocks.rail.getRelative(direction).getLocation();
        }

        if(minecartDispenserAntiSpam && EntityUtil.isEntityOfTypeInBlock(location.getBlock(), EntityType.MINECART))
            return;

        if (inv != null) {
            if (type.equals(CartType.Minecart)) {
                if (!inv.contains(Material.MINECART)) return;
                inv.removeItem(new ItemStack(Material.MINECART, 1));
            } else if (type.equals(CartType.StorageMinecart)) {
                if (!inv.contains(Material.STORAGE_MINECART)) return;
                inv.removeItem(new ItemStack(Material.STORAGE_MINECART, 1));
            } else if (type.equals(CartType.PoweredMinecart)) {
                if (!inv.contains(Material.POWERED_MINECART)) return;
                inv.removeItem(new ItemStack(Material.POWERED_MINECART, 1));
            } else if (type.equals(CartType.TNTMinecart)) {
                if (!inv.contains(Material.EXPLOSIVE_MINECART)) return;
                inv.removeItem(new ItemStack(Material.EXPLOSIVE_MINECART, 1));
            } else if (type.equals(CartType.HopperMinecart)) {
                if (!inv.contains(Material.HOPPER_MINECART)) return;
                inv.removeItem(new ItemStack(Material.HOPPER_MINECART, 1));
            }
        }
        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

    @Override
    public boolean doAction(Dispenser dis, ItemStack item, Vector velocity, BlockDispenseEvent event) {

        org.bukkit.material.Dispenser disp = (org.bukkit.material.Dispenser) dis.getData();
        BlockFace face = disp.getFacing();
        Location location = dis.getBlock().getRelative(face).getLocation().add(0.5, 0.5, 0.5);
        TNTPrimed a = (TNTPrimed) dis.getWorld().spawnEntity(location, EntityType.PRIMED_TNT);
        a.setVelocity(velocity.normalize().multiply(2));
        return true;
    }
View Full Code Here

     */
    public static CartMechanismBlocks findByRail(Block rail) throws InvalidMechanismException {

        if (!RailUtil.isTrack(rail.getType()))
            throw new InvalidMechanismException("rail argument must be a rail!");
        BlockFace face = BlockFace.DOWN;

        if (rail.getType() == Material.LADDER)
            face = ((Attachable) rail.getState().getData()).getAttachedFace();
        else if (rail.getType() == Material.VINE) {
            Vine vine = (Vine) rail.getState().getData();
View Full Code Here

    @Override
    public boolean doAction(Dispenser dis, ItemStack item, Vector velocity, BlockDispenseEvent event) {

        org.bukkit.material.Dispenser disp = (org.bukkit.material.Dispenser) dis.getData();
        BlockFace face = disp.getFacing();
        Location location = dis.getBlock().getRelative(face).getLocation().add(0.5, 0.5, 0.5);
        Arrow a = dis.getWorld().spawnArrow(location, velocity, 1.0f, 0.0f);
        a.setFireTicks(5000);
        return true;
    }
View Full Code Here

        // pick the track block to modify and the curve to give it.
        // perhaps oddly, it's the sign facing that determines the concepts of left and right, and not the track.
        // this is required since there's not a north track and a south track; just a north-south track type.
        byte trackData;
        BlockFace next = SignUtil.getFacing(event.getBlocks().sign);
        switch (next) {
            case SOUTH:
                switch (dir) {
                    case LEFT:
                        trackData = 9;
View Full Code Here

    }

    public static ChangedSign getSignOnPiston(Block block) {

        BlockState state = block.getState();
        BlockFace facing = BlockFace.SELF;
        if(state.getData() instanceof Directional)
            facing = ((Directional) state.getData()).getFacing();

        for(BlockFace face : LocationUtil.getDirectFaces()) {
View Full Code Here

TOP

Related Classes of org.bukkit.block.BlockFace

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.