#(jakobwlf21) Issue with NPC UUID

9 messages · Page 1 of 1 (latest)

neat palm
#

I am trying to detect when an npc is being attacked. For this I have a listener:

    @EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
        LOTM.getLogUtil().debug(event.getEntity().getUniqueId() + " Entity UUID --- " + getUuid() + " NPC UUID");

        if(event.getEntity().getUniqueId() != getUuid()) return;

        LOTM.getLogUtil().debug("NPC attacked");

And this is the getUUID function:

    @Override
    public UUID getUuid() {
        this.uuid = npc.getUniqueId();
        return uuid;
    }

However when hitting the npc, the UUIDS dont match and there will be a difference in one single character:

[DEBUG] b2571c87-a511-23b4-9cc5-40089150f96d Entity UUID --- b2571c87-a511-43b4-9cc5-40089150f96d NPC UUID

I know that I could simply comnpare the entities but I'm still curious to know what's wrong here

lone monolithBOT
#

(jakobwlf21) Issue with NPC UUID

lone monolithBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

distant fractal
#

@neat palm you can use getMinecraftUniqueId() instead

#

if you want them to match

steady yarrowBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@neat palm