Solved Drops of blocks event?

Discussion in 'Plugin Development' started by Gonmarte, Oct 5, 2015.

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

    Gonmarte

    Hi =)
    i cant find a event that gets the itens that the blocks drops when i break it. I would like to cancel the event and insteaf of drop a iron ore ( if the block is iron ore) it would drop a iron =)
    Any1 can help me?
     
  2. Offline

    teej107

    @Gonmarte Have you tried looking in the Bukkit JavaDocs in BlockBreakEvent?
     
  3. Offline

    Gonmarte

    @teej107 My javadocs doesnt work...
     
  4. Offline

    Zombie_Striker

    Code:
    .getDrops()
     
  5. Offline

    Gonmarte

    @teej107 the only thing i could find was this
    But i dont have any idea of what i should put inside the method removeAll once i never worked with it
    Code:
    event.getBlock().getDrops().removeAll();
    
    
     
  6. Offline

    Zombie_Striker

    @Gonmarte
    Drops.clear();
    Drops.add(That Iron Itemstack)
     
    Last edited: Oct 5, 2015
  7. Offline

    Gonmarte

    @Zombie_Striker So if i want to cancel it to all the blocks i need to get the itemstack of all the blocks??
     
  8. Offline

    Zombie_Striker

    @Gonmarte
    Nothing. It does not take in anything.

    [Edit]
    Replace removeall with .clear()
     
  9. Offline

    Gonmarte

  10. Offline

    Zombie_Striker

    @Gonmarte
    List#clear remove all objects within the collection. List#removeAll removes all of the objects specified.
     
    Gonmarte likes this.
  11. Offline

    Gonmarte

    @Zombie_Striker if i specify the block like this it will remove the drop of the iron block only right?
    Code:
     Block iron_ore = event.getBlock();
               iron_ore.getType().equals(Material.IRON_ORE);
                iron_ore.getDrops().clear();
                iron_ore.getDrops().add(new ItemStack(Material.IRON_INGOT));
    
    
     
  12. Offline

    Zombie_Striker

    This is a boolean, not a void.

    Besides that, that is how it should be.
     
    Gonmarte likes this.
  13. Offline

    tkuiyeager1

    @Gonmarte i think you need to change
    Code:
    iron_ore.getType().equals(Material_IRON_ORE);
    To this
    Code:
    iron_ore.getType() == Material.IRON_ORE;
    Edit:
    i see that this thread is Solved so nvm.
     
  14. Offline

    Gonmarte

  15. Offline

    RoboticPlayer

    When comparing enums, use == as .equals() is null-prone.
     
  16. Offline

    teej107

  17. Offline

    RoboticPlayer

    Gonmarte likes this.
Thread Status:
Not open for further replies.

Share This Page