Jump to content

[1.19.4] Implementing a sticky bomb: rotation behavior (vehicle passenger rotates unexpectedly)


Recommended Posts

Posted (edited)

This is a very specific problem, but let me elaborate:

I am implementing a custom GeckoLib entity that is a sticky bomb. When thrown at another entity, the bomb must latch onto that entity by "riding" it. I need to do mainly two things in order to make the bomb really look like it is  sticking to an entity:

1. Modify the bomb's riding position by overriding its Entity#setPos method. The bomb must be positioned so that it will appear stuck to the body part of the entity that it hit.

2. Modify the bomb's rotation by overriding its Projectile#updateRotation method. The bomb should be rotated so that it constantly faces its victim (i.e. the center of the victim's hitbox).

The math and logic behind implementing #1 and #2 was not that difficult for me, and I was able to implement #1 successfully. However, I am struggling with #2 because whenever the vehicle itself rotates, the bomb seems to rotate the wrong way. I even tried modifying the overridden updateRotation method so that the bomb's rotation is not changed when it is riding a vehicle (i.e. this.getVehicle() != null), but the bomb somehow still rotates when the vehicle rotates. So far, I could not find any other code that modifies the rotation of a passenger entity on a vehicle. But what I have found out is that--when the bomb rotates unexpectedly--its hitbox does not rotate with it (Hitbox rotation is indicated by the direction its blue line is pointing when the player presses F3 + B). Was it being rotated clientside? What could be causing this behavior? 

Edited by LeeCrafts
  • LeeCrafts changed the title to [1.19.4] Implementing a sticky bomb: rotation behavior (vehicle passenger rotates unexpectedly)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.