IBlockState

An IBlockState object represents a block’s current state.

Importing the package

It might be required for you to import the package if you encounter any issues, so better be safe than sorry and add the import.
import crafttweaker.block.IBlockState;

Calling an IBlockState

There are several methods that return an IBlockState

Resolving an IBlockState At Runtime

There may be times at which your script may rely on interaction with a block from a mod that has not been loaded yet, such as inside block events in ContentTweaker or another pre-init script loader. If you attempt to use a Bracket Handler for a block that has not yet been registered, the handler will fail to resolve and your script will not work.

To avoid this, you can use the static IBlockState.getBlockState() method to resolve an IBlockState at runtime.

static getBlockState

static IBlockState getBlockState(String blockname, String... properties) Parameters:

Returns an IBlockState of the specified blockname with the specified properties, or the default blockstate if no properties are specified.

Extending IBlockProperties

IBlockState extends IBlockProperties. That means that all methods that are available to IBlockProperties objects are also available to IBlockState objects.

Extending IBlockStateMatcher

IBlockState extends IBlockStateMatcher. That means that all methods that are available to IBlockStateMatcher objects are also available to IBlockState objects.

ZenMethods and ZenGetters

ZenGetter Return Type Description
block IBlock Returns the refered block
meta int Returns the refered block’s metadata
commandString String Returns a possible Bracket Handler for this state

ZenMethods

isReplacable

boolean isReplaceable(IWorld world, IBlockPos pos);
Parameters:

Returns a boolean that sais whether the block can be replaced or not.

Getting or changing Properties

You can get a list of all registered properties, either as list with all property names or as map that maps the properties to their value.
You can also check which values are possible for a given property name.
You can also use withProperty to create a new IBlockState object with that property changed.

List<String> getPropertyNames();
String getPropertyValue(String name);
List<String> getAllowedValuesForProperty(String name);

IBlockState withProperty(String name, String value);

Comparing two IBlockState objects

You can either use int compare(IBlockState other); or the ZenCompare Tokens == !=.
The return different types though:

Getting an explicit Blockstate Matcher

Returns an IBlockStateMatcher that matches the given block.

IBlockStateMatcher matchBlock();