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

Is it still possible to detect within a custom mob class if it has been hit by an Uncraftable Tipped Arrow , and if so, how? I am trying to convert code from 1.12.2 to 1.18.2 but the capability no longer seems to exist.

@Override
public boolean hurt(DamageSource source, float amount) {

Entity entity = source.getDirectEntity();
if (entity instanceof LivingEntity) {
this.setTarget((LivingEntity) entity);
if (entity instanceof Player) {
if (amount > 0) {
if (source.isProjectile()) {

if (!this.hasPal()) {
if( source.getImmediateSource() instanceof EntityTippedArrow) { 
TippedArrowItem tippedArrow = (TippedArrowItem) source.get.getImmediateSource();

if (tippedArrow.getColor()==3694022) {

 

Edited by DinoPawz

  • DinoPawz changed the title to Forge 1.18.2 How to detect if mob hit by an Uncraftable Tipped Arrow

Tipped arrows are now just regular `Arrow` entities that contain a potion or a list of mob effects. This can be checked using `#getPickupItem` on the returned `ItemStack`s `CompoundTag`. You can use the `PotionUtils` helper to read the data. Uncraftable tipped arrows apply custom effects and not a potion.

  • Author

Thank you, I have managed to get the color arrows that have potion effects, but mc doesn't bother to give the Uncraftable Tipped Arrow a color anymore, and gives the same -1 color result as a plain arrow and identical names 'entity.minecraft.arrow'. So no way to distinguish from getting hit with the Uncraftable Tipped Arrow and a plain Arrow.

16 hours ago, DinoPawz said:

So no way to distinguish from getting hit with the Uncraftable Tipped Arrow and a plain Arrow.

Those are two separate items though, iirc. One is a TippedArrowItem and the other is just an ArrowItem.

  • 2 weeks later...
  • Author

But all types of arrows are now just stored under Arrow which is an entity and not castable as items. The only hurt investigating you can do is:

if (source.getDirectEntity() instanceof Arrow) {

int col = ((Arrow) source.getDirectEntity()).getColor();

if(source.isProjectile())

 

10 hours ago, DinoPawz said:

But all types of arrows are now just stored under Arrow which is an entity and not castable as items. The only hurt investigating you can do is:

 

That's the entity. I was talking about the item stack, which you can get from the entity itself.

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.