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.

Diese Klasse importieren

Link to diese-klasse-importieren

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

Link to extending-anydefaultingvanillawrappingpredicate

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

Name: 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
ParameterTypeBeschreibung
Parameter
catType
Type
MCResource-Standort
Beschreibung
The type of cat this entity should be.

Link to withDataPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<NBTPredicate>
Beschreibung
A consumer that will be used to configure the NBTPredicate.

Link to withDistancePredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<DistancePredicate>
Beschreibung
A consumer that will be used to configure the DistancePredicate.

Link to withEffectPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<MobEffectsPredicate>
Beschreibung
A consumer that will be used to configure the MobEffectsPredicate.

Link to withEffectPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
effect
Type
MCPotionEffect
Beschreibung
The effect that should be present on the entity.
Parameter
bauer
Type
Consumer<EffectData>
Beschreibung
A consumer that will be used to configure and provide the effect's data.

Link to withEntityTypePredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<EntityTypePredicate>
Beschreibung
A consumer that will be used to configure the EntityTypePredicate.

Link to withEquipmentPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<EntityEquipmentPredicate>
Beschreibung
A consumer that will be used to configure the EntityEquipmentPredicate.

Link to withFishingPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<FishingPredicate>
Beschreibung
A consumer that will be used to configure the FishingPredicate.

Link to withFlagsPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<EntityFlagsPredicate>
Beschreibung
A consumer that will be used to configure the EntityFlagsPredicate.

Link to withLocationPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<LocationPredicate>
Beschreibung
A consumer that will be used to configure the LocationPredicate.

Link to withPlayerPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<PlayerPredicate>
Beschreibung
A consumer that will be used to configure the PlayerPredicate.

Link to withRiddenEntityPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<EntityPredicate>
Beschreibung
A consumer that will be used to configure the EntityPredicate.

Link to withTargetedEntityPredicate

Name: 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
ParameterTypeBeschreibung
Parameter
bauer
Type
Consumer<EntityPredicate>
Beschreibung
A consumer that will be used to configure the EntityPredicate.

Name: 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
ParameterTypeBeschreibung
Parameter
team
Type
string
Beschreibung
The scoreboard team this entity should be a part of.