Skip to content

Commit 9b50fca

Browse files
committed
fix: change getting of npcs to uuid for walk and check immovable state
1 parent 9001a13 commit 9b50fca

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/main/kotlin/cc/modlabs/kpaper/npc/NPCImpl.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class NPCImpl(
211211
}
212212

213213
override fun walkTo(location: Location): Boolean {
214-
val entity = getMannequin() as? LivingEntity ?: return false
214+
val entity = getEntityByUUID() ?: return false
215215

216216
// Clear existing path
217217
pathQueue.clear()
@@ -260,7 +260,7 @@ class NPCImpl(
260260

261261
override fun walkPath(locations: List<Location>): Boolean {
262262
if (locations.isEmpty()) return false
263-
val entity = getMannequin() as? LivingEntity ?: return false
263+
val entity = getEntityByUUID() ?: return false
264264

265265
// Clear existing path
266266
pathQueue.clear()
@@ -324,8 +324,8 @@ class NPCImpl(
324324

325325
override fun startWalking(): Boolean {
326326
logDebug("[NPC] startWalking called")
327-
val entity = getMannequin() as? LivingEntity ?: run {
328-
logDebug("[NPC] startWalking failed: cannot get LivingEntity")
327+
val entity = getEntityByUUID() ?: run {
328+
logDebug("[NPC] startWalking failed: cannot get LivingEntity (UUID: $npcUUID)")
329329
return false
330330
}
331331

@@ -582,7 +582,7 @@ class NPCImpl(
582582

583583
override fun startPatrolling(locations: List<Location>): Boolean {
584584
if (locations.isEmpty()) return false
585-
val entity = getMannequin() as? LivingEntity ?: return false
585+
val entity = getEntityByUUID() ?: return false
586586

587587
// Stop any existing walking/patrolling
588588
stopWalking()
@@ -642,8 +642,8 @@ class NPCImpl(
642642
logDebug("[NPC] followEntity failed: entity is invalid")
643643
return false
644644
}
645-
val npcEntity = getMannequin() as? LivingEntity ?: run {
646-
logDebug("[NPC] followEntity failed: cannot get LivingEntity")
645+
val npcEntity = getEntityByUUID() ?: run {
646+
logDebug("[NPC] followEntity failed: cannot get LivingEntity (UUID: $npcUUID)")
647647
return false
648648
}
649649

@@ -723,8 +723,8 @@ class NPCImpl(
723723

724724
override fun followNearbyPlayers(range: Double, followDistance: Double): Boolean {
725725
logDebug("[NPC] followNearbyPlayers called: range=$range, followDistance=$followDistance")
726-
val npcEntity = getMannequin() as? LivingEntity ?: run {
727-
logDebug("[NPC] followNearbyPlayers failed: cannot get LivingEntity")
726+
val npcEntity = getEntityByUUID() ?: run {
727+
logDebug("[NPC] followNearbyPlayers failed: cannot get LivingEntity (UUID: $npcUUID)")
728728
return false
729729
}
730730

0 commit comments

Comments
 (0)