Trait CriterionContext
pub trait CriterionContext {
// Required methods
fn conditions_json(&self) -> String;
fn item(&self, key: &str, stack: &ItemStack) -> bool;
}Expand description
One open criterion being tested during PlayerRef::trigger_criterion.
The game lends this resource only for CriterionTest::test. Its private world context is
the target player’s own level; a mod cannot retain the resource after the test returns.
The same native implementation reads conditions and evaluates item predicates for both
build targets.
Required Methods§
fn conditions_json(&self) -> String
fn conditions_json(&self) -> String
The criterion’s conditions as owned JSON ("null" when absent). The game’s test of
its player predicate follows the mod’s test, as vanilla’s SimpleInstance.player.
fn item(&self, key: &str, stack: &ItemStack) -> bool
fn item(&self, key: &str, stack: &ItemStack) -> bool
Whether stack passes the item predicate under key in the conditions, as the game’s
own triggers read an ItemPredicate: items (an id, a list or a #tag), count, the
potion_contents and damage components, and the enchantments and damage
predicates; other components and predicates aren’t checked. A missing key passes, as
an absent Optional<ItemPredicate> does. Tag lookups use the target player’s world.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".