EntityPredicate

Represents a predicate for an MCEntity.

This predicate leverages many children predicates to check for the many entity parameters. In fact, this predicate can be used to check an entity's type via an EntityTypePredicate, along with the distance from a certain position via DistancePredicate. The predicate is also able to check whether the entity is in a certain location using a LocationPredicate and whether there are potion effects currently active (MobEffectsPredicate). The entity's internal NBT data can also be checked with an NBTPredicate along with its status flags (EntityFlagsPredicate) and equipment (EntityEquipmentPredicate). The entity can also be checked for its team, if available, and for the entity that is currently riding or targeting for its attacks, via additional entity predicates.

Moreover, the predicate provides additional specialization for specific types of entities such as players (PlayerPredicate), cats (by allowing to query their type), and fishing hooks (FishingPredicate). If any of these specialization is added, then the predicate will also ensure that the entity type is applicable for that specific specialization (e.g., if a player-only predicate is specified, this predicate will only pass if the entity is a player).

By default, any entity will pass this check, without caring about any of its properties.

Импорт класса

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.EntityPredicate;

Extending AnyDefaultingVanillaWrappingPredicate

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

Methods

withCatType

Sets the type of cat this entity should be.

As a side effect of this method, this entity predicate will require the entity to be a cat, failing the check otherwise.

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withCatType(catType as MCResourceLocation) as EntityPredicate
ПараметрТипDescription
catTypeРасположение MCResource-ресурсовThe type of cat this entity should be.
withDataPredicate

Creates and sets the NBTPredicate that will be used to match the entity's NBT data.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withDataPredicate(builder as Consumer<NBTPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<NBTPredicate>A consumer that will be used to configure the NBTPredicate.
withDistancePredicate

Creates and sets the DistancePredicate that will be used to match the entity's distance from a point.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withDistancePredicate(builder as Consumer<DistancePredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<DistancePredicate>A consumer that will be used to configure the DistancePredicate.
withEffectPredicate

Creates and sets the MobEffectsPredicate that will be used to match the entity's current potion effects.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withEffectPredicate(builder as Consumer<MobEffectsPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<MobEffectsPredicate>A consumer that will be used to configure the MobEffectsPredicate.
withEffectPredicate

Sets the effect that should be present on the entity.

The effect should also match the data that gets configured in the EffectData predicate.

Any changes that have been previously made to the effect predicate, if any, are discarded. Any other effects that have been added using this method are also discarded, keeping only the currently specified one.

Returns: This predicate for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withEffectPredicate(effect as MCPotionEffect, builder as Consumer<EffectData>) as EntityPredicate
ПараметрТипDescription
effectMCPotionEffectThe effect that should be present on the entity.
конструкторConsumer<EffectData>A consumer that will be used to configure and provide the effect's data.
withEntityTypePredicate

Creates and sets the EntityTypePredicate that will be used to match the entity's type.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withEntityTypePredicate(builder as Consumer<EntityTypePredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<EntityTypePredicate>A consumer that will be used to configure the EntityTypePredicate.
withEquipmentPredicate

Creates and sets the EntityEquipmentPredicate that will be used to match the entity's equipment.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withEquipmentPredicate(builder as Consumer<EntityEquipmentPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<EntityEquipmentPredicate>A consumer that will be used to configure the EntityEquipmentPredicate.
withFishingPredicate

Creates and sets the FishingPredicate that will be used as specialization for fishing hooks.

As a side effect of this method, this entity predicate will require the entity to be a fishing hook, failing the check otherwise.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withFishingPredicate(builder as Consumer<FishingPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<FishingPredicate>A consumer that will be used to configure the FishingPredicate.
withFlagsPredicate

Creates and sets the EntityFlagsPredicate that will be used to match the entity's status flags.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withFlagsPredicate(builder as Consumer<EntityFlagsPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<EntityFlagsPredicate>A consumer that will be used to configure the EntityFlagsPredicate.
withLocationPredicate

Creates and sets the LocationPredicate that will be used to match the entity's location.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withLocationPredicate(builder as Consumer<LocationPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<LocationPredicate>A consumer that will be used to configure the LocationPredicate.
withPlayerPredicate

Creates and sets the PlayerPredicate that will be used as specialization for players.

As a side effect of this method, this entity predicate will require the entity to be a player, failing the check otherwise.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withPlayerPredicate(builder as Consumer<PlayerPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<PlayerPredicate>A consumer that will be used to configure the PlayerPredicate.
withRiddenEntityPredicate

Creates and sets the EntityPredicate that will be used for the entity that is being ridden by this entity.

As a side effect of this method, this entity predicate will require the entity to be riding something, failing the check otherwise.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withRiddenEntityPredicate(builder as Consumer<EntityPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<EntityPredicate>A consumer that will be used to configure the EntityPredicate.
withTargetedEntityPredicate

Creates and sets the EntityPredicate that will be used for the entity that is being targeted for attacks by this entity.

As a side effect of this method, this entity predicate will require the entity to be attacking something, failing the check otherwise.

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

Returns: The predicate itself for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withTargetedEntityPredicate(builder as Consumer<EntityPredicate>) as EntityPredicate
ПараметрТипDescription
конструкторConsumer<EntityPredicate>A consumer that will be used to configure the EntityPredicate.
withTeam

Sets the scoreboard team this entity should be a part of.

Returns: This predicate for chaining.
Return Type: EntityPredicate

ZenScript
Copy
EntityPredicate.withTeam(team as string) as EntityPredicate
ПараметрТипDescription
teamstringThe scoreboard team this entity should be a part of.