Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7771

Material.getDefaultAttributes always returns an empty map since MC 1.20.6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Windows 10

      Java 21

    • CraftBukkit version 4217-Spigot-146439e-68603b1 (MC: 1.21)
    • Yes

      The getDefaultAttributeModifiers method of the Material enum always returns an empty map on MC 1.21 (and on MC 1.20.6), but I would expect it to return a non-empty map for materials such as iron swords.

      I created a dummy plug-in that has the following code in its onEnable method:

      System.out.println("default attributes of iron sword are " + Material.IRON_SWORD.getDefaultAttributeModifiers(EquipmentSlot.HAND)); 

      On MC 1.21 and MC 1.20.6, the plug-in prints:

      default attributes of iron sword are {} 

      which I believe is wrong. On MC 1.20.4, it prints this instead:

      default attributes of iron sword are {GENERIC_ATTACK_DAMAGE=[AttributeModifier{uuid=cb3f55d3-645c-4f38-a497-9c13a33db5cf, name=Weapon modifier, operation=ADD_NUMBER, amount=5.0, slot=HAND}], GENERIC_ATTACK_SPEED=[AttributeModifier{uuid=fa233e1c-4180-4865-b01b-bcce9785aca3, name=Weapon modifier, operation=ADD_NUMBER, amount=-2.4000000953674316, slot=HAND}]} 

      which I believe is the desired behavior. Running the plug-in (but compiled for Java 17) on MC 1.18.2 and 1.19.4 also gives this correct behavior.

       

      Note 1: this bug happens on more materials than just iron swords. The iron sword is simply the example that I chose.

      Note 2: I guess Major is the right priority because it breaks functionality, doesn't cause crashes, and has no work-around. The only work-around that I know relies on NMS and only works in MC 1.20.4 and earlier...

            Unassigned Unassigned
            knokko Tim van de Klundert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: