EntityPredicate
Link to 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.
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 Copyimport 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
Methoden
Link to methoden
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 CopyEntityPredicate.withCatType(catType as MCResourceLocation) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter catType | Type MCResource-Standort | Beschreibung The type of cat this entity should be. |
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 CopyEntityPredicate.withDataPredicate(builder as Consumer<NBTPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<NBTPredicate> | Beschreibung A consumer that will be used to configure the NBTPredicate. |
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 CopyEntityPredicate.withDistancePredicate(builder as Consumer<DistancePredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<DistancePredicate> | Beschreibung A consumer that will be used to configure the DistancePredicate. |
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 CopyEntityPredicate.withEffectPredicate(builder as Consumer<MobEffectsPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<MobEffectsPredicate> | Beschreibung A consumer that will be used to configure the MobEffectsPredicate. |
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 CopyEntityPredicate.withEffectPredicate(effect as MCPotionEffect, builder as Consumer<EffectData>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
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. |
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 CopyEntityPredicate.withEntityTypePredicate(builder as Consumer<EntityTypePredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<EntityTypePredicate> | Beschreibung A consumer that will be used to configure the EntityTypePredicate. |
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 CopyEntityPredicate.withEquipmentPredicate(builder as Consumer<EntityEquipmentPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<EntityEquipmentPredicate> | Beschreibung A consumer that will be used to configure the EntityEquipmentPredicate. |
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 CopyEntityPredicate.withFishingPredicate(builder as Consumer<FishingPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<FishingPredicate> | Beschreibung A consumer that will be used to configure the FishingPredicate. |
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 CopyEntityPredicate.withFlagsPredicate(builder as Consumer<EntityFlagsPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<EntityFlagsPredicate> | Beschreibung A consumer that will be used to configure the EntityFlagsPredicate. |
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 CopyEntityPredicate.withLocationPredicate(builder as Consumer<LocationPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<LocationPredicate> | Beschreibung A consumer that will be used to configure the LocationPredicate. |
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 CopyEntityPredicate.withPlayerPredicate(builder as Consumer<PlayerPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<PlayerPredicate> | Beschreibung A consumer that will be used to configure the PlayerPredicate. |
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 CopyEntityPredicate.withRiddenEntityPredicate(builder as Consumer<EntityPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter bauer | Type Consumer<EntityPredicate> | Beschreibung A consumer that will be used to configure the EntityPredicate. |
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 CopyEntityPredicate.withTargetedEntityPredicate(builder as Consumer<EntityPredicate>) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
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 CopyEntityPredicate.withTeam(team as string) as EntityPredicate
Parameter | Type | Beschreibung |
---|---|---|
Parameter team | Type string | Beschreibung The scoreboard team this entity should be a part of. |