Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved How make entity invulnerable

Comments in 'Plugin Development' started by Kvetinac97, Jun 29, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    What should I add to entity to make it invulnerable? I made some entities but when I hit them, they're damaged. Setting 2000 HPs isn't good, because entity can be damaged and after long time, it's killed
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    *human entity
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    EntityDamageEvent, where
    PHP:
    $entityhit instanceof $entity
    and then
    PHP:
    $event->setCancelled(true);
    Jon likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    DO YOU AT ALL EVEN KNOW WHAT INSTANCEOF MEANS?

    instanceof only checks the entity type and doesn't let you compare between variables. If you want to compare variables, use ===
    TigerHix likes this.
  5. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Try this:

    public function onEntityInteract(EntityDamageEvent $ev) {
    $taker = $ev->getEntity();
    if (!($taker instanceof Player)){$taker->getSaveId();}
    if(($takerSaveId == "Your entity type here, E.G Villager, Human or Pig")){ $ev->setCancelled(); }
    }
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I mean this:
    PHP:
    $entityhit $event->getEntity();

    if (
    $entityhit instanceof Zombie){
    $event->setCancelled(true);
    }
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And how do you know if it is a natural zombie or one he spawned? Moreover, he said human entity.
    Undefined variable $takerSaveId
    TigerHix and jojoe77777 like this.

Share This Page

Advertisement