Solved Setting Player Armor Level

Discussion in 'Spigot Plugin Development' started by Leniency, Jan 7, 2017.

Thread Status:
Not open for further replies.
  1. I am trying to make it so that when a player puts a block on their head it adds +4 armor points to the player. I know there is a way to modify item attributes to do this, but I do not know how to do this in 1.8. So instead I went with the approach of directly modifying the player's armor attribute (http://minecraft.gamepedia.com/Attribute#Attributes_available_on_all_living_entities Go to the bottom where it says 'generic.armor'). In order to set the base value of the attribute, you have to have an instance of the attribute, however I do not know how to get this instance.

    Here is my current code:
    Code (Text):
    ((EntityPlayer) data.getPlayer()).getAttributeInstance(null)
                    .setValue(((EntityPlayer) data.getPlayer()).getAttributeInstance(null).getValue() + 4.0);
    Where null should be the instance of the 'generic.armor' attribute.

    If someone could tell me how to either:
    a) Add armor point attributes to an item
    b) Get an instance of the attribute in order to set the base value
    This would be much appreciated.

    NOTE: This is in 1.8.
     
    • Creative Creative x 1
Thread Status:
Not open for further replies.