Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

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.

script.zs
import crafttweaker.api.util.DamageSource;

Static Methods

Return Type: DamageSource

script.zs
// DamageSource.causeBedExplosionDamage() as DamageSource
DamageSource.causeBedExplosionDamage();

Return Type: DamageSource

script.zs
DamageSource.causeBeeStingDamage(bee as MCLivingEntity) as DamageSource
ParameterTypeDescription
Parameter
bee
Type
MCLivingEntity
Description
No Description Provided

Return Type: DamageSource

script.zs
DamageSource.causeExplosionDamage(entityLivingBaseIn as MCLivingEntity?) as DamageSource
ParameterTypeDescriptionOptionalDefaultValue
Parameter
entityLivingBaseIn
Type
MCLivingEntity?
Description
No Description Provided
Optional
true
DefaultValue

Return Type: DamageSource

script.zs
DamageSource.causeExplosionDamage(explosionIn as Explosion?) as DamageSource
ParameterTypeDescriptionOptionalDefaultValue
Parameter
explosionIn
Type
Explosion?
Description
No Description Provided
Optional
true
DefaultValue

Return Type: DamageSource

script.zs
DamageSource.causeIndirectDamage(source as MCEntity, indirectEntityIn as MCLivingEntity) as DamageSource
ParameterTypeDescription
Parameter
source
Type
MCEntity
Description
No Description Provided
Parameter
indirectEntityIn
Type
MCLivingEntity
Description
No Description Provided

Return Type: DamageSource

script.zs
DamageSource.causeIndirectMagicDamage(source as MCEntity, indirectEntityIn as MCEntity?) as DamageSource
ParameterTypeDescriptionOptionalDefaultValue
Parameter
source
Type
MCEntity
Description
No Description Provided
Optional
false
DefaultValue
Parameter
indirectEntityIn
Type
MCEntity?
Description
No Description Provided
Optional
true
DefaultValue

Return Type: DamageSource

script.zs
DamageSource.causeMobDamage(mob as MCLivingEntity) as DamageSource
ParameterTypeDescription
Parameter
mob
Type
MCLivingEntity
Description
No Description Provided

Return Type: DamageSource

script.zs
DamageSource.causePlayerDamage(player as MCPlayerEntity) as DamageSource
ParameterTypeDescription
Parameter
player
Type
MCPlayerEntity
Description
No Description Provided

Return Type: DamageSource

script.zs
DamageSource.causeThornsDamage(source as MCEntity) as DamageSource
ParameterTypeDescription
Parameter
source
Type
MCEntity
Description
No Description Provided

Return Type: DamageSource

script.zs
DamageSource.causeThrownDamage(source as MCEntity, indirectEntityIn as MCEntity?) as DamageSource
ParameterTypeDescriptionOptionalDefaultValue
Parameter
source
Type
MCEntity
Description
No Description Provided
Optional
false
DefaultValue
Parameter
indirectEntityIn
Type
MCEntity?
Description
No Description Provided
Optional
true
DefaultValue

Return Type: DamageSource

script.zs
DamageSource.causeTridentDamage(source as MCEntity, indirectEntityIn as MCEntity?) as DamageSource
ParameterTypeDescriptionOptionalDefaultValue
Parameter
source
Type
MCEntity
Description
No Description Provided
Optional
false
DefaultValue
Parameter
indirectEntityIn
Type
MCEntity?
Description
No Description Provided
Optional
true
DefaultValue

Methods

Checks if the damage can bypass creative mode.

Returns: Whether or not the damage can bypass creative mode.
Return Type: boolean

script.zs
// DamageSource.canBypassCreative() as boolean
myDamageSource.canBypassCreative();

Gets the location where the damage occurred.

Returns: The location of the damage.
Return Type: MCVector3d?

script.zs
// DamageSource.getDamageLocation() as MCVector3d?
myDamageSource.getDamageLocation();

Gets the type of damage.

Returns: The type of damage.
Return Type: string

script.zs
// DamageSource.getDamageType() as string
myDamageSource.getDamageType();

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

Returns: The amount of exhaustion to add to the player’s hunger bar.
Return Type: float

script.zs
// DamageSource.getHungerDamage() as float
myDamageSource.getHungerDamage();

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

Returns: The immediate source of the damage.
Return Type: MCEntity?

script.zs
// DamageSource.getImmediateSource() as MCEntity?
myDamageSource.getImmediateSource();

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

Returns: The true source of the damage.
Return Type: MCEntity?

script.zs
// DamageSource.getTrueSource() as MCEntity?
myDamageSource.getTrueSource();

Checks if the damage is absolute.

Returns: Whether or not the damage is absolute.
Return Type: boolean

script.zs
// DamageSource.isAbsoluteDamage() as boolean
myDamageSource.isAbsoluteDamage();

Gets whether the damage was inflicted by a creative player.

Returns: Whether the damage was inflicted by a creative player.
Return Type: boolean

script.zs
// DamageSource.isCreativePlayer() as boolean
myDamageSource.isCreativePlayer();

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

Returns: Whether the damage changes strength according to difficulty.
Return Type: boolean

script.zs
// DamageSource.isDifficultyScaled() as boolean
myDamageSource.isDifficultyScaled();

Checks if the damage is caused by an explosion.

Returns: Whether or not the damage is caused by an explosion.
Return Type: boolean

script.zs
// DamageSource.isExplosionDamage() as boolean
myDamageSource.isExplosionDamage();

Checks if the damage is caused by fire or burning.

Returns: Whether or not the damage is caused by fire or burning.
Return Type: boolean

script.zs
// DamageSource.isFireDamage() as boolean
myDamageSource.isFireDamage();

Checks if the damage is caused by magic.

Returns: Whether or not the damage is caused by magic.
Return Type: boolean

script.zs
// DamageSource.isMagicDamage() as boolean
myDamageSource.isMagicDamage();

Checks if the damage is caused by a projectile.

Returns: Whether or not the damage is caused by a projectile.
Return Type: boolean

script.zs
// DamageSource.isProjectileDamage() as boolean
myDamageSource.isProjectileDamage();

Checks if the damage can be blocked.

Returns: Whether or not the damage can be blocked.
Return Type: boolean

script.zs
// DamageSource.isUnblockableDamage() as boolean
myDamageSource.isUnblockableDamage();

Properties

NameTypeHas GetterHas SetterDescription
Name
absolute
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the damage is absolute.
Name
bypassCreative
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the damage can bypass creative mode.
Name
creativePlayer
Type
boolean
Has Getter
true
Has Setter
false
Description
Gets whether the damage was inflicted by a creative player.
Name
difficultyScaled
Type
boolean
Has Getter
true
Has Setter
false
Description
Gets whether the damage changes strength based on the current difficulty.
Name
explosion
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the damage is caused by an explosion.
Name
fire
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the damage is caused by fire or burning.
Name
hungerDamage
Type
float
Has Getter
true
Has Setter
false
Description
Gets the amount of exhaustion to add to the player’s hunger bar if they
get hit by this damage.
Name
immediateSource
Type
MCEntity?
Has Getter
true
Has Setter
false
Description
Gets the immediate source of the damage, like an arrow.
Name
location
Type
MCVector3d?
Has Getter
true
Has Setter
false
Description
Gets the location where the damage occurred.
Name
magic
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the damage is caused by magic.
Name
projectile
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the damage is caused by a projectile.
Name
trueSource
Type
MCEntity?
Has Getter
true
Has Setter
false
Description
Gets the true source of the damage, like the player who shot the arrow.
Name
type
Type
string
Has Getter
true
Has Setter
false
Description
Gets the type of damage.
Name
unblockable
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the damage can be blocked.