Questions about entity.moveTo vs entity.setDeltaMotion

Started by Lofty on

Topic category: Help with modding (Java Edition)

Last seen on 04:04, 3. Feb 2023
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Questions about entity.moveTo vs entity.setDeltaMotion
Tue, 12/20/2022 - 22:32 (edited)

Several questions!
I'm playing with a test creature and am trying to move it around.
I created a new LivingEntity in a test workspace and named it PathingTester.

Using the code below, the creature flickers constantly back and forth - it is very stuttery when I expected smooth motion.

1. How can I smooth the creature's motion? The flickering is awful haha
2. What is the proper use of setDeltaMotion? (Nothing happens when I try to use it with this creature.)
3. Are there any weird gotchas or gimmicks I need to keep in mind when choosing a base mob type? (I chose a silverfish for this test)
4. I locked the code for the creature in PathingTesterEntity.java, but not in PathingTesterRenderer.java, and I had to re-lock and re-unlock the whole mod element to change the model from silverfish to slime. Is it intended that all of the java files get locked instead of just the one being edited?

Thanks in advance for help and guidance

@Override
	public void baseTick() 
	{
		super.baseTick();
		
		++myTicks;
		double radius = 5.0;

		//current location
		Vec3 pos = position();
		double px = pos.x;
		double py = pos.y;
		double pz = pos.z;

		//desired location - circle <0,70,0> over the course of 8 seconds with a radius of 5 blocks
		double x = Math.cos(myTicks * (0.05 * Math.PI * 2) / 8.0) * radius;
		double y = 70.0;
		double z = Math.sin(myTicks * (0.05 * Math.PI * 2) / 8.0) * radius;

		//dirty teleport
		moveTo(x,y,z);
	}
Edited by Lofty on Tue, 12/20/2022 - 22:32
Last seen on 18:22, 26. Apr 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
fairly certain moveTo just…
Tue, 12/20/2022 - 22:48

fairly certain moveTo just teleports it. delta motion is already available as a procedure, attempt to override motion vector.

Last seen on 04:04, 3. Feb 2023
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I unlocked the mob's code,…
Wed, 12/21/2022 - 07:55

I unlocked the mob's code, then checked the box to enable AI. 

Now setDeltaMotion is working as expected.