Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

Explosion

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.world.Explosion;

Static Methods

Return Type: Explosion

script.zs
Explosion.create(world as MCWorld, x as double, y as double, z as double, size as float, causesFire as boolean, mode as ExplosionMode, exploder as MCEntity, source as DamageSource) as Explosion
ParameterTypeDescriptionOptionalDefaultValue
Parameter
world
Type
MCWorld
Description
No Description Provided
Optional
false
DefaultValue
Parameter
x
Type
double
Description
No Description Provided
Optional
false
DefaultValue
Parameter
y
Type
double
Description
No Description Provided
Optional
false
DefaultValue
Parameter
z
Type
double
Description
No Description Provided
Optional
false
DefaultValue
Parameter
size
Type
float
Description
No Description Provided
Optional
false
DefaultValue
Parameter
causesFire
Type
boolean
Description
No Description Provided
Optional
false
DefaultValue
Parameter
mode
Type
ExplosionMode
Description
No Description Provided
Optional
false
DefaultValue
Parameter
exploder
Type
MCEntity
Description
No Description Provided
Optional
true
DefaultValue
Parameter
source
Type
DamageSource
Description
No Description Provided
Optional
true
DefaultValue

Methods

Clears the affected block positions of this Explosion.

Return Type: void

script.zs
// Explosion.clearAffectedBlockPositions() as void
myExplosion.clearAffectedBlockPositions();

Performs the first part of the explosion which is destroying the blocks.

Return Type: void

script.zs
// Explosion.doExplosionA() as void
myExplosion.doExplosionA();

Performs the second part of the explosion which is the sound, drops and if enabled the particles.

Return Type: void

script.zs
// Explosion.doExplosionB(spawnParticles as boolean) as void
myExplosion.doExplosionB(true);
ParameterTypeDescription
Parameter
spawnParticles
Type
boolean
Description
Should particles be spawned.

Return Type: stdlib.List<BlockPos>

script.zs
// Explosion.getAffectedBlockPositions() as stdlib.List<BlockPos>
myExplosion.getAffectedBlockPositions();

Gets the damage source of this Explosion.

Returns: The damage source of this Explosion.
Return Type: DamageSource

script.zs
// Explosion.getDamageSource() as DamageSource
myExplosion.getDamageSource();

Gets the actual Entity that caused this Explosion to occur.

Examples: TNT will return itself. Creeper will return itself. A Ghast fireball will return itself.

You may need to cast the returned Entity to not be nullable.

Returns: The Entity that caused this Explosion. If the Explosion wasn’t caused by any Entity, it will return null.
Return Type: MCEntity?

script.zs
// Explosion.getExploder() as MCEntity?
myExplosion.getExploder();

Gets the LivingEntity that caused this Explosion.

For example: If the Explosion was caused by TNT, it will return the PlayerEntity that placed it. If the Explosion was caused by a Creeper or another Entity directly, it will return that Entity. If the Explosion was caused by a Ghast fireball, it will return the Ghast.

If no Entity caused this Explosion (for example, if the Explosion was caused by TNT in a Desert Temple that generated in the world), then null is returned.

You may need to cast the returned LivingEntity to not be nullable.

Returns: The LivingEntity that caused this Explosion. null if no LivingEntity caused it.
Return Type: MCLivingEntity?

script.zs
// Explosion.getExplosivePlacedBy() as MCLivingEntity?
myExplosion.getExplosivePlacedBy();

Gets the player knockback map for this Explosion.

This map is only populated in Explosion#doExplosionA() so calling it before will return nothing.

This map is used to calculate the vectors that players around the explosion will be pushed back by.

Returns: A Map of PlayerEntity to Vector3d depicting knockback vectors.
Return Type: MCVector3d[MCPlayerEntity]

script.zs
// Explosion.getPlayerKnockbackMap() as MCVector3d[MCPlayerEntity]
myExplosion.getPlayerKnockbackMap();

Return Type: MCVector3d

script.zs
// Explosion.getPosition() as MCVector3d
myExplosion.getPosition();

Properties

NameTypeHas GetterHas SetterDescription
Name
Type
MCEntity?
Has Getter
true
Has Setter
false
Description
Gets the actual Entity that caused this Explosion to occur.

Examples:
TNT will return itself.
Creeper will return itself.
A Ghast fireball will return itself.

You may need to cast the returned Entity to not be nullable.
Name
affectedBlockPositions
Type
stdlib.List<BlockPos>
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
damageSource
Type
DamageSource
Has Getter
true
Has Setter
false
Description
Gets the damage source of this Explosion.
Name
explosivePlacedBy
Type
MCLivingEntity?
Has Getter
true
Has Setter
false
Description
Gets the LivingEntity that caused this Explosion.

For example:
If the Explosion was caused by TNT, it will return the PlayerEntity that placed it.
If the Explosion was caused by a Creeper or another Entity directly, it will return that Entity.
If the Explosion was caused by a Ghast fireball, it will return the Ghast.

If no Entity caused this Explosion (for example, if the Explosion was caused by TNT in a Desert Temple that
generated in the world), then null is returned.

You may need to cast the returned LivingEntity to not be nullable.
Name
playerKnockbackMap
Type
MCVector3d[MCPlayerEntity]
Has Getter
true
Has Setter
false
Description
Gets the player knockback map for this Explosion.

This map is only populated in Explosion#doExplosionA() so calling it before will return nothing.

This map is used to calculate the vectors that players around the explosion will be pushed back by.
Name
position
Type
MCVector3d
Has Getter
true
Has Setter
false
Description
No Description Provided