Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

Posted

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.

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

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())

 

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

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