类 LivingShieldBlockEvent
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.LivingShieldBlockEvent
LivingShieldBlockEvent is fired when an entity is hurt and vanilla checks if the entity is attempting
to block 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: This event fires whether the player is actively using a shield or not. Vanilla shield
blocking logic is captured and passed into the event via
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: This event fires whether the player is actively using a shield or not. Vanilla shield
blocking logic is captured and passed into the event via getOriginalBlock()
. If this is
true, The shield item stack "should" be available from LivingEntity.getUseItem()
at least
for players.
- 另请参阅:
-
嵌套类概要
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
字段概要
字段修饰符和类型字段说明private final DamageContainer
private float
private boolean
private final boolean
private final float
private int
-
构造器概要
构造器构造器说明LivingShieldBlockEvent
(LivingEntity blocker, DamageContainer container, float blockedDamage, boolean originalBlockedState) -
方法概要
修饰符和类型方法说明boolean
Used inEntity.hurt(DamageSource, float)
to signify that a blocking action has occurred.float
boolean
float
void
setBlocked
(boolean isBlocked) Sets the blocking state of the entity.void
setBlockedDamage
(float blocked) Set how much damage is blocked by this action.
Note that initially the blocked amount depends on theBlocksAttacks.damageReductions()
.void
setShieldDamage
(int damage) Set how much durability the shield will lose ifgetBlocked()
is true.int
If the event isgetBlocked()
and the user is holding a shield, the returned amount will be taken from the item's durability.从类继承的方法 net.neoforged.neoforge.event.entity.living.LivingEvent
getEntity
-
字段详细资料
-
container
-
dmgBlocked
private float dmgBlocked -
originalDmgBlocked
private final float originalDmgBlocked -
shieldDamage
private int shieldDamage -
originalBlocked
private final boolean originalBlocked -
newBlocked
private boolean newBlocked
-
-
构造器详细资料
-
LivingShieldBlockEvent
public LivingShieldBlockEvent(LivingEntity blocker, DamageContainer container, float blockedDamage, boolean originalBlockedState)
-
-
方法详细资料
-
getDamageContainer
-
getDamageSource
- 返回:
- The damage source.
-
getOriginalBlockedDamage
public float getOriginalBlockedDamage()- 返回:
- The original amount of damage blocked.
-
getBlockedDamage
public float getBlockedDamage()- 返回:
- The current amount of damage blocked, as a result of this event.
-
shieldDamage
public int shieldDamage()If the event isgetBlocked()
and the user is holding a shield, the returned amount will be taken from the item's durability.- 返回:
- The amount of shield durability damage to take.
-
setBlockedDamage
public void setBlockedDamage(float blocked) Set how much damage is blocked by this action.
Note that initially the blocked amount depends on theBlocksAttacks.damageReductions()
. -
setShieldDamage
public void setShieldDamage(int damage) Set how much durability the shield will lose ifgetBlocked()
is true. Setting this to a value lower than0
will apply the vanillaBlocksAttacks.itemDamage()
.- 参数:
damage
- the new durability value taken from the shield on successful block
-
getOriginalBlock
public boolean getOriginalBlock()- 返回:
- whether the damage would have been blocked by vanilla logic
-
getBlocked
public boolean getBlocked()Used inEntity.hurt(DamageSource, float)
to signify that a blocking action has occurred. If returning false, damage to the shield will not occur.- 返回:
- true if the entity should be considered "blocking"
-
setBlocked
public void setBlocked(boolean isBlocked) Sets the blocking state of the entity. By default, entities raising a shield, facing the damage source, and not being hit by a source that bypasses shields will be considered blocking. An entity can be considered blocking regardless by supplying true to this.- 参数:
isBlocked
- should the entity be treated as if it is blocking
-