Dropping ItemStack

Discussion in 'Plugin Development' started by xSummit, Aug 19, 2013.

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

    xSummit

    So I'm trying to drop a player's inventory in front of them and when I try to drop the player's inventory it gives me an illegal argument exception.

    Code:
    Code:java
    1. for(ItemStack stack : p.getInventory().getContents()){
    2.  
    3. p.getWorld().dropItem(new Location(p.getWorld(), p.getLocation().getX() - 1, p.getLocation().getY(), p.getLocation().getZ()), stack);
    4.  
    5. }


    Question in a nutshell, how can I drop an array of items? ItemStack.
     
  2. Offline

    Mattredsox

    try this code:

    Code:java
    1. for (ItemStack itemStack : player.getInventory().getContents()) {
    2. if (itemStack != null) {
    3. player.getWorld().dropItemNaturally(player.getLocation(), itemStack );
    4. player.getInventory().remove(itemStack );
    5. }
    6. }
     
  3. Offline

    xSummit

    That worked. Thanks.
     
Thread Status:
Not open for further replies.

Share This Page