Home Commands Examples Getting Started With Scripts Global Keywords

BlockEntity

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.entity.BlockEntity;

Extending CapabilityProvider<BlockEntity>

BlockEntity extends CapabilityProvider<BlockEntity>. That means all methods available in CapabilityProvider<BlockEntity> are also available in BlockEntity

Methods

Return Type: BlockPos

script.zs
// BlockEntity.getBlockPos() as BlockPos
myBlockEntity.getBlockPos();

Return Type: BlockState

script.zs
// BlockEntity.getBlockState() as BlockState
myBlockEntity.getBlockState();

Return Type: Level?

script.zs
// BlockEntity.getLevel() as Level?
myBlockEntity.getLevel();

Return Type: ResourceLocation

script.zs
// BlockEntity.getRegistryName() as ResourceLocation
myBlockEntity.getRegistryName();

Return Type: boolean

script.zs
// BlockEntity.hasLevel() as boolean
myBlockEntity.hasLevel();
script.zs
BlockEntity.setData(data as IData)
ParameterType
Parameter
data
Type
IData
script.zs
BlockEntity.updateData(data as IData)
ParameterType
Parameter
data
Type
IData

Properties

NameTypeHas GetterHas Setter
Name
blockPos
Type
BlockPos
Has Getter
true
Has Setter
false
Name
blockState
Type
BlockState
Has Getter
true
Has Setter
false
Name
data
Type
IData
Has Getter
true
Has Setter
true
Name
hasLevel
Type
boolean
Has Getter
true
Has Setter
false
Name
level
Type
Level?
Has Getter
true
Has Setter
false
Name
registryName
Type
ResourceLocation
Has Getter
true
Has Setter
false