Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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.

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.

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.