Getting all Slots of Inventory

Discussion in 'Plugin Development' started by Ancetras, Dec 4, 2011.

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

    Ancetras

    Hi,
    I have a problem.
    I'm creating a plugin which if you have a determinate item in your inventory slot bar you can do something.
    I need to write a code which allow me to see in all the slots not just one. But I can do this with just one slot ( ItemStack item = player.getInventory().getItem(1); ).

    Can someone help me? T_T
    Thanks!
     
  2. Offline

    wwsean08

    you could just loop thru the slots, that would probably be the easiest way
     
  3. Offline

    Ancetras

    for example? o,o
     
  4. Offline

    wwsean08

    Code:
    boolean hasItem = false;
    for(int i=0;i<10;i++){
        ItemStack item = player.getInventory().getItem(i);
        if(//items what your looking for){
            hasItem = true;
            break;
        }
    }
    if(hasItem){
        //do stuff
    }
     
  5. Offline

    Ancetras

    This works :3
    Thanks!
     
  6. Offline

    wwsean08

    no problem
     
Thread Status:
Not open for further replies.

Share This Page