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) booleanbooleanstatic DamageSourcecactus()static DamageSourcedrown()static DamageSourcefall()static DamageSourcegeneric()static DamageSourceinFire()booleanisFire()booleanstatic DamageSourcelava()static DamageSourcebooleanstatic DamageSourceof(TypedKey<DamageType> type) static DamageSourceof(TypedKey<DamageType> type, @Nullable Entity source) static DamageSourcestatic DamageSourceonFire()static DamageSourcestatic DamageSourceplayerAttack(Player attacker) position()static DamageSourcestarve()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
- Parameters:
type- theminecraft:damage_typeto report to the clientposition- the point the damage radiated from, used by the client for the hit direction- Since:
- 0.1.0
-
playerAttack
-
mobAttack
-
fall
-
drown
-
lava
-
inFire
-
onFire
-
cactus
-
starve
-
outOfWorld
-
generic
-
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
-