Jump to content

[1.6.4] How do I add armor piercing to my weapon?


zhangh

Recommended Posts

Well, try to find a way to shortcut the damage reduction!

I would not suggest damaging the entity directly, but scaling up your damage done by the item to effectively ignore the armor value... (WARNING: Requires basic algebra)

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

The way I did it was to create a new static DamageSource class:

public static class DamageSourceArmorBreak extends EntityDamageSource {
public DamageSourceArmorBreak(String name, Entity entity) {
super(name, entity);
setDamageBypassesArmor();
}
}

Then I listen for the LivingHurtEvent, check if the source of the damage is a player using, in this case, a special skill (substitute your weapon), and then damage the entity with my new damage source instead.

DirtyEntityAccessor.damageEntity((EntityLivingBase) event.entity, DamageUtils.causeArmorBreakDamage(player), event.ammount);
event.ammount = 0.0F; // set to 0 and/or cancel the event so entity not damaged twice

DirtyEntityAccessor is just a class that I placed in the net.minecraft.entity folder that allows me to call the protected 'damageEntity' method:

public class DirtyEntityAccessor {
public static void damageEntity(EntityLivingBase target, DamageSource source, float amount) {
target.damageEntity(source, amount);
}
}

Thanks again to diesieben07 for his help with that particular solution.

Link to comment
Share on other sites

The way I did it was to create a new static DamageSource class:

public static class DamageSourceArmorBreak extends EntityDamageSource {
public DamageSourceArmorBreak(String name, Entity entity) {
super(name, entity);
setDamageBypassesArmor();
}
}

Then I listen for the LivingHurtEvent, check if the source of the damage is a player using, in this case, a special skill (substitute your weapon), and then damage the entity with my new damage source instead.

DirtyEntityAccessor.damageEntity((EntityLivingBase) event.entity, DamageUtils.causeArmorBreakDamage(player), event.ammount);
event.ammount = 0.0F; // set to 0 and/or cancel the event so entity not damaged twice

DirtyEntityAccessor is just a class that I placed in the net.minecraft.entity folder that allows me to call the protected 'damageEntity' method:

public class DirtyEntityAccessor {
public static void damageEntity(EntityLivingBase target, DamageSource source, float amount) {
target.damageEntity(source, amount);
}
}

Thanks again to diesieben07 for his help with that particular solution.

 

Where do i put the 2nd code?

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.

Announcements



×
×
  • Create New...

Important Information

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