Endermites......

Discussion in 'Plugin Help/Development/Requests' started by jolbol1, Jan 7, 2015.

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

    jolbol1

    Hey guys, I have an event that blocks enderpearls being used, but they are technically thrown, the player is just never teleported. I need to work out how to stop the endermite spawning however, Ive tried storing the location and seeing if the endermite spawns in the same location however they spread out so that doesn't work. Anyone have a way to stop the Endermite?
     
  2. Offline

    1Rogue

    Why not just cancel throwing the enderpearls?
     
  3. Offline

    Danteland

    check for nearby entities within a 10 block radius and if the entity is instanceof endermite then remove the entity
     
  4. Offline

    jolbol1

    How so? I tried player interact event, Checking if the hand was an enderpearl, but it wasn't working.
     
  5. Offline

    1Rogue

    I do see a PlayerUnleashEntityEvent but I don't actually know if it's relevant (never had to use and the documentation is shoddy).

    What is your code that you tried to use for cancelling? (Both the interact and the cancelling upon impact)
     
  6. Offline

    jolbol1

    This is my code that cancels the tp but endermites spawn.
    Code:
      @EventHandler
        public void onTpEvent(PlayerTeleportEvent e) {
            if (e.getPlayer().hasPermission("nifl.enderpearl")) return;
            if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)) {
                if (nifl.config.getString("EnderPearl").equalsIgnoreCase("true")) {
               
    
                 
                        e.setCancelled(true);
                        nifl.locations.put(e.getPlayer().getName(), e.getPlayer().getLocation().getBlock());
                        nifl.cantEnderHere(e.getPlayer());
                        e.getPlayer().getInventory().addItem(new ItemStack(Material.ENDER_PEARL, 1));
    
                    }
                }
            }
    
        }
    And this was the interact
    Code:
      if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                if(e.getPlayer().getItemInHand().equals(Material.ENDER_PEARL)) {
                    if(nifl.config.getString("EnderPearl").equalsIgnoreCase("true")) {
                       
                           
                
    
    
                        e.setCancelled(true);
                        nifl.cantEnderHere(e.getPlayer());
    
                    }
                }
     
  7. Offline

    1Rogue

    Oh you were cancelling the teleport, you should try cancelling the impact instead using ProjectileHitEvent, or just cancel launching altogether with ProjectileLaunchEvent.
     
  8. Offline

    jolbol1

    Anyway to get the player that launched the projectile?

    Scrap that read the docs, getShooter.
     
    Last edited by a moderator: Jan 8, 2015
    ChipDev and 1Rogue like this.
  9. Offline

    Permeer

    Why not use CreatureSpawnEvent and if is a endermite cancel the event?
     
  10. Offline

    Skionz

    ChipDev likes this.
  11. Offline

    Permeer

    omg , I did not know that
     
  12. Offline

    teej107

  13. Offline

    jolbol1

    ProjectileLaunchEvent worked for me. Thanks guys.
     
Thread Status:
Not open for further replies.

Share This Page