help with my first plugin...

Discussion in 'Bukkit Help' started by MasterCtrl, Jan 24, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    MasterCtrl

    so ive been trying to write my first plugin today and i seem to have hit a roadblock,
    basically im trying to implement something like degreifstick only it takes out a line of blocks (inspired by blastpick from hmod) anyways i have this as my onrightclick event but it doesnt seem to work... does anyone who has had more than a days experience see a problem?
    Code:
        public void onBlockRightClick(BlockRightClickEvent event){
            System.out.println("OMFG IT WORKED!!");
            int length = plugin.getLength();
            if(event.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
                Player player = event.getPlayer();
                Block[] blocks = new Block[length];
                blocks[0] = event.getBlock();
                World world = blocks[0].getWorld();
                Vector playerLocation = player.getLocation().toVector();
                Vector blockLocation = blocks[0].getLocation().toVector();
                double dx = blockLocation.getX() - playerLocation.getX();
                double dy = blockLocation.getY() - playerLocation.getY();
                if(Math.abs(dx) > Math.abs(dy)){
                    for(int i = 0; i < length - 1 ; i++ ){
                        blockLocation = blocks[i].getLocation().toVector();
                        blocks[i+1] =  world.getBlockAt((int)(blockLocation.getX() + Math.signum(dx)),  (int)(blockLocation.getY()), (int)(blockLocation.getZ()));
                    }
                }else{
                    for(int i = 0; i < length - 1 ; i++ ){
                        blockLocation = blocks[i].getLocation().toVector();
                        blocks[i+1] =  world.getBlockAt((int)(blockLocation.getX()), (int)(blockLocation.getY()  + Math.signum(dy)), (int)(blockLocation.getZ()));
                    }
                }
                for(int i = 0; i< length; i++){
                    blocks[i].setType(Material.AIR);
                }
            }
        }
    Thanks in advance,
    MasterCtrl

    DW sorted it...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 6, 2016
Thread Status:
Not open for further replies.

Share This Page