Class ShieldBlockEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event

public class ShieldBlockEvent extends LivingEvent
The ShieldBlockEvent is fired when an entity successfully blocks with a shield.
Cancelling this event will have the same impact as if the shield was not eligible to block.
The damage blocked cannot be set lower than zero or greater than the original value.
Note: The shield item stack "should" be available from LivingEntity.getUseItem() at least for players.
  • Field Details

    • source

      private final DamageSource source
    • originalBlocked

      private final float originalBlocked
    • dmgBlocked

      private float dmgBlocked
    • shieldTakesDamage

      private boolean shieldTakesDamage
  • Constructor Details

  • Method Details

    • getDamageSource

      public DamageSource getDamageSource()
      Returns:
      The damage source.
    • getOriginalBlockedDamage

      public float getOriginalBlockedDamage()
      Returns:
      The original amount of damage blocked, which is the same as the original incoming damage value.
    • getBlockedDamage

      public float getBlockedDamage()
      Returns:
      The current amount of damage blocked, as a result of this event.
    • shieldTakesDamage

      public boolean shieldTakesDamage()
      Returns:
      If the shield item will take durability damage or not.
    • setBlockedDamage

      public void setBlockedDamage(float blocked)
      Set how much damage is blocked by this action.
      Note that initially the blocked amount is the entire attack.
    • setShieldTakesDamage

      public void setShieldTakesDamage(boolean damage)
      Set if the shield will take durability damage or not.