Removing an entity (STILL NEED HELP!)

Discussion in 'Plugin Development' started by Lupus, Apr 12, 2012.

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

    Lupus

    If i wanted to make an event to remove an entity like ThrownExpBottle, how would I do that?
     
  2. Offline

    nisovin

    I'm not entirely sure what you're asking here. You can call the remove() method on an entity to remove it.
     
  3. Offline

    Lupus

    I honestly dont know how to do this, so could i ask you? I want it to be so that every time an EXP bottle is thrown, the entity (ThrownExpBottle) is removed. Can you do it/?
     
  4. Offline

    Orcem12

    Maybe the event: EntityInteractEvent. I don't think that's right but I think you can test for right click event using PlayerInteractEvent. Try playing around with that for a while.
     
  5. Offline

    Lupus

    but where and how do i put the remove(). could you just set up the code for me?
     
  6. Offline

    Orcem12

    I think it's something like this.
    Code:
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event){
            Player player = event.getPlayer();
            if(event.getAction() == Action.RIGHT_CLICK_AIR){
               
            }
        }
    I don't think it would be the remove() but rather a cancel of the event... just check to see what material is being used. In this case a potion, and if so, cancel the event.
     
  7. Offline

    Lupus

    so
    Code:
    if (if (event.getBlock().getType() == Material.EXP_POTION){
    event.setCancelled(true);
    
    Correct?
     
  8. Offline

    Orcem12

    Try it. Trial and error is the best way to learn.
     
  9. Offline

    Duckdoom5

    no, use this

    if (event.getPlayer().getItemInHand().getType().equals(Material.EXP_POTION)){
    event.setCancelled(true);
    }
     
  10. Offline

    VeryBIgCorp

    You don't need to use .equals to compare enums, but otherwise it's correct.
     
Thread Status:
Not open for further replies.

Share This Page