How to make a mob invincible?

Discussion in 'Plugin Development' started by super292, Oct 26, 2013.

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

    super292

    Does anyone know the code used to make a mob invincible? I already know how to spawn mobs, I just need them to not take damage.
     
  2. Offline

    RealDope

    Code:JAVA
    1.  
    2. @EventHandler
    3. public void onEntityDamage(EntityDamageByEntityEvent event) {
    4. event.setCancelled(true);
    5. }
    6.  

    Obviously you need to add some checks to make sure the entity is the mob you want invincible.
     
  3. Offline

    DarkBladee12

    super292 You'd probably have to save the UUID of the mob in a variable and check in the EntityDamageEvent if the damaged mob's UUID equals the saved one and then cancel it!
     
  4. Offline

    super292

Thread Status:
Not open for further replies.

Share This Page