DamageSourcePredicate

Link to damagesourcepredicate

Represents a predicate for a DamageSource.

The predicate can be used to match against a various set of types that identify the damage source type and characteristics, such as being caused by magic or bypassing invulnerability. Moreover, the predicate can also check for specific properties of the entity that caused the damage or the direct entity (refer to TargetedEntity for the semantic difference), via EntityPredicates.

By default, any damage source will pass this predicate's checks.

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.predicate.DamageSourcePredicate;

Extending AnyDefaultingVanillaWrappingPredicate

Link to extending-anydefaultingvanillawrappingpredicate

DamageSourcePredicate extends AnyDefaultingVanillaWrappingPredicate. That means all methods available in AnyDefaultingVanillaWrappingPredicate are also available in DamageSourcePredicate

Name: withArmorBypass

Indicates that the damage source must be able to bypass armor protection (for example, suffocation)

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withArmorBypass() as DamageSourcePredicate

myDamageSourcePredicate.withArmorBypass();

Link to withDirectEntityPredicate

Name: withDirectEntityPredicate

Creates and sets the EntityPredicate that will be used to check the entity that directly caused damage.

For the specific semantic meaning, refer to TargetedEntity.

Any changes that have been made to the entity predicate previously, if any, will be discarded.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
DamageSourcePredicate.withDirectEntityPredicate(builder as Consumer<EntityPredicate>) as DamageSourcePredicate
ParameterTypeDescription
Parameter
builder
Type
Consumer<EntityPredicate>
Description
A consumer used to configure the EntityPredicate.

Link to withExplosionSource

Name: withExplosionSource

Indicates that the damage must have been caused by an explosion.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withExplosionSource() as DamageSourcePredicate

myDamageSourcePredicate.withExplosionSource();

Name: withFireSource

Indicates that the damage must have been caused by fire.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withFireSource() as DamageSourcePredicate

myDamageSourcePredicate.withFireSource();

Link to withInvulnerabilityBypass

Name: withInvulnerabilityBypass

Indicates that the damage source must be able to bypass invulnerability (for example, void damage).

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withInvulnerabilityBypass() as DamageSourcePredicate

myDamageSourcePredicate.withInvulnerabilityBypass();

Link to withLightningSource

Name: withLightningSource

Indicates that the damage must have been caused by a lightning strike.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withLightningSource() as DamageSourcePredicate

myDamageSourcePredicate.withLightningSource();

Name: withMagicBypass

Indicates that the damage source must be able to bypass magic protection (for example, starvation).

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withMagicBypass() as DamageSourcePredicate

myDamageSourcePredicate.withMagicBypass();

Name: withMagicSource

Indicates that the damage must have been caused by magic sources.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withMagicSource() as DamageSourcePredicate

myDamageSourcePredicate.withMagicSource();

Link to withProjectileSource

Name: withProjectileSource

Indicates that the damage must have been caused by a projectile.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withProjectileSource() as DamageSourcePredicate

myDamageSourcePredicate.withProjectileSource();

Link to withSourceEntityPredicate

Name: withSourceEntityPredicate

Creates and sets the EntityPredicate that will be used to check the entity that caused damage.

For the specific semantic meaning, refer to TargetedEntity.

Any changes that have been made to the entity predicate previously, if any, will be discarded.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
DamageSourcePredicate.withSourceEntityPredicate(builder as Consumer<EntityPredicate>) as DamageSourcePredicate
ParameterTypeDescription
Parameter
builder
Type
Consumer<EntityPredicate>
Description
A consumer used to configure the EntityPredicate.

Link to withoutArmorBypass

Name: withoutArmorBypass

Indicates that the damage source must not be able to bypass armor protection.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutArmorBypass() as DamageSourcePredicate

myDamageSourcePredicate.withoutArmorBypass();

Link to withoutExplosionSource

Name: withoutExplosionSource

Indicates that the damage must not have been caused by an explosion.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutExplosionSource() as DamageSourcePredicate

myDamageSourcePredicate.withoutExplosionSource();

Link to withoutFireSource

Name: withoutFireSource

Indicates that the damage must not have been caused by fire.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutFireSource() as DamageSourcePredicate

myDamageSourcePredicate.withoutFireSource();

Link to withoutInvulnerabilityBypass

Name: withoutInvulnerabilityBypass

Indicates that the damage source must not be able to bypass invulnerability.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutInvulnerabilityBypass() as DamageSourcePredicate

myDamageSourcePredicate.withoutInvulnerabilityBypass();

Link to withoutLightningSource

Name: withoutLightningSource

Indicates that the damage must not have been caused by a lightning strike.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutLightningSource() as DamageSourcePredicate

myDamageSourcePredicate.withoutLightningSource();

Link to withoutMagicBypass

Name: withoutMagicBypass

Indicates that the damage source must not be able to bypass magic protection.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutMagicBypass() as DamageSourcePredicate

myDamageSourcePredicate.withoutMagicBypass();

Link to withoutMagicSource

Name: withoutMagicSource

Indicates that the damage must not have been caused by magic sources.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutMagicSource() as DamageSourcePredicate

myDamageSourcePredicate.withoutMagicSource();

Link to withoutProjectileSource

Name: withoutProjectileSource

Indicates that the damage must not have been caused by a projectile.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: DamageSourcePredicate

ZenScript
Copy
// DamageSourcePredicate.withoutProjectileSource() as DamageSourcePredicate

myDamageSourcePredicate.withoutProjectileSource();