Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.