juliarn / npc-lib

Asynchronous, high-performance Minecraft NPC library for 1.8-1.21 servers.
MIT License
296 stars 50 forks source link

Npc Rotation Issue #97

Closed plytki closed 1 year ago

plytki commented 1 year ago

Npc yaw setting is not working. It always spawns at yaw = 0. I used npc.lookAt() but still doesn't work. How to properly rotate an Npc?

derklaro commented 1 year ago

Interesting, the method is used internally (in combination with the action controller) and works there perfectly fine from my testing 🤔

plytki commented 1 year ago

Maybe I'm doing it wrong. How can I properly rotate the npc and when should I?

plytki commented 1 year ago

image I've tried everything.

ytnoos commented 1 year ago

I have the same issue

plytki commented 1 year ago

image Line 128 is setting the position but still nothing.

derklaro commented 1 year ago

The lookAt method returns a prepared packet, you need to send it to the target player(s), using .schedule

plytki commented 1 year ago

This also does not work. "/ https://streamable.com/273clz

derklaro commented 1 year ago

Can you print out the result of bossNPC.getPosition() and walk to that position? That should be where the npc looks to...

plytki commented 1 year ago

https://streamable.com/jnspvf

derklaro commented 1 year ago

Based on the printed values, it looks correct? (maybe I'm just misunderstanding the values tho 😂 )

plytki commented 1 year ago

Npcs are facing yaw 0. Not 90 as expected. image

derklaro commented 1 year ago

The yaw and pitch you're providing to the method are not taken into account. The method calculates the yaw and pitch to look at based on the position to look at (x, y, z).

plytki commented 1 year ago

Is there a way to change just rotation? I want to just change the rotation of the npc.

derklaro commented 1 year ago

Might be a good helper method to add, until then you can use platform.packetFactory().createRotationPacket(yaw, pitch).schedule(...)

plytki commented 1 year ago

Ok, that works! Thanks!