Home Commands Examples Getting Started With Scripts Global Keywords 1.21 Migration Guide
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

BlockEntity

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.block.entity.BlockEntity;

Extends

BlockEntity extends AttachmentHolder.

Implements

BlockEntity implements the following interfaces:

IAttachmentHolder

Undocumented Interfaces

IBlockEntityExtension

Members

Getter
Gets the BlockPos of the block entity.
script.zs
// BlockEntity.blockPos as BlockPos
myBlockEntity.blockPos

Return Type: BlockPos

blockPos() as BlockPos
Gets the BlockPos of the block entity.

Returns: The BlockPos of the block entity.

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

Return Type: BlockPos

Getter
Gets the BlockState of the block entity.
script.zs
// BlockEntity.blockState as BlockState
myBlockEntity.blockState

Return Type: BlockState

blockState() as BlockState
Gets the BlockState of the block entity.

Returns: The BlockState of the block entity.

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

Return Type: BlockState

Getter
Gets the data of the block entity.
script.zs
// BlockEntity.data as IData
myBlockEntity.data

Return Type: IData

Setter
Sets the data of the block entity.
script.zs
// BlockEntity.data = (data as IData);
myBlockEntity.data = myIData;

Parameters:

data Type: IData - The data to set.
data(data as IData)
Sets the data of the block entity.
script.zs
// BlockEntity.data(data as IData);
myBlockEntity.data(myIData);

Parameters:

data Type: IData - The data to set.
getAttachmentData(type as AttachmentType<T>) as T
script.zs
// BlockEntity.getAttachmentData<T>(type as AttachmentType<T>) as T;
myBlockEntity.getAttachmentData<T>(myAttachmentType);

Parameters:

type Type: AttachmentType<T>

Return Type: T

getAttachmentData(type as Supplier<AttachmentType<T>>) as T
script.zs
// BlockEntity.getAttachmentData<T>(type as Supplier<AttachmentType<T>>) as T;
myBlockEntity.getAttachmentData<T>(mySupplier);

Parameters:

type Type: Supplier<AttachmentType<T>>

Return Type: T

hasAttachmentData(type as AttachmentType<T>) as bool
script.zs
// BlockEntity.hasAttachmentData<T>(type as AttachmentType<T>) as bool;
myBlockEntity.hasAttachmentData<T>(myAttachmentType);

Parameters:

type Type: AttachmentType<T>

Return Type: bool

hasAttachmentData(type as Supplier<AttachmentType<T>>) as bool
script.zs
// BlockEntity.hasAttachmentData<T>(type as Supplier<AttachmentType<T>>) as bool;
myBlockEntity.hasAttachmentData<T>(mySupplier);

Parameters:

type Type: Supplier<AttachmentType<T>>

Return Type: bool

Getter
Checks if the block entity has a level.
script.zs
// BlockEntity.hasLevel as bool
myBlockEntity.hasLevel

Return Type: bool

hasLevel() as bool
Checks if the block entity has a level.

Returns: Whether the block entity has a level.

script.zs
// BlockEntity.hasLevel() as bool;
myBlockEntity.hasLevel();

Return Type: bool

Getter
Gets the Level of the block entity.
script.zs
// BlockEntity.level as Level
myBlockEntity.level

Return Type: Level

level() as Level
Gets the Level of the block entity.

Returns: The Level of the block entity.

script.zs
// BlockEntity.level() as Level;
myBlockEntity.level();

Return Type: Level

Getter
Gets the ResourceLocation of the block entity type.
script.zs
// BlockEntity.registryName as ResourceLocation
myBlockEntity.registryName

Return Type: ResourceLocation

registryName() as ResourceLocation
Gets the ResourceLocation of the block entity type.

Returns: The ResourceLocation of the block entity type.

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

Return Type: ResourceLocation

setAttachmentData(type as AttachmentType<T>, data as T) as T?
script.zs
// BlockEntity.setAttachmentData<T>(type as AttachmentType<T>, data as T) as T?;
myBlockEntity.setAttachmentData<T>(myAttachmentType, myT);

Parameters:

type Type: AttachmentType<T>
data Type: T

Return Type: T?

setAttachmentData(type as Supplier<AttachmentType<T>>, data as T) as T?
script.zs
// BlockEntity.setAttachmentData<T>(type as Supplier<AttachmentType<T>>, data as T) as T?;
myBlockEntity.setAttachmentData<T>(mySupplier, myT);

Parameters:

type Type: Supplier<AttachmentType<T>>
data Type: T

Return Type: T?

updateData(data as IData)
Updates the data of the block entity, merging the provided data with the existing data.
script.zs
// BlockEntity.updateData(data as IData);
myBlockEntity.updateData(myIData);

Parameters:

data Type: IData - The data to update.