NMS: Stopping all damage

Discussion in 'Plugin Development' started by BurnerDiamond, May 6, 2015.

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

    BurnerDiamond

    Title says it all...
     
  2. @BurnerDiamond Why do you want to use NMS? Just listen to PlayerDamageEvent and cancel it.
     
    BurnerDiamond likes this.
  3. Offline

    BurnerDiamond

    It was mostly because the entity I want to cancel the damage to is a custom chicken.

    I could always use the event but isn't there a way with NMS?
     
  4. Offline

    timtower Administrator Administrator Moderator

    @BurnerDiamond There probably is, but why do you want to do that? The event is just the easy method of the NMS.
    Don't over-complicate things when you don't need to.
     
    BurnerDiamond likes this.
  5. Offline

    BurnerDiamond

    I guess you're right. I was trying to keep all of it compact, but hey never mind.

    Thanks for your help!
     
  6. Offline

    Konato_K

    @BurnerDiamond The EntityLiving class has a damageEntity(DamageSource, float) method, if you override it and return false the damage should not be applied.

    There is also as isInvulnerable method (which is called by damageEntity method) which returns a boolean of whether the entity is invulnerable or not.

    This method returns the value from the invulnerable field, which is private, either way overriding damageEntity or isInvulnerable should work and there is no need for this.

    However, take in consideration that any of these solutions will make the entity totally invulnerable and EntityDamageEvents won't be fired if this entity is hit by something, so, if you want to run logic by hitting this custom entity (but just don't want it to die) this is NOT the way to go.
     
Thread Status:
Not open for further replies.

Share This Page