BlockPredicate

Represents a predicate for a MCBlock.

This predicate will match a block state with either the given MCBlock or block tag (MCTag<T>), with the second check taking precedence over the first if they are both present. If this comparison succeeds, then the predicate may also verify additional block state properties via the supplied StatePropertiesPredicate or specific parts of the NBT data of the block entity associated to the state via a NBTPredicate.

By default, this predicate allows any block state to pass the checks without restrictions.

Importing the class

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

Extending AnyDefaultingVanillaWrappingPredicate

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

Methods

withBlock

Sets the block that this predicate should match.

If a tag to match against has already been set, then the tag check will take precedence over this check.

Return Type: BlockPredicate

ZenScript
Copy
BlockPredicate.withBlock(block as MCBlock) as BlockPredicate
ParameterTypeDescription
blockMCBlockThe block the predicate should match.

withBlockTag

Sets the tag that this predicate should use for matching.

The predicate will successfully match only if the supplied block state's block is contained within the given tag.

Specifying both a tag and a block to match against will make the tag take precedence over the block.

Return Type: BlockPredicate

ZenScript
Copy
BlockPredicate.withBlockTag(blockTag as MCTag<MCBlock>) as BlockPredicate
ParameterTypeDescription
blockTagMCTag<MCBlock>The tag the predicate should use for matching.

withDataPredicate

Creates and sets the NBTPredicate that will be matched against the block entity's data.

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

Return Type: BlockPredicate

ZenScript
Copy
BlockPredicate.withDataPredicate(builder as Consumer<NBTPredicate>) as BlockPredicate
ParameterTypeDescription
costruttoreConsumer<NBTPredicate>A consumer that will be used to configure the NBTPredicate.

withStatePropertiesPredicate

Creates and sets the StatePropertiesPredicate that will be matched against the block state's properties.

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

Return Type: BlockPredicate

ZenScript
Copy
BlockPredicate.withStatePropertiesPredicate(builder as Consumer<StatePropertiesPredicate>) as BlockPredicate
ParameterTypeDescription
costruttoreConsumer<StatePropertiesPredicate>A consumer that will be used to configure the StatePropertiesPredicate.