Skip to content

Commit

Permalink
Partially restore uuid version reset code
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 15, 2023
1 parent 07d2c97 commit 5bb73b3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
12 changes: 12 additions & 0 deletions main/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,23 @@ public NPC getById(int id) {

@Override
public NPC getByUniqueId(UUID uuid) {
if (uuid.version() == 2) {
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000002000L;
msb |= 0x0000000000004000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
return uniqueNPCs.get(uuid);
}

@Override
public NPC getByUniqueIdGlobal(UUID uuid) {
if (uuid.version() == 2) {
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000002000L;
msb |= 0x0000000000004000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
NPC npc = getByUniqueId(uuid);
if (npc != null)
return npc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean update() {
}
Location loc = npc.getEntity().getLocation(NPC_LOCATION);
/* Proper door movement - gets stuck on corners at times
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
if (MinecraftBlockExaminer.isDoor(block.getType())) {
Door door = (Door) block.getState().getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
Expand Down Expand Up @@ -330,8 +329,7 @@ public void setTarget(Iterable<Vector> path) {
setTarget(params -> {
if (npc.isFlyable()) {
return new FlyingAStarNavigationStrategy(npc, path, params);
} else if (params.useNewPathfinder()
|| (!(npc.getEntity() instanceof LivingEntity) && !(npc.getEntity() instanceof ArmorStand))) {
} else if (params.useNewPathfinder() || !(npc.getEntity() instanceof LivingEntity)) {
return new AStarNavigationStrategy(npc, path, params);
} else {
return new MCNavigationStrategy(npc, path, params);
Expand All @@ -351,8 +349,7 @@ public void setTarget(Location targetIn) {
setTarget(params -> {
if (npc.isFlyable()) {
return new FlyingAStarNavigationStrategy(npc, target, params);
} else if (params.useNewPathfinder()
|| (!(npc.getEntity() instanceof LivingEntity) && !(npc.getEntity() instanceof ArmorStand))) {
} else if (params.useNewPathfinder() || !(npc.getEntity() instanceof LivingEntity)) {
return new AStarNavigationStrategy(npc, target, params);
} else {
return new MCNavigationStrategy(npc, target, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ protected Entity createEntity(final Location at, final NPC npc) {
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // set version to 2
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000004000L;
msb |= 0x0000000000002000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
String teamName = Util.getTeamName(uuid);
if (npc.requiresNameHologram()) {
name = teamName;
Expand Down

0 comments on commit 5bb73b3

Please sign in to comment.