类 CriticalHitEvent
Player.attack(Entity)
.
It can be used to change the critical hit status and the critical damage multiplier. Additionally, this event allows controlling if the critical hit will impact sweep conditions.
This event is fired on both the logical client and logical server.
-
嵌套类概要
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
字段概要
字段修饰符和类型字段说明private boolean
private float
private boolean
private final boolean
private final Entity
private final float
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明boolean
If this attack is a critical hit, returns if a sweep should be prevented.float
The damage multiplier is applied to the base attack's damage if the attack critically hits.返回 the entity that was attacked by the player。float
Gets the original damage multiplier set by vanilla.boolean
返回 if the attack will critically hit。boolean
返回 true if the attack was considered a critical hit by vanilla。void
setCriticalHit
(boolean isCriticalHit) Changes the critical hit state.void
setDamageMultiplier
(float dmgMultiplier) Sets the damage multiplier for the critical hit.void
setDisableSweep
(boolean disableSweep) Sets if this attack should prevent a sweep from occurring.从类继承的方法 net.neoforged.neoforge.event.entity.player.PlayerEvent
getEntity
-
字段详细资料
-
target
-
vanillaDmgMultiplier
private final float vanillaDmgMultiplier -
isVanillaCritical
private final boolean isVanillaCritical -
dmgMultiplier
private float dmgMultiplier -
isCriticalHit
private boolean isCriticalHit -
disableSweep
private boolean disableSweep
-
-
构造器详细资料
-
CriticalHitEvent
-
-
方法详细资料
-
getTarget
返回 the entity that was attacked by the player。- 返回:
- the entity that was attacked by the player
-
getDamageMultiplier
public float getDamageMultiplier()The damage multiplier is applied to the base attack's damage if the attack critically hits.A damage multiplier of 1.0 will not change the damage, a value of 1.5 will increase the damage by 50%, and so on.
-
setDamageMultiplier
public void setDamageMultiplier(float dmgMultiplier) Sets the damage multiplier for the critical hit. Not used ifisCriticalHit()
is false.Changing the damage modifier to zero does not guarantee that the attack does zero damage.
- 参数:
dmgMultiplier
- The new damage modifier. Must not be negative.- 另请参阅:
-
isCriticalHit
public boolean isCriticalHit()返回 if the attack will critically hit。- 返回:
- if the attack will critically hit
-
setCriticalHit
public void setCriticalHit(boolean isCriticalHit) Changes the critical hit state.- 参数:
isCriticalHit
- true if the attack should critically hit
-
getVanillaMultiplier
public float getVanillaMultiplier()Gets the original damage multiplier set by vanilla.If the event
isVanillaCritical()
, the damage multiplier will be 1.5, otherwise it will be 1.0- 另请参阅:
-
isVanillaCritical
public boolean isVanillaCritical()返回 true if the attack was considered a critical hit by vanilla。- 返回:
- true if the attack was considered a critical hit by vanilla
-
setDisableSweep
public void setDisableSweep(boolean disableSweep) Sets if this attack should prevent a sweep from occurring.In vanilla, a critical hit always prevents a sweep from occurring. This method can allow an attack to both critically hit and sweep without having to validate the other sweep conditions.
-
disableSweep
public boolean disableSweep()If this attack is a critical hit, returns if a sweep should be prevented.If this attack is not a critical hit, the return value of this method is meaningless.
-