Jump to content

Forge 1.18.2 How to detect if mob hit by an Uncraftable Tipped Arrow


DinoPawz

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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