NMS Setting MaxHealth -- FIXED

Discussion in 'Spigot Plugin Development' started by TcFoxy, Jun 12, 2015.

  1. This is what I've been using to set an entity's max health:
    Code (Text):
    @Override
        public void initAttributes()
          {
            super.initAttributes();
            getAttributeInstance(GenericAttributes.maxHealth).setValue(700.0D);//Health
            getAttributeInstance(GenericAttributes.e).setValue(6.0D);//Damage (sorta? (damage is modified in the pathfinding goal))
            getAttributeInstance(GenericAttributes.d).setValue(0.0D);//mov speed
            getAttributeInstance(GenericAttributes.b).setValue(10.0D);//Sight
         
          }
    And i know for a FACT that this works for ONE of my entities (Iron Golem), but not for the other. Here are both methods side by side.


    IRON GOLEM:
    Code (Text):
    protected void initAttributes(){
            super.initAttributes();
            getAttributeInstance(GenericAttributes.maxHealth).setValue(300.0D);
            getAttributeInstance(GenericAttributes.d).setValue(0.0D);//movement speed
            getAttributeInstance(GenericAttributes.c).setValue(500.0D);//KnockBack resist
            getAttributeInstance(GenericAttributes.b).setValue(7.0D);//sight
          }
    GUARDIAN:
    Code (Text):
        public void initAttributes(){
            super.initAttributes();
            getAttributeInstance(GenericAttributes.maxHealth).setValue(700.0D);//Health
            getAttributeInstance(GenericAttributes.e).setValue(6.0D);//Damage (sorta? (damage is modified in the pathfinding goal))
            getAttributeInstance(GenericAttributes.d).setValue(0.0D);//mov speed
            getAttributeInstance(GenericAttributes.b).setValue(10.0D);//Sight
          }
    The weird thing, is that my Guardian DOES seem to spawn with 700 health, but whenever an entity damages him, his health goes back to default 80 then continues decreasing as usual... WTF??

    Any ideas?
     
  2. Entity.setMaxHealth(...)
     
    • Winner Winner x 1
  3. That's not what Im asking. My question is why is one of my NMS methods working and the other not working?

    I am aware of that method but it shouldn't be necessary if my NMS was working...
     
  4. graywolf336

    Supporter

    My question would be why go with NMS methods when you can use something that won't break every update...
     
  5. Well im already modifying the guardian a LOT with NMS so why not do all the modifications in one place? plus somethings can ONLY be done by NMS. Like changing his pathfinding goals
     
  6. Watever, If i convert my NMS entity to a Living Creature i can set his health so thats just what Ill do