Inventory Moving Items - Bukkit

Discussion in 'Plugin Development' started by CuteCubed, Feb 10, 2016.

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

    CuteCubed

    Hey Guys, I need help making my Bukkit plugin . I wan't a moving Item in the Inventory .
    Like a scheduler which is moving the item when a compass is clicked -->
    The Items start moving from the right side to the left . :D
    Is it possible to do that ? [creeper]
    --> rewinside.tv when you click on the golden apple a menu apears with items
    The items should move.
    EXAMPLE:

    Code:
        @EventHandler
        public void interact(PlayerInteractEvent e) {
            Action action = e.getAction();
            final Player p = e.getPlayer();
            if (action == Action.RIGHT_CLICK_AIR | action == Action.RIGHT_CLICK_BLOCK)
                if (e.getMaterial() == Material.COMPASS) {
                   
                    p.playSound(p.getLocation(), Sound.CHEST_OPEN, 1F, 1F);
                }
           
       
       
       
       
       
       
       
       
       
       
    //How can i make the item move??
       
       
           
            ItemStack i= new ItemStack(Material.SLIME_BALL, 1);
             ItemStack a= new ItemStack(Material.BOOK_AND_QUILL, 1);
             ItemStack d= new ItemStack(Material.BOW, 1);
       
    //How can i make the item move??
    
            tp.setItem(25, a);
            tp.setItem(26, d);
    tp.setItem(26, i);
       
           
        if (action == Action.RIGHT_CLICK_AIR | action == Action.RIGHT_CLICK_BLOCK)
                if (e.getMaterial() == Material.COMPASS) {
    
                    p.openInventory(tp);
                   
                    p.playSound(p.getLocation(), Sound.CAT_MEOW, 2F, 2F);
                }
        }
    
     
  2. Offline

    CoolDude53

    @CuteCubed you can use a repeating task that keeps moving the item in whatever pattern you want it to move for as long as you want it to move. Just be sure to cancel the task once the inventory is closed or when you want the item to stop moving.
     
  3. Offline

    RoflFrankoc

    after setting the new Location do this:
    Code:
    player.updateInventory();
    
    An example:
    Code:
    public void move(Inventory inv, int newLoc, ItemStack s, Player p){
          inv.setItem(newLoc, s);
          p.updateInventory();
    }
    
    That should do the job!
     
Thread Status:
Not open for further replies.

Share This Page