Partially restore uuid version reset code

This commit is contained in:
fullwall 2023-04-16 02:21:30 +08:00
parent 07d2c970d0
commit 5bb73b3a95
4 changed files with 21 additions and 6 deletions

View File

@ -154,11 +154,23 @@ public class CitizensNPCRegistry implements NPCRegistry {
@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;

View File

@ -99,7 +99,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
}
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();

View File

@ -7,7 +7,6 @@ import java.util.function.Function;
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;
@ -330,8 +329,7 @@ public class CitizensNavigator implements Navigator, Runnable {
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);
@ -351,8 +349,7 @@ public class CitizensNavigator implements Navigator, Runnable {
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);

View File

@ -32,6 +32,12 @@ public class HumanController extends AbstractEntityController {
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;