Home Commands Examples Getting Started With Scripts Global Keywords

Block

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

Implemented Interfaces

Block implements the following interfaces. That means all methods defined in these interfaces are also available in Block

Casters

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

Methods

Gets the Item representation of this Block.

NOTE: Not all Blocks have Items, for instance, a Lit Redstone Lamp does not have an Item.

Returns: The Item representation of this Block.
Return Type: ItemDefinition

script.zs
// Block.asItem() as ItemDefinition
<block:minecraft:grass_block>.asItem();

Gets the block bracket handler syntax for this Block.

E.G.

Returns: The block bracket handler syntax for this Block.
Return Type: string

script.zs
// Block.getCommandString() as string
<block:minecraft:grass_block>.getCommandString();

Gets the default BlockState of this Block.

Returns: The default BlockState of this Block.
Return Type: BlockState

script.zs
// Block.getDefaultState() as BlockState
<block:minecraft:grass_block>.getDefaultState();

Gets the translation key that is used to localize this Block.

Returns: The unlocalized name of this block.
Return Type: string

script.zs
// Block.getDescriptionId() as string
<block:minecraft:grass_block>.getDescriptionId();

Gets the blast resistance of this Block.

Returns: The blast resistance of this Block.
Return Type: float

script.zs
// Block.getExplosionResistance() as float
<block:minecraft:grass_block>.getExplosionResistance();

Gets the friction of this Block.

Returns: The friction of this Block.
Return Type: float

script.zs
// Block.getFriction() as float
<block:minecraft:grass_block>.getFriction();

Gets the jump factor of this Block.

Returns: The jump factor of this Block.
Return Type: float

script.zs
// Block.getJumpFactor() as float
<block:minecraft:grass_block>.getJumpFactor();

Gets the loot table id for this Block.

Returns: The loot table id for this Block.
Return Type: string

script.zs
// Block.getLootTable() as string
<block:minecraft:grass_block>.getLootTable();

Gets the name of this Block

Returns: The name of this block.
Return Type: MutableComponent

script.zs
// Block.getName() as MutableComponent
<block:minecraft:grass_block>.getName();

Gets a list of valid BlockStates for this Block.

Returns: A list of valid BlockStates for this Block.
Return Type: stdlib.List<BlockState>

script.zs
// Block.getPossibleStates() as stdlib.List<BlockState>
<block:minecraft:grass_block>.getPossibleStates();

Gets the registry name of this block.

Returns: A ResourceLocation of the registry name of this block.
Return Type: ResourceLocation

script.zs
// Block.getRegistryName() as ResourceLocation
<block:minecraft:grass_block>.getRegistryName();

Gets the speed factor of this Block.

Returns: The speed factor of this Block.
Return Type: float

script.zs
// Block.getSpeedFactor() as float
<block:minecraft:grass_block>.getSpeedFactor();

Checks if entities can collide with this Block.

Returns: True if entities will collide with this Block. False otherwise.
Return Type: boolean

script.zs
// Block.hasCollision() as boolean
<block:minecraft:grass_block>.hasCollision();

Checks if the opacity of this block is different in different areas of the Block.

Returns: True if this Block has variable opacity. False otherwise.
Return Type: boolean

script.zs
// Block.hasDynamicShape() as boolean
<block:minecraft:grass_block>.hasDynamicShape();

Checks if an entity can be spawned inside this Block.

This is used to find valid spawn locations for players.

Returns: True if an entity can be spawned in this Block. False Otherwise.
Return Type: boolean

script.zs
Block.isPossibleToRespawnInThis(state as BlockState) as boolean
ParameterType
Parameter
state
Type
BlockState

Checks whether this Block matches another Block.

Returns: True if this Block matches the other Block. False otherwise.
Return Type: boolean

script.zs
Block.matches(other as Block) as boolean
ParameterTypeDescription
Parameter
other
Type
Block
Description
The other Block to check if this Block matches.

Sets the blast resistance of this Block.

script.zs
// Block.setExplosionResistance(resistance as float)
<block:minecraft:grass_block>.setExplosionResistance(2);
ParameterTypeDescription
Parameter
resistance
Type
float
Description
The new blast resistance of this Block.

Sets the friction of this Block.

script.zs
// Block.setFriction(friction as float)
<block:minecraft:grass_block>.setFriction(2);
ParameterTypeDescription
Parameter
friction
Type
float
Description
The new friction of this Block.

Sets whether entities can collide with this Block.

script.zs
// Block.setHasCollision(canCollide as boolean)
<block:minecraft:grass_block>.setHasCollision(true);
ParameterTypeDescription
Parameter
canCollide
Type
boolean
Description
Can entities collide with this Block.

Sets the jump factor of this Block.

script.zs
// Block.setJumpFactor(jumpFactor as float)
<block:minecraft:grass_block>.setJumpFactor(2);
ParameterTypeDescription
Parameter
jumpFactor
Type
float
Description
The new jump factor of this Block.

Sets the speed factor of this Block.

script.zs
// Block.setSpeedFactor(speedFactor as float)
<block:minecraft:grass_block>.setSpeedFactor(2);
ParameterTypeDescription
Parameter
speedFactor
Type
float
Description
The new speed factor of this Block.

Properties

NameTypeHas GetterHas SetterDescription
Name
commandString
Type
string
Has Getter
true
Has Setter
false
Description
Gets the block bracket handler syntax for this Block.

E.G.
Name
defaultState
Type
BlockState
Has Getter
true
Has Setter
false
Description
Gets the default BlockState of this Block.
Name
descriptionId
Type
string
Has Getter
true
Has Setter
false
Description
Gets the translation key that is used to localize this Block.
Name
dynamicShape
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if the opacity of this block is different in different areas of the Block.
Name
explosionResistance
Type
float
Has Getter
true
Has Setter
true
Description
Gets the blast resistance of this Block.
Name
friction
Type
float
Has Getter
true
Has Setter
true
Description
Gets the friction of this Block.
Name
hasCollision
Type
boolean
Has Getter
true
Has Setter
true
Description
Checks if entities can collide with this Block.
Name
jumpFactor
Type
float
Has Getter
true
Has Setter
true
Description
Gets the jump factor of this Block.
Name
lootTable
Type
string
Has Getter
true
Has Setter
false
Description
Gets the loot table id for this Block.
Name
name
Type
MutableComponent
Has Getter
true
Has Setter
false
Description
Gets the name of this Block
Name
possibleStates
Type
stdlib.List<BlockState>
Has Getter
true
Has Setter
false
Description
Gets a list of valid BlockStates for this Block.
Name
registryName
Type
ResourceLocation
Has Getter
true
Has Setter
false
Description
Gets the registry name of this block.
Name
speedFactor
Type
float
Has Getter
true
Has Setter
true
Description
Gets the speed factor of this Block.