FancyMcPlugins / FancyNpcs

FancyNpcs is a simple, lightweight and fast npc plugin using packets
https://modrinth.com/plugin/fancynpcs
MIT License
100 stars 23 forks source link

Rotate the player's body #59

Open luisBazanDev opened 8 months ago

luisBazanDev commented 8 months ago

I was trying to make some kind of selector and I need the npc I have to rotate completely, but with the lookat method it only rotates the player's head and not the entire body.

Perhaps something similar can be achieved with the BodyRotationControl class. and make a lookat method that receives a boolean value to rotate the body as well, I couldn't implement it correctly but maybe someone else will do it

https://github.com/FancyMcPlugins/FancyNpcs/blob/main/implementation_1_20_2/src/main/java/de/oliver/fancynpcs/v1_20_2/Npc_1_20_2.java#L141

I only found this reference to the mentioned class: https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.18.2/net/minecraft/world/entity/ai/control/BodyRotationControl.html

OliverSchlueter commented 4 months ago

Should be fixed now, would be greate, if you could test it.

Latest dev build: https://fancyplugins.de/FancyNpcs/download/

luisBazanDev commented 4 months ago

Ok. I will test it later, don't worry.

luisBazanDev commented 4 months ago

I did 2 tests. Which are the same ones I tried before. In the first test it was a little better but since the package is used it makes the npc hit the air so it looks bad. In the second test the same thing happens as before. The body begins to rotate when the angle of rotation of the head reaches the limit so to speak. Well, I'm not sure if it's possible to implement the class I mentioned "BodyRotationControl". I attach a video with both tests and their codes.

Test 1:

Location location = npc.getData().getLocation();
location.setYaw(angle - 180);
location.setPitch(0);

npc.getData().setLocation(location);
npc.move(player);

Test 2:

Location location = npc.getData().getLocation();
location.setYaw(angle - 180);
location.setPitch(0);

npc.lookAt(player, location);

https://github.com/FancyMcPlugins/FancyNpcs/assets/99089018/edc7f447-0579-42c7-9f02-df8aca5020a5