Changing default armor values

Discussion in 'Plugin Development' started by SocomX1, Oct 25, 2014.

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

    SocomX1

    I've been trying to use reflection to edit the default armor values of Minecraft. After looking at NMS, it would seem the only way to do this would be to edit the array inside EnumArmorMaterial.java that represents 4 integers. These 4 integers correspond to the armor value of each piece of armor; the first being the helmet, the last being the boots.

    What I've done is the following:

    Code:java
    1. public void onLoad() {
    2. try {
    3. Field armorValuesField = EnumArmorMaterial.class.getDeclaredField("g");
    4. armorValuesField.setAccessible(true);
    5.  
    6. int[] newArmorValues = new int[]{0, 0, 0, 0};
    7.  
    8. armorValuesField.set(EnumArmorMaterial.DIAMOND, newArmorValues);
    9.  
    10. } catch (NoSuchFieldException e) {
    11. e.printStackTrace();
    12. } catch (IllegalAccessException e) {
    13. e.printStackTrace();
    14. }
    15. }


    The above code will change the value of the integers inside the array for diamond armor from 3, 8, 6, 3, to 0, 0, 0, 0. I have confirmed that these values are changed by this code by using debug messages to print out the values in a separate method, however damage reduction remains the same on diamond armor. If anyone has any ideas, they would be greatly appreciated.
     
Thread Status:
Not open for further replies.

Share This Page