Solved Clear an Area, prevent itemdrops

Discussion in 'Plugin Development' started by Koningpeter, Apr 1, 2016.

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

    Koningpeter

    Hi all, I want to delete an area, but when I change or remove a block, blocks like chests and grass drop their items.
    Anyone knows how to disable itemdrops in this area?
     
  2. Offline

    CraftCreeper6

    @Koningpeter
    Get the destroyed block
    Cancel the event
    Set the block to air

    Or you can remove the item from the droplist but I can't remember off the top of my head how to do that.
     
  3. Offline

    Koningpeter

  4. Offline

    mine-care

    Ok, specify the area you want to delete and then loop (with a tripple nested loop) through all the blocks between the two diagonal points you got, and as you remove the blocks in each loop pass, then check if it is a chest. If it is, drop its stuff and break it as you do for the rest..
     
  5. Offline

    Koningpeter

    yea, but how can I set the drops of the chest to null?
     
  6. Offline

    CraftCreeper6

    @Koningpeter
    Event, there is an event for item drops which you can use to set the drop list to air.
     
  7. Offline

    Koningpeter

    @CraftCreeper6
    Its faster to do something like:
    Location l = new Location(p.getWorld(), x, y, z);
    l.getBlock().getDrops().clear;
    It doesn't work on chests....
     
  8. Offline

    CraftCreeper6

    @Koningpeter
    If it doesn't work on chests, why are you saying it's a faster way?
     
  9. Offline

    Koningpeter

    because it works fine for blocks like grass or flowers
     
  10. Offline

    CraftCreeper6

    @Koningpeter
    Well use that
    Why not clear the chests inventory before it's broken?
     
    Koningpeter likes this.
  11. Offline

    Koningpeter

    yes, Thanks!!
     
Thread Status:
Not open for further replies.

Share This Page