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 Copyimport 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
Methods
Link to methods
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();
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 CopyDamageSourcePredicate.withDirectEntityPredicate(builder as Consumer<EntityPredicate>) as DamageSourcePredicate
Parameter | Type | Description |
---|---|---|
Parameter builder | Type Consumer<EntityPredicate> | Description A consumer used to configure the EntityPredicate. |
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();
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();
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();
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();
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 CopyDamageSourcePredicate.withSourceEntityPredicate(builder as Consumer<EntityPredicate>) as DamageSourcePredicate
Parameter | Type | Description |
---|---|---|
Parameter builder | Type Consumer<EntityPredicate> | Description A consumer used to configure the EntityPredicate. |
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();
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();
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();
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();
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();
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();
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();
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();