WrapperPlayServerSpawnEntityLiving won't set Yaw. Entities are permanently facing south.
MrRumpunsh opened this issue · 9 comments
Hi there, I was trying to figure this out by myself for far too long now. That's why I am here to ask how to properly spawn an Entity in 1.10.
In 1.8 the following code worked perfectly. But now the Entity is spawning without the proper Yaw and Pitch values:
(Code: https://gist.github.com/MrRumpunsh/2e4d3896da5c6cf837b6f931c681ca7b)
Even teleporting after being spawned doesn't set the Yaw value right. (At this point the .getYaw() value is still -45.0f!)
Am I doing something wrong here? I am really growing desperate right now. Help would be appreciated!
Thank you in advance,
MrRumpunsh
The code in the modifier is the same as that in the NMS packet constructor. Are you sure the location has pitch and yaw?
Yes, I am absolutely sure. Before and After sending the packet, I've printed out living.getYaw(); (so after I've constructed the WrapperClass) and the result was, as expected, -45.0f.
Are you in need of further code and/or proof?
And, if it is neither your fault, nor mine, who is responsible?
That's so weird. You could try modifying the Packet directly (w/ NMS) and if it works, it's an issue with the wrapper, if not it's something else.
Oh yes it is, that's why I am so confused. It should work but it simply doesn't. It's killing me.
But I will follow your advice and try out nms directly. I will report back as soon as I find time to do it.
Thank you for your help so far! :)
Any more info on this?
This is old client side bug. Just send Head rotation packet after entity spawn packet)
That works fine for me. Found it by empirical way.
WrapperPlayServerSpawnEntityLiving spawn = new WrapperPlayServerSpawnEntityLiving();
spawn.setEntityID(-1);
spawn.setUniqueId(UUID.randomUUID());
spawn.setType(EntityType.ZOMBIE);
spawn.setX(loc.getX());
spawn.setY(loc.getY());
spawn.setZ(loc.getZ());
spawn.setYaw(loc.getYaw()); //client ignore
spawn.setPitch(loc.getPitch()); //head pitch
spawn.setHeadPitch(loc.getYaw()); //body yaw
//send packet
WrapperPlayServerEntityHeadRotation head = new WrapperPlayServerEntityHeadRotation();
head.setEntityID(-1);
head.setHeadYaw((byte) ((loc.getYaw() + 45f) * 256.0F / 360.0F)); //head yaw
//send packet
I will try that out. Thank you!
Works absolutely fine! - Thank you all for your great help!
~ Closed.
(Working: https://gist.github.com/MrRumpunsh/093eefdfbae16e838027edbef80b2ac5)