Posted May 25, 20232 yr 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 May 25, 20232 yr by DinoPawz
May 25, 20232 yr 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.
May 25, 20232 yr 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.
May 26, 20232 yr 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.
June 7, 20232 yr 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())
June 7, 20232 yr 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.