Help me with .remove and Orange Wool

Discussion in 'Plugin Development' started by 200dvd, Jul 31, 2012.

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

    200dvd

    Hello Com,

    I have a Problem with remove Orange Wool:

    Code:
    Inventory inv = p.getInventory();
    inv.remove(new ItemStack(Material.WOOL, 20, (short) 0, (byte) 1));
     
    
    It doesn't work.
    Please help me and Sorry 4 my bad English... THX
     
  2. Offline

    sd5

    Can you remove wool with another colour? maybe try new ItemStack() without the third parameter...
     
  3. Offline

    200dvd

    yahhhhhh i have fix it! THX
    Code:
    inv.removeItem(new ItemStack[] { new ItemStack(35, 10, (short) 0, (byte) 1) });
    no i have a problem with .contains
    i have try it without .contains but it don't work... :(

    Code:
    public boolean canAffordITEM(Player p, int amount, int id , int dur) throws Exception
    {
       
     
        ItemStack item =  new ItemStack(id, am, (short) 0, (byte) dur) ;
       
     
       
          for(ItemStack stack : p.getInventory().getContents())
     
              if(stack.getType() == item.getType()){
                   
                  switch(item.getTypeId())
                  {
                      case 5:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                      case 6:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                      case 17:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                   
                      case 18:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 24:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 31:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 35:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 43:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 44:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                      case 98:
                            if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 97:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 125:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                      case 126:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 351:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                       
                      case 383:
                          if(stack.getData().getData() == item.getData().getData()){
                             
                                return true;
                            }
                             
                      default:
                       
                          return true;
                         
                  }
             
               
                 
                 
                 
                }
           
           
             
         
       
       
          return false;
         
     
    }
    its always true

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  4. Offline

    nala3

    because you only have true?...
     
  5. Offline

    sd5

    :D:D:D
     
Thread Status:
Not open for further replies.

Share This Page