#(masecla22) Issues with Citizens API

64 messages · Page 1 of 1 (latest)

stray matrix
#

Hey!

I'm having a couple troubles with the Citizens API. Specifically, when the NPC gets stuck, I added a .stuckAction on the NPC, in which I cancel the navigation and then teleport the NPC. But for some reason, the stuckAction method gets called multiple times and also doesn't teleport the NPC! Any ideas?

rustic sirenBOT
#

(masecla22) Issues with Citizens API

rustic sirenBOT
#

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.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

stray matrix
#

This here is my stuck action

#

validateSpawnLocation finds a correct spawn location

#

moveTo teleports the NPC

#

But I end up with this

orchid orchid
#

you need to return true if you want to continue navigation

#

cancelNavigation shouldn't be called again

#

@stray matrix

stray matrix
#

I've tried returning true,

#

I've tried returning false

#

I've tried not calling cancelNavigation

#

If I return true, I get this NPE

#

And if i return true without cancelling it, it still hangs in a loop

orchid orchid
#

@stray matrix what's the rest of the code look like? TeleportStuckAction (the default one) is similar, and has no issue so must be somewhere else

stray matrix
#

So the spawn location thing

#

Is this,

#

I'm using it to slightly vary the spawn location everytime the NPC gets stuck,

#

Since no NPE's are showing up, it seems like the location is not null

orchid orchid
#

I mean the setTarget call

stray matrix
#

I never set navigation,

#

It's invoked by BlockBreaker

#

I also modified some of the BlockBreaker methods so I could intercept them

#

Though this should not cause an issue

#

I added it so I could move the NPC closer

#

And I still use the Citizens method

orchid orchid
#

what is moveTo

stray matrix
#

Move to simply teleports, never invokes pathfinding

orchid orchid
#

ok so it doesn't teleport?

stray matrix
#

No,

#

It simply gets stuck in place and calls stuckAction 100 times (after which I despawn it)

orchid orchid
#

what if you call the npc method

#

npc.teleport(location, TeleportCause.PLUGIN)

stray matrix
#

Let me see

#

Still seems to call repeatedly

#

Weird thing is, isNavigating is returning false

orchid orchid
#

does it teleport

stray matrix
#

It now seems to have teleported

#

But I don't see why stuckAction would be called when navigator.isNavigating returns false

orchid orchid
#

if it can't find a path that is also stuck

stray matrix
#

But wouldn't isNavigating return true?

orchid orchid
#

no, because it couldn't find a path

#

it immediately becomes stuck

low vesselBOT
#
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.)

#

@stray matrix