Home Commands Examples Getting Started With Scripts Global Keywords

BlockState

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.

script.zs
import crafttweaker.api.block.BlockState;

Casters

Result TypeIs Implicit
Result Type
Block
Is Implicit
true
Result Type
BlockIngredient
Is Implicit
true
Result Type
string
Is Implicit
false

Methods

Return Type: string

script.zs
// BlockState.asString() as string
<blockstate:minecraft:grass>.asString();

Checks whether this BlockState is solid.

Returns: True if this BlockState is solid. False otherwise.
Return Type: boolean

script.zs
// BlockState.canOcclude() as boolean
<blockstate:minecraft:grass>.canOcclude();

Gets a list of allowed values for a given property.

Returns: a List of allowed values.
Return Type: stdlib.List<string>

script.zs
// BlockState.getAllowedValuesForProperty(name as string) as stdlib.List<string>
<blockstate:minecraft:grass>.getAllowedValuesForProperty("snowy");
ParameterTypeDescription
Parameter
name
Type
string
Description
The name of the property to find the allowed values for.

Gets the blockstate bracket handler syntax for this BlockState.

E.G.

Returns: The blockstate bracket handler syntax for this BlockState.
Return Type: string

script.zs
// BlockState.getCommandString() as string
<blockstate:minecraft:grass>.getCommandString();

Gets the hardness of this BlockState.

Returns: The hardness of this BlockState.
Return Type: float

script.zs
// BlockState.getDestroySpeed() as float
<blockstate:minecraft:grass>.getDestroySpeed();

Gets the light level of this BlockState

Returns: The light level of this BlockState.
Return Type: int

script.zs
// BlockState.getLightEmission() as int
<blockstate:minecraft:grass>.getLightEmission();

Gets the properties of this BlockState.

Returns: a Map of the properties on this BlockState.
Return Type: string[string]

script.zs
// BlockState.getProperties() as string[string]
<blockstate:minecraft:grass>.getProperties();

Gets the names of the properties of this BlockState.

Returns: the List of the names of the BlockStates’s properties.
Return Type: stdlib.List<string>

script.zs
// BlockState.getPropertyNames() as stdlib.List<string>
<blockstate:minecraft:grass>.getPropertyNames();

Gets the value of the given property.

Returns: The value of the property on this BlockState.
Return Type: string

script.zs
BlockState.getPropertyValue(name as string) as string
ParameterTypeDescription
Parameter
name
Type
string
Description
”snowy”

Return Type: SoundType

script.zs
// BlockState.getSoundType() as SoundType
<blockstate:minecraft:grass>.getSoundType();

Checks whether this BlockState has a BlockEntity.

Returns: True if this BlockState has a BlockEntity. False otherwise.
Return Type: boolean

script.zs
// BlockState.hasBlockEntity() as boolean
<blockstate:minecraft:grass>.hasBlockEntity();

Checks whether this BlockState has the given property.

Returns: True if this BlockState has the property. False otherwise.
Return Type: boolean

script.zs
// BlockState.hasProperty(name as string) as boolean
<blockstate:minecraft:grass>.hasProperty("snowy");
ParameterTypeDescription
Parameter
name
Type
string
Description
the name of the property to check.

Checks whether this BlockState ticks randomly.

Returns: True if this BlockState ticks randomly. False otherwise.
Return Type: boolean

script.zs
// BlockState.isRandomlyTicking() as boolean
<blockstate:minecraft:grass>.isRandomlyTicking();

Checks whether this BlockState can provide Redstone Power

Returns: True if this BlockState can provide Redstone Power. False otherwise.
Return Type: boolean

script.zs
// BlockState.isSignalSource() as boolean
<blockstate:minecraft:grass>.isSignalSource();

Return Type: BlockState

script.zs
BlockState.rotate(rotation as Rotation) as BlockState
ParameterType
Parameter
rotation
Type
Rotation

Sets the destroy speed of this BlockState.

script.zs
// BlockState.setDestroySpeed(destroySpeed as float)
<blockstate:minecraft:grass>.setDestroySpeed(2.4f);
ParameterTypeDescription
Parameter
destroySpeed
Type
float
Description
the new destroy speed of this BlockState

Sets a block property based on it’s name.

Returns: This BlockState with the new property value.
Return Type: BlockState

script.zs
// BlockState.withProperty(name as string, value as string) as BlockState
<blockstate:minecraft:grass>.withProperty("snowy", "true");
ParameterTypeDescription
Parameter
name
Type
string
Description
The name of the property to set.
Parameter
value
Type
string
Description
The new value of the property.

Properties

NameTypeHas GetterHas SetterDescription
Name
block
Type
Block
Has Getter
true
Has Setter
false
Description
Gets the base Block of this BlockState.

The Block will not contain any of the properties of this BlockState.
Name
canOcclude
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState is solid.
Name
commandString
Type
string
Has Getter
true
Has Setter
false
Description
Gets the blockstate bracket handler syntax for this BlockState.

E.G.
Name
destroySpeed
Type
float
Has Getter
true
Has Setter
true
Description
Gets the hardness of this BlockState.
Name
hasBlockEntity
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState has a BlockEntity.
Name
isRandomlyTicking
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState ticks randomly.
Name
isSignalSource
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState can provide Redstone Power
Name
lightEmission
Type
int
Has Getter
true
Has Setter
false
Description
Gets the light level of this BlockState
Name
properties
Type
string[string]
Has Getter
true
Has Setter
false
Description
Gets the properties of this BlockState.
Name
propertyNames
Type
stdlib.List<string>
Has Getter
true
Has Setter
false
Description
Gets the names of the properties of this BlockState.
Name
soundType
Type
SoundType
Has Getter
true
Has Setter
false
Description