An IBlockStateMatcher object can be used to match an IBlockState object against a set of requirements or a set of matching blockstates.

Importing the package

It might be required for you to import the package if you encounter any issues (like casting an Array or using the static .create() method), so better be safe than sorry and add the import.
import crafttweaker.block.IBlockStateMatcher;

Matching a Specific IBlockState

Every IBlockState is also an IBlockStateMatcher which matches only to itself.

Matching Any Block State for a Specific Block

You can use IBlockState‘s matchBlock() method to create an IBlockStateMatcher that matches any possible blockstate for that block.

Calling an IBlockStateMatcher

There are several methods that return an IBlockStateMatcher

Compound Matchers

When using OR (|) to combine IBlockStateMatchers, the resulting IBlockStateMatcher is no longer tied to one specific underlying block, as it would be with an IBlockState or an IBlockStateMatcher created using the IBlockStateMatcher.create() method. Instead, the matcher matches any blockstate which would have been matched by any of the combined matchers.

Because this blockstate is not tied to a specific block, it is not possible to use the withMatchedValuesForProperty() method to retrieve another IBlockStateMatcher.

static create

static IBlockStateMatcher create(IBlockState... blockStates); Parameters:

Returns an IBlockStateMatcher to match the specified blockstate(s).



boolean matches(IBlockState blockState);

Returns a boolean that represents whether the blockstate matched this matcher’s requirements.
You can also use A has B that represents A.matches(B).

Get or add allowed properties

(These methods are only allowed on non-compound IBlockStateMatcher instances)

IBlockStateMatcher withMatchedValuesForProperty(String name, String... values);
List<String> getMatchedValuesForProperty(String name);
Map<String, List<String>> getMatchedProperties();


Returns a new IBlockStateMatcher with the same property requirements as this IBlockStateMatcher with the exception of the specified property name, which will now allow any of the specified values as a matching input.


Collection<IBlockState> getMatchingBlockStates(); Returns a collection of every IBlockState with any combination of properties that match this IBlockStateMatcher. This list may contain blockstates that are not possible to get through normal gameplay means. (Ex: IBlockStateMatcher.create(<blockstate:minecraft:log>) will return an IBlockStateMatcher that matches to logs with property axis=none, having bark textures on all 6 sides.)

Check if a BlockState is a compound State

boolean isCompound()

Does what you’d expect.

Get a commandString representation

ZenGetter commandString

Returns a Bracket Handler expression string, if needed paired with withMatchedValueForProperty() calls.
Keep in mind though, that the returned method calls do not have "" around the parameters.
So if you wanted to copy that result, you’d need to manually add them to the arguments!