Importing the class

Link to 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.world.Explosion;
ZenScript
Copy
new Explosion(level as Level, entity as Level, x as double, y as double, z as double, size as float, causesFire as boolean, mode as ExplosionBlockInteraction) as Explosion
new Explosion(level, player, 0, 0, 0, 1.0, true, <constant:minecraft:explosion/blockinteraction:destroy>);
ParameterTypeDescription
Parameter
level
Type
Level
Description
The level to spawn the explosion in
Parameter
entity
Type
Level
Description
The entity that spawned the explosion
Parameter
x
Type
double
Description
The x position.
Parameter
y
Type
double
Description
The y position.
Parameter
z
Type
double
Description
The z position.
Parameter
size
Type
float
Description
How big is the explosion
Parameter
causesFire
Type
boolean
Description
Does the explosion cause fire
Parameter
mode
Type
ExplosionBlockInteraction
Description
How should the explosion interact with blocks

Name: clearToBlow

Clears the affected block positions of this Explosion.

ZenScript
Copy
// Explosion.clearToBlow()

myExplosion.clearToBlow();

Name: explode

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

ZenScript
Copy
// Explosion.explode()

myExplosion.explode();

Link to finalizeExplosion

Name: finalizeExplosion

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

ZenScript
Copy
// Explosion.finalizeExplosion(spawnParticles as boolean)

myExplosion.finalizeExplosion(true);
ParameterTypeDescription
Parameter
spawnParticles
Type
boolean
Description
Should particles be spawned.

Name: getDamageSource

Gets the damage source of this Explosion.

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

ZenScript
Copy
// Explosion.getDamageSource() as DamageSource

myExplosion.getDamageSource();

Name: getHitPlayers

Gets the player knockback map for this Explosion.

This map is only populated in Explosion#explode() 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: Vec3[Player]

ZenScript
Copy
// Explosion.getHitPlayers() as Vec3[Player]

myExplosion.getHitPlayers();

Link to getIndirectSourceEntity

Name: getIndirectSourceEntity

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: LivingEntity?

ZenScript
Copy
// Explosion.getIndirectSourceEntity() as LivingEntity?

myExplosion.getIndirectSourceEntity();

Name: getToBlow

Return Type: stdlib.List<BlockPos>

ZenScript
Copy
// Explosion.getToBlow() as stdlib.List<BlockPos>

myExplosion.getToBlow();
NameTypeHas GetterHas SetterDescription
Name
damageSource
Type
DamageSource
Has Getter
true
Has Setter
false
Description
Gets the damage source of this Explosion.
Name
indirectSourceEntity
Type
LivingEntity?
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
Vec3[Player]
Has Getter
true
Has Setter
false
Description
Gets the player knockback map for this Explosion.

This map is only populated in Explosion#explode() 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
toBlow
Type
stdlib.List<BlockPos>
Has Getter
true
Has Setter
false
Description
​