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.

Featured Replies

Posted

What code should I add to a projectile to make it give a hit player a potion effect?

Developer of the WIP Rubies mod.

There is no event for when a projectile hits an entity of any type.

 

However. You can use LivingHurtEvent - check if the event's entity (event.entity) is instance of the Player.

If I remember correctly, there is another a field where you can see the damage source, check if the damage source is from the Arrow before giving the entity (Player) a potion effect.

 

 

  • Author

Ok, but what is LivingHurtEvent? I can't seem to find a class or a (static) method by that name.

Developer of the WIP Rubies mod.

Read up tutorials on event handling for Minecraft forge. And yes, event.entity is the entity hurt, and event.source.getEntity() is the entity that caused the damage.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Not sure what type of projectile you've got going there, but if it extends EntityThrowable then you can override the onImpact method. You can see how vanilla's EntityEnderPearl deals damage to what it hits there.

 

If it's more like an arrow, then perhaps you can override onCollideWithPlayer. Not sure how that will work out, though. EntityArrow does it but only for letting players pick up their arrows again, not to deal damage. You'd probably instead have to override onUpdate and handle the flying through the air and all that yourself (you could mostly copy EntityArrow so it shouldn't be too bad) or use a method like that suggested above.

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.