Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

MCBlockState

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.blocks.MCBlockState;

Casters

Result typeIs Implicit
Result type
MCBlock
Is Implicit
true
Result type
string
Is Implicit
false

Methods

Checks if this BlockState can be replaced by leaves in tree growth.

Return Type: boolean

script.zs
// MCBlockState.canBeReplacedByLeaves(world as MCWorld, pos as BlockPos) as boolean
<blockstate:minecraft:grass>.canBeReplacedByLeaves(world, new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState

Checks if this BlockState can be replaced by logs in tree growth.

Return Type: boolean

script.zs
// MCBlockState.canBeReplacedByLogs(world as MCWorld, pos as BlockPos) as boolean
<blockstate:minecraft:grass>.canBeReplacedByLogs(world, new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState

Determines if Redstone can connect to this BlockState at the given position and (optional) side.

Returns: True if Redstone can connect to this BlockState. False otherwise.
Return Type: boolean

script.zs
MCBlockState.canConnectRedstone(world as MCWorld, pos as BlockPos, side as Direction) as boolean
ParameterTypeDescriptionOptionalDefaultValue
Parameter
world
Type
MCWorld
Description
A world object.
Optional
false
DefaultValue
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Optional
false
DefaultValue
Parameter
side
Type
Direction
Description
The side to check for.
Optional
true
DefaultValue

Checks if a specific entity type can spawn on this BlockState at the position in the world.

Returns: True if the entity type can spawn. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.canCreatureSpawn(world as MCWorld, pos as BlockPos, type as PlacementType, entityType as MCEntityType) as boolean
<blockstate:minecraft:grass>.canCreatureSpawn(world, new BlockPos(1, 2, 3), PlacementType.IN_WATER, <entitytype:minecraft:pig>);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position in the world.
Parameter
type
Type
PlacementType
Description
The PlaceMentType to check for.
Parameter
entityType
Type
MCEntityType
Description
The EntityType to check for.

Checks if the BlockState will drop from the given explosion at the given position.

Returns: True if this BlockState will drop. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.canDropFromExplosion(world as MCWorld, pos as BlockPos, explosion as Explosion) as boolean
<blockstate:minecraft:grass>.canDropFromExplosion(world, new BlockPos(1, 2, 3), Explosiotn.create(world, 1, 2, 3, 5, true, ExplosionMode.BREAK));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
explosion
Type
Explosion
Description
The Explosion to check against.

Determines if this BlockState can be destroyed by the Entity at the specific position.

Returns: True if the entity can destroy the BlockState. False otherwise.
Return Type: boolean

script.zs
MCBlockState.canEntityDestroy(world as MCWorld, pos as BlockPos, entity as MCEntity) as boolean
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
entity
Type
MCEntity
Description
The Entity that is trying to destroy the BlockState.

Checks whether the player can harvest the BlockState.

Returns: True if the player can harvest the block. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.canHarvestBlock(world as MCWorld, pos as BlockPos, player as MCPlayerEntity) as boolean
<blockstate:minecraft:grass>.canHarvestBlock(world, new BlockPos(1, 2, 3), player);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position to check at.
Parameter
player
Type
MCPlayerEntity
Description
The player that is trying to harvest the block.

Checks whether this BlockState can provide Redstone Power

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

script.zs
// MCBlockState.canProvidePower() as boolean
<blockstate:minecraft:grass>.canProvidePower();

Checks if this BlockState can stick to the other BlockState when pushed by a piston.

Returns: True if the BlockStatess stick when pushed by a piston. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.canStickTo(other as MCBlockState) as boolean
<blockstate:minecraft:grass>.canStickTo(<blockstate:minecraft:grass>);
ParameterTypeDescription
Parameter
other
Type
MCBlockState
Description
The BlockState check if it will stick against.

Gets a list of allowed values for a given property.

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

script.zs
// MCBlockState.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 direction of the bed. This can be called on any BlockState that has the HORIZONTAL_FACING property, not just beds.

The game WILL crash if you call this on a blockstate that doesn’t have the property, so make sure you check it before calling it!

Return Type: void

script.zs
// MCBlockState.getBedDirection(world as MCWorld, pos as BlockPos) as void
<blockstate:minecraft:grass>.getBedDirection(world, new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState

Gets the blockstate bracket handler syntax for this BlockState.

E.G. blockstate:minecraft:grass:snowy=true

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

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

Returns how much Experience this BlockState will drop when broken.

Returns: The amount of Experience that will drop when this BlockState is broken.
Return Type: int

script.zs
// MCBlockState.getExpDrop(world as MCWorld, pos as BlockPos, fortune as int, silktouch as int) as int
<blockstate:minecraft:grass>.getExpDrop(world, new BlockPos(1, 2, 3), 1, 0);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
fortune
Type
int
Description
The fortune level of the tool being used to break the block.
Parameter
silktouch
Type
int
Description
The silktouch level of the tool being used to break the block. This will most likely either be 0 or 1.

Gets the explosion resistance of the BlockState in the world for the given Explosion

Returns: The amount of the explosion that is absorbed.
Return Type: float

script.zs
// MCBlockState.getExplosionResistance(world as MCWorld, pos as BlockPos, explosion as Explosion) as float
<blockstate:minecraft:grass>.getExplosionResistance(world, new BlockPos(1, 2, 3), Explosiotn.create(world, 1, 2, 3, 5, true, ExplosionMode.BREAK));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState
Parameter
explosion
Type
Explosion
Description
The explosion object to check against.

Determines how fast fire spreads from this block. The higher the number the faster that fire will spread around the BlockState.

Returns: The spread speed of the BlockState.
Return Type: int

script.zs
MCBlockState.getFireSpreadSpeed(world as MCWorld, pos as BlockPos, face as Direction) as int
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
face
Type
Direction
Description
The face that the fire is coming from.

Gets the chance that fire will spread and consume this BlockState.

Values range from 0 - 300.

A value of 300 is a 100% chance, and 0 is a 0% chance.

Returns: A number between 0 and 300 dictating how flammable this BlockState is.
Return Type: int

script.zs
// MCBlockState.getFlammability(world as MCWorld, pos as BlockPos, face as Direction) as int
<blockstate:minecraft:grass>.getFlammability(world, new BlockPos(1, 2, 3), Direction.south);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
face
Type
Direction
Description
The face that the fire is coming from.

Gets the hardness of this BlockState.

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

script.zs
// MCBlockState.getHardness() as float
<blockstate:minecraft:grass>.getHardness();

Gets the harvest level of this BlockState.

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

script.zs
// MCBlockState.getHarvestLevel() as int
<blockstate:minecraft:grass>.getHarvestLevel();

Gets the ToolType of this BlockState.

Returns: The ToolType of this BlockState.
Return Type: ToolType?

script.zs
// MCBlockState.getHarvestTool() as ToolType?
<blockstate:minecraft:grass>.getHarvestTool();

Gets the light level of this BlockState

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

script.zs
// MCBlockState.getLightLevel() as int
<blockstate:minecraft:grass>.getLightLevel();

Gets the light value of the BlockState at the given position.

Returns: The light value of the BlockState at the position.
Return Type: int

script.zs
// MCBlockState.getLightValue(world as MCWorld, pos as BlockPos) as int
<blockstate:minecraft:grass>.getLightValue(world, new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world Object.
Parameter
pos
Type
BlockPos
Description
The position to check the light value of.

Gets the properties of this BlockState.

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

script.zs
// MCBlockState.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
// MCBlockState.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
MCBlockState.getPropertyValue(name as string) as string
ParameterTypeDescription
Parameter
name
Type
string
Description
”snowy”

Gets the slipperiness of the BlockState at the given location for the given entity (if one is given)

Returns: The slipperiness of the BlockState at the given BlockPos for the Entity.
Return Type: float

script.zs
// MCBlockState.getSlipperiness(world as MCWorld, pos as BlockPos, entity as MCEntity) as float
<blockstate:minecraft:grass>.getSlipperiness(world, new Blockpos(0,0,0);, entity);
ParameterTypeDescriptionOptionalDefaultValue
Parameter
world
Type
MCWorld
Description
A world object.
Optional
false
DefaultValue
Parameter
pos
Type
BlockPos
Description
The position to check at.
Optional
false
DefaultValue
Parameter
entity
Type
MCEntity
Description
The entity to work with.
Optional
true
DefaultValue

Checks whether this BlockState has the given property.

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

script.zs
// MCBlockState.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 has a MCTileEntity.

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

script.zs
// MCBlockState.hasTileEntity() as boolean
<blockstate:minecraft:grass>.hasTileEntity();

Determines if the block can be used to sleep.

Returns: True if the block allows sleeping.
Return Type: boolean

script.zs
// MCBlockState.isBed(world as MCWorld, pos as BlockPos, sleeper as MCLivingEntity) as boolean
<blockstate:minecraft:grass>.isBed(world, new BlockPos(1, 2, 3), entity);
ParameterTypeDescriptionOptionalDefaultValue
Parameter
world
Type
MCWorld
Description
A world object.
Optional
false
DefaultValue
Parameter
pos
Type
BlockPos
Description
The position to check at.
Optional
false
DefaultValue
Parameter
sleeper
Type
MCLivingEntity
Description
The Living Entity that is trying to sleep.
Optional
true
DefaultValue

Checks if the BlockState is burning at the given position.

Returns: True if the BlockState is burning a the given position.
Return Type: boolean

script.zs
// MCBlockState.isBurning(world as MCWorld, pos as BlockPos) as boolean
<blockstate:minecraft:grass>.isBurning(world, new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.

Determines if this BlockState can be used as the frame of a Conduit.

Returns: True if this BlockState can be used as a Conduit frame.
Return Type: boolean

script.zs
// MCBlockState.isConduitFrame(world as MCWorld, pos as BlockPos, conduitPosition as BlockPos) as boolean
<blockstate:minecraft:grass>.isConduitFrame(world, new BlockPos(1, 2, 3), new BlockPos(1, 5, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
conduitPosition
Type
BlockPos
Description
The Position of the Conduit.

Checks if the BlockState is “fertile” at the given position.

This will only ever return true if the BlockState is in the <tag:blocks:minecraft:farmland> tag and if it has the moisture state.

The game WILL crash if you call this on a blockstate that doesn’t have the property, so make sure you check it before calling it!

Returns: True if the BlockState is Fertile. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.isFertile(world as MCWorld, pos as BlockPos) as boolean
<blockstate:minecraft:grass>.isFertile(world, new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState

Checks if this BlockState is a fire source at the given position with the fire coming from the given direciton.

Returns: True if this BlockState is a fire source. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.isFireSource(world as MCWorld, pos as BlockPos, side as Direction) as boolean
<blockstate:minecraft:grass>.isFireSource(world, new BlockPos(1, 2, 3), Direction.east);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
side
Type
Direction
Description
The face that the fire is coming form.

Checks if this BlockState is flammable at the given position with the fire coming from the given direciton.

Returns: True if the BlockState if flammable. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.isFlammable(world as MCWorld, pos as BlockPos, face as Direction) as boolean
<blockstate:minecraft:grass>.isFlammable(world, new BlockPos(1, 2, 3), Direction.east);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
face
Type
Direction
Description
The face that the fire is coming from.

Checks if a Living Entity can use this block to climb like a ladder.

Returns: True if the entity can climb the block. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.isLadder(world as MCWorld, pos as BlockPos, entity as MCLivingEntity) as boolean
<blockstate:minecraft:grass>.isLadder(world, new BlockPos(1, 2, 3), entity);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position to check at.
Parameter
entity
Type
MCLivingEntity
Description
The entity that wants to climb the block.

Determins if this BlockState can be used as the frame of a Nether portal.

Returns: True if this BlockState can be used as a Nether portal frame. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.isPortalFrame(world as MCWorld, pos as BlockPos) as boolean
<blockstate:minecraft:grass>.isPortalFrame(world, new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the Blockstate.

Checks if the entity should handle movement on this BlockState like it handles movement on scaffolding.

Returns: True if this BlockState should act like scaffolding. False otherwise.
Return Type: boolean

script.zs
// MCBlockState.isScaffolding(entity as MCLivingEntity) as boolean
<blockstate:minecraft:grass>.isScaffolding(entity);
ParameterTypeDescription
Parameter
entity
Type
MCLivingEntity
Description
The entity that is being checked against.

Checks if this BlockState is a Slime Block.

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

script.zs
// MCBlockState.isSlime() as boolean
<blockstate:minecraft:grass>.isSlime();

Checks whether this BlockState is solid.

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

script.zs
// MCBlockState.isSolid() as boolean
<blockstate:minecraft:grass>.isSolid();

Checks if this BlockState is sticky.

This is used to determine if the block should pull or push adjacent blocks when pushed / pulled by a piston. For example, Slime Blocks are sticky blocks.

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

script.zs
// MCBlockState.isSticky() as boolean
<blockstate:minecraft:grass>.isSticky();

Checks if the given ToolType is effective against this BlockState.

Returns: True if the ToolType is effective. False otherwise.
Return Type: boolean

script.zs
MCBlockState.isToolEffective(tool as ToolType) as boolean
ParameterTypeDescription
Parameter
tool
Type
ToolType
Description
The ToolType to check for.

Marks the block as “occupied”, this is only supported on blocks that have the “occupied” BlockState property.

The game WILL crash if you call this on a blockstate that doesn’t have the property, so make sure you check it before calling it!

Return Type: void

script.zs
// MCBlockState.setBedOccupied(world as MCWorld, pos as BlockPos, sleeper as MCLivingEntity, occupied as boolean) as void
<blockstate:minecraft:grass>.setBedOccupied(world, new BlockPos(1, 2, 3), livingEntity, true);
ParameterTypeDescription
Parameter
world
Type
MCWorld
Description
A world object.
Parameter
pos
Type
BlockPos
Description
The position of the BlockState.
Parameter
sleeper
Type
MCLivingEntity
Description
The LivingEntity that is occupying the bed.
Parameter
occupied
Type
boolean
Description
If the bed is occupied or not.

Sets the hardness of this BlockState.

Return Type: void

script.zs
// MCBlockState.setHardness(hardness as float) as void
<blockstate:minecraft:grass>.setHardness(2.4f);
ParameterTypeDescription
Parameter
hardness
Type
float
Description
the new hardness of this BlockState

Checks whether this BlockState ticks randomly.

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

script.zs
// MCBlockState.ticksRandomly() as boolean
<blockstate:minecraft:grass>.ticksRandomly();

Sets a block property based on it’s name.

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

script.zs
// MCBlockState.withProperty(name as string, value as string) as MCBlockState
<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
MCBlock
Has Getter
true
Has Setter
false
Description
Gets the base MCBlock of this BlockState.

The MCBlock will not contain any of the properties of this BlockState.
Name
canProvidePower
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState can provide Redstone Power
Name
commandString
Type
string
Has Getter
true
Has Setter
false
Description
Gets the blockstate bracket handler syntax for this BlockState.

E.G.

blockstate:minecraft:grass:snowy=true
Name
hardness
Type
float
Has Getter
true
Has Setter
true
Description
Gets the hardness of this BlockState.
Name
harvestLevel
Type
int
Has Getter
true
Has Setter
false
Description
Gets the harvest level of this BlockState.
Name
harvestTool
Type
ToolType?
Has Getter
true
Has Setter
false
Description
Gets the ToolType of this BlockState.
Name
hasTileEntity
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState has a MCTileEntity.
Name
isSlime
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if this BlockState is a Slime Block.
Name
isSolid
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState is solid.
Name
isSticky
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if this BlockState is sticky.

This is used to determine if the block should pull or push adjacent blocks when pushed / pulled by a piston.
For example, Slime Blocks are sticky blocks.
Name
lightLevel
Type
int
Has Getter
true
Has Setter
false
Description
Gets the light level 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
ticksRandomly
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks whether this BlockState ticks randomly.