Class DamageSource
java.lang.Object
fr.fidorial.combat.DamageSource
Describes where a hit came from.
A source carries the minecraft:damage_type used by the client to pick the death
message and the screen tint, plus the entities involved. causingEntity() is the entity
credited with the kill (the shooter), while directEntity() is what actually touched the
victim (the arrow). For a melee hit both are the same entity.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic DamageSourceat(TypedKey<DamageType> type, Location position) Creates a source for damage radiating from a point, such as an explosion.booleanbooleanstatic DamageSourcecactus()Returns a source for damage dealt by touching a cactus.static DamageSourcedrown()Returns a source for damage dealt by drowning.static DamageSourcefall()Returns a source for damage dealt by falling.static DamageSourcegeneric()Returns a source for damage dealt by an unspecified cause.static DamageSourceinFire()Returns a source for damage dealt by standing in fire.booleanisFire()booleanstatic DamageSourcelava()Returns a source for damage dealt by standing in lava.static DamageSourceReturns a source for damage dealt by a mob melee hit.booleanstatic DamageSourceof(TypedKey<DamageType> type) static DamageSourceof(TypedKey<DamageType> type, @Nullable Entity source) static DamageSourcestatic DamageSourceonFire()Returns a source for damage dealt by burning.static DamageSourceReturns a source for damage dealt by falling out of the world.static DamageSourceplayerAttack(Player attacker) Returns a source for damage dealt by a player melee hit.position()static DamageSourcestarve()Returns a source for damage dealt by starving.toString()type()withPosition(Location position)
-
Method Details
-
of
- Parameters:
type- theminecraft:damage_typeto report to the client- Returns:
- an environmental source with no entity attached
- Since:
- 0.1.0
-
of
- Parameters:
type- theminecraft:damage_typeto report to the clientsource- the entity responsible for the hit- Since:
- 0.1.0
-
of
public static DamageSource of(TypedKey<DamageType> type, @Nullable Entity causing, @Nullable Entity direct) - Parameters:
type- theminecraft:damage_typeto report to the clientcausing- the entity credited with the kill, typically the shooterdirect- the entity that physically hit the victim, typically the projectile- Since:
- 0.1.0
-
at
Creates a source for damage radiating from a point, such as an explosion.- Parameters:
type- theminecraft:damage_typeto report to the clientposition- the point the damage radiated from, used by the client for the hit direction- Returns:
- the source
- Since:
- 0.1.0
-
playerAttack
Returns a source for damage dealt by a player melee hit.- Parameters:
attacker- the attacking player- Returns:
- a source for damage dealt by a player melee hit
- Since:
- 0.1.0
-
mobAttack
Returns a source for damage dealt by a mob melee hit.- Parameters:
attacker- the attacking mob, ornull- Returns:
- a source for damage dealt by a mob melee hit
- Since:
- 0.1.0
-
fall
Returns a source for damage dealt by falling.- Returns:
- a source for damage dealt by falling
- Since:
- 0.1.0
-
drown
Returns a source for damage dealt by drowning.- Returns:
- a source for damage dealt by drowning
- Since:
- 0.1.0
-
lava
Returns a source for damage dealt by standing in lava.- Returns:
- a source for damage dealt by standing in lava
- Since:
- 0.1.0
-
inFire
Returns a source for damage dealt by standing in fire.- Returns:
- a source for damage dealt by standing in fire
- Since:
- 0.1.0
-
onFire
Returns a source for damage dealt by burning.- Returns:
- a source for damage dealt by burning
- Since:
- 0.1.0
-
cactus
Returns a source for damage dealt by touching a cactus.- Returns:
- a source for damage dealt by touching a cactus
- Since:
- 0.1.0
-
starve
Returns a source for damage dealt by starving.- Returns:
- a source for damage dealt by starving
- Since:
- 0.1.0
-
outOfWorld
Returns a source for damage dealt by falling out of the world.- Returns:
- a source for damage dealt by falling out of the world
- Since:
- 0.1.0
-
generic
Returns a source for damage dealt by an unspecified cause.- Returns:
- a source for damage dealt by an unspecified cause
- Since:
- 0.1.0
-
type
- Returns:
- the registry key of the damage type backing this source
-
causingEntity
-
directEntity
-
position
- Returns:
- the origin used to orient the hurt animation, or
nullto derive it fromdirectEntity()
-
bypassesArmor
public boolean bypassesArmor()- Returns:
truewhen armour points do not reduce this damage
-
bypassesInvulnerability
public boolean bypassesInvulnerability()- Returns:
truewhen this damage ignores both invulnerability frames and creative mode
-
isFire
public boolean isFire()- Returns:
truewhen this damage counts as fire for resistances and effects
-
isProjectile
public boolean isProjectile()- Returns:
truewhen the hit came from a projectile
-
noKnockback
public boolean noKnockback()- Returns:
truewhen this damage must never push the victim around
-
withPosition
- Returns:
- the source with
positionattached, used to orient the hurt animation
-
toString
-