Class ShieldBlockEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.living.ShieldBlockEvent
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
public class ShieldBlockEvent
extends LivingEvent
implements net.neoforged.bus.api.ICancellableEvent
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
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.-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEventNested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate floatprivate final floatprivate booleanprivate final DamageSource -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatfloatvoidsetBlockedDamage(float blocked) Set how much damage is blocked by this action.
Note that initially the blocked amount is the entire attack.voidsetShieldTakesDamage(boolean damage) Set if the shield will take durability damage or not.booleanControls ifLivingEntity.hurtCurrentlyUsedShield(float)is called.Methods inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
getEntityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
source
-
originalBlocked
private final float originalBlocked -
dmgBlocked
private float dmgBlocked -
shieldTakesDamage
private boolean shieldTakesDamage
-
-
Constructor Details
-
ShieldBlockEvent
-
-
Method Details
-
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()Controls ifLivingEntity.hurtCurrentlyUsedShield(float)is called.- 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.
-