Skip to content

Commit

Permalink
Add new uuid metho
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jun 18, 2023
1 parent f4bdfc4 commit 1b4be45
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/net/citizensnpcs/api/npc/AbstractNPC.java
Expand Up @@ -216,6 +216,20 @@ public boolean equals(Object obj) {
return true;
}

@Override
public UUID getMinecraftUniqueId() {
if (getEntityType() == EntityType.PLAYER) {
UUID uuid = getUniqueId();
if (uuid.version() == 4) { // set version to 2
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000004000L;
msb |= 0x0000000000002000L;
return new UUID(msb, uuid.getLeastSignificantBits());
}
}
return getUniqueId();
}

@Override
public GoalController getDefaultGoalController() {
return goalController;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/citizensnpcs/api/npc/NPC.java
Expand Up @@ -113,6 +113,15 @@ public interface NPC extends Agent, Cloneable {
*/
public BlockBreaker getBlockBreaker(Block targetBlock, BlockBreakerConfiguration config);

/**
* For certain mob types (currently, Players) it is beneficial to change the UUID slightly to signal to the client
* that the mob is an NPC not a real mob. This will return {@link #getUniqueId()} with the necessary changes for the
* current mob type.
*
* @return The client unique ID.
*/
public UUID getMinecraftUniqueId();

/**
* Gets the default {@link GoalController} of this NPC.
*
Expand Down

0 comments on commit 1b4be45

Please sign in to comment.