Topic category: Help with Minecraft modding (Java Edition)
Hi friends,
What is the correct way to tell a mob to point at a particular location?
Custom code examples or procedure examples would both be helpful!
Here is what I am trying to rotate:
1. Make new LivingEntity
2. Behavior -> Is flying entity
3. Enable AI (empty)
I want to make the entity look at a specific point as it moves.
These phantoms are intended to:
Spawn above the block (working)
Circle down toward the block (movement working, rotation not working)
Touch the block (working)
Then circle back up into the sky and despawn (movement working, rotation not working)
Here are some things I have tried, but were not successful:
Some custom code I tried - not successful:
@Override
public void baseTick()
{
super.baseTick();
//this sets NBT for velX, velY, and velZ
PhantomailCourierTickSpicyProcedure.execute(this);
double velX = getPersistentData().getDouble("velX");
double velY = getPersistentData().getDouble("velY");
double velZ = getPersistentData().getDouble("velZ");
//DOES NOT WORK IN THIS EXAMPLE
//use look controller to point the mob at a position
lookControl.setLookAt(position().x + velX, position().y + velY, position().z + velZ);
lookControl.tick();
//DOES NOT WORK IN THIS EXAMPLE
//attempt to set yaw to face the direction we are moving in - multiply by radians to degrees
setRot((float)(Math.atan2(velZ,velX) * 57.2958),(float)0);
//Not sure what these do - doesn't appear to do anything
setXxa((float)90);
setZza((float)-90);
}
Here is a copy of the procedure if that helps:
https://cdn.discordapp.com/attachments/1054132569886703717/105517741479…
After a bunch of trial-and-error, I figured out what I wanted.
There were 3 required things:
As far as I can tell, these had to be done in that specific order.