January 28, 201411 yr 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.
January 28, 201411 yr 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. http://i.imgur.com/NdrFdld.png[/img]
January 28, 201411 yr That also works, didn't know that method was there. So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.
January 28, 201411 yr Author 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?
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.