[SPIGOT-7890] attributeModifier.getUniqueId() doesn't match the UUID passed to its constructor Created: 30/Aug/24  Updated: 25/Dec/24  Resolved: 30/Aug/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Tim van de Klundert Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Attachments: File attributes.jar    
Version: CraftBukkit version 4302-Spigot-a759b62-63f9166 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

When I pass a UUID to the constructor of AttributeModifier, I would expect the getUniqueId() method of the newly created attribute modifier to return that same UUID. However, this seems to return a completely different UUID.

 

The problem is demonstrated by the following code:

@Override
public void onEnable() {
    UUID exampleID = UUID.fromString("cdbfab97-f3d1-4b8e-b320-a66c3f0abea5");
    AttributeModifier testModifier = new AttributeModifier(
          exampleID, "generic.attackDamage", 1.0, AttributeModifier.Operation.ADD_NUMBER
    );
    if (exampleID.equals(testModifier.getUniqueId())) Bukkit.broadcastMessage("It works, great job!");
    else throw new RuntimeException("Expected " + exampleID + ", but got " + testModifier.getUniqueId());
} 

Running this code on the latest Spigot build results in

RuntimeException: Expected cdbfab97-f3d1-4b8e-b320-a66c3f0abea5, but got 50e9750c-cc25-3624-acd0-f11b2b383591 

I believe the correct output would be "It works, great job!".

 

For reproduction convenience, I added a pre-built version of this 'plug-in' in the attachments.



 Comments   
Comment by md_5 [ 30/Aug/24 ]

I've added further shimming, but would still encourage updating

Comment by Tim van de Klundert [ 30/Aug/24 ]

Yes, I did recently notice this (it took me a while to notice because I usually compile against older versions, where it wasn't deprecated yet).

If this 'bug' were fixed, I would not need to rewrite my attribute tracking system, which would make my life easy. Also, it might prevent other old plug-ins from unexpectedly breaking when they are used in a newer minecraft version. (The API is the same as in older versions, but the behavior is different, which can easily lead to unexpected problems.)

Since attribute UUIDs are deprecated, you could argue that this is not really a bug, and that plug-ins should simply update their stuff. I guess this is up to you. I would like to know your answer, whatever it may be.

Comment by md_5 [ 30/Aug/24 ]

You are aware UUIDs for attributes are deprecated and have in fact been removed by Vanilla?

Generated at Sat Dec 13 15:18:01 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.