EntityProperties

Builder to create an 'EntityProperties' loot condition.

This condition checks the LootContext for an MCEntity that matches the targeted one, specified via TargetedEntity, along with some additional properties like world and origin. The entity, if present, is matched against an EntityPredicate which will be used to determine entity-specific properties.

The condition passes if and only if there exists a valid entity to target and the predicate matches.

A valid 'EntityProperties' loot condition has to specify a targeted entity. The predicate, on the other hand, is optional: a lack of predicate means that the condition will simply check for the presence of the targeted entity.

导入相关包

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.loot.conditions.vanilla.EntityProperties;

已实现的接口

EntityProperties implements the following interfaces. That means all methods defined in these interfaces are also available in EntityProperties

方法

withPredicate

Creates and sets the EntityPredicate that will be matched against the targeted entity.

Any changes that have already been made to the predicate will be overwritten, effectively replacing the previous predicate, if any.

This parameter is optional.

Return Type: EntityProperties

ZenScript
Copy
EntityProperties.withPredicate(builder as Consumer<EntityPredicate>) as EntityProperties
参数类型描述
生成器Consumer<EntityPredicate>A consumer that will be used to configure the EntityPredicate.

withTargetedEntity

Sets the entity that should be targeted by the loot condition.

Refer to TargetedEntity for a full list and their respective meaning.

This parameter is required.

Return Type: EntityProperties

ZenScript
Copy
EntityProperties.withTargetedEntity(entity as TargetedEntity) as EntityProperties
参数类型描述
entityTargetedEntityThe entity that should be targeted.