DamageSource

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.util.DamageSource;

Methods

canBypassCreative

Checks if the damage can bypass creative mode.

Return Type: boolean

ZenScript
Copy
DamageSource.canBypassCreative() as boolean
myDamageSource.canBypassCreative();

getDamageLocation

Gets the location where the damage occurred.

Return Type: MCVector3d?

ZenScript
Copy
DamageSource.getDamageLocation() as MCVector3d?
myDamageSource.getDamageLocation();

getDamageType

Gets the type of damage.

Return Type: string

ZenScript
Copy
DamageSource.getDamageType() as string
myDamageSource.getDamageType();

getHungerDamage

Gets the amount of exhaustion to add to the player's hunger bar if they get hit by this damage.

Return Type: float

ZenScript
Copy
DamageSource.getHungerDamage() as float
myDamageSource.getHungerDamage();

getImmediateSource

Gets the immediate source of the damage, like an arrow.

Return Type: MCEntity

ZenScript
Copy
DamageSource.getImmediateSource() as MCEntity
myDamageSource.getImmediateSource();

getTrueSource

Gets the true source of the damage, like the player who shot the arrow.

Return Type: MCEntity

ZenScript
Copy
DamageSource.getTrueSource() as MCEntity
myDamageSource.getTrueSource();

isAbsoluteDamage

Checks if the damage is absolute.

Return Type: boolean

ZenScript
Copy
DamageSource.isAbsoluteDamage() as boolean
myDamageSource.isAbsoluteDamage();

isCreativePlayer

Gets whether the damage was inflicted by a creative player.

Return Type: boolean

ZenScript
Copy
DamageSource.isCreativePlayer() as boolean
myDamageSource.isCreativePlayer();

isDifficultyScaled

Gets whether the damage changes strength based on the current difficulty.

Return Type: boolean

ZenScript
Copy
DamageSource.isDifficultyScaled() as boolean
myDamageSource.isDifficultyScaled();

isExplosionDamage

Checks if the damage is caused by an explosion.

Return Type: boolean

ZenScript
Copy
DamageSource.isExplosionDamage() as boolean
myDamageSource.isExplosionDamage();

isFireDamage

Checks if the damage is caused by fire or burning.

Return Type: boolean

ZenScript
Copy
DamageSource.isFireDamage() as boolean
myDamageSource.isFireDamage();

isMagicDamage

Checks if the damage is caused by magic.

Return Type: boolean

ZenScript
Copy
DamageSource.isMagicDamage() as boolean
myDamageSource.isMagicDamage();

isProjectileDamage

Checks if the damage is caused by a projectile.

Return Type: boolean

ZenScript
Copy
DamageSource.isProjectileDamage() as boolean
myDamageSource.isProjectileDamage();

isUnblockableDamage

Checks if the damage can be blocked.

Return Type: boolean

ZenScript
Copy
DamageSource.isUnblockableDamage() as boolean
myDamageSource.isUnblockableDamage();

Properties

NameTypeHa GetterHa Setter
absolutebooleantruefalse
bypassCreativebooleantruefalse
creativePlayerbooleantruefalse
difficultyScaledbooleantruefalse
explosionbooleantruefalse
firebooleantruefalse
hungerDamagefloattruefalse
immediateSourceMCEntitytruefalse
posizioneMCVector3d?truefalse
magicbooleantruefalse
projectilebooleantruefalse
trueSourceMCEntitytruefalse
typestringtruefalse
unblockablebooleantruefalse