Перейти к основному содержанию

TileEntity

TileEntity is a powerful mechanism that allows for creation of interactive blocks such as chests, furnaces, etc.

Index

Interfaces

LocalTileEntityPrototype

LocalTileEntityPrototype:

Interface passed to TileEntity.registerPrototype function as client property.

optionalcontainerEvents

containerEvents?: {}

Events of the container's client copy.


Type declaration

optionalevents

events?: {}

Events that receive packets on the client side.


Type declaration

  • [packetName string]: (packetData: any, packetExtra: any) => void

    Example of the client packet event function.

optionalload

load?: () => void

Called when the client copy is created.

@since

2.0.2b29


Type declaration

    • (): void
    • Returns void

optionaltick

tick?: () => void

Called every tick on client thread; you cannot set tick later if there is no function at all.


Type declaration

    • (): void
    • Returns void

optionalunload

unload?: () => void

Called on destroying the client copy.

@since

2.0.2b29


Type declaration

    • (): void
    • Returns void

TileEntityPrototype

TileEntityPrototype:

Interface passed to TileEntity.registerPrototype function.

optionalclick

click?: (id: number, count: number, data: number, coords: ItemUseCoordinates, player: number, extra: ItemExtraData) => boolean | void

Called when player uses some item on a TileEntity.

@returns

true if the event is handled and should not be propagated to the next handlers. Return true if you don't want the user interface to be opened.


Type declaration

optionalclient

Client tile entity prototype copy.

optionalcontainerEvents

containerEvents?: {}

Events of the container on the server side.


Type declaration

optionalcreated

created?: () => void

Called when a TileEntity is created.


Type declaration

    • (): void
    • Returns void

optionaldefaultValues

defaultValues?: Scriptable

Default data values, will be initially added to TileEntity.data field.

optionaldestroy

destroy?: (fromDestroyBlock: boolean, isDropAllowed: boolean) => boolean | void

Occurs when the TileEntity is being destroyed.

@returns

true to prevent it. TileEntity object from destroying (but if the block was destroyed, returning true from this function doesn't replace the missing block with a new one)


Type declaration

    • (fromDestroyBlock: boolean, isDropAllowed: boolean): boolean | void
    • Parameters

      • fromDestroyBlock: boolean
      • isDropAllowed: boolean

      Returns boolean | void

optionaldestroyBlock

destroyBlock?: (coords: ItemUseCoordinates, player: number) => void

Occurs when a block of the TileEntity is being destroyed. See Callback.DestroyBlockFunction for details.


Type declaration

optionalevents

events?: {}

Events that receive packets on the server side.


Type declaration

  • [packetName string]: (packetData: any, packetExtra: any, connectedClient: NetworkClient) => void

    Example of the server packet event function. 'this.sendResponse' method is only available here.

optionalgetGuiScreen

getGuiScreen?: () => IWindow

Called to get the UI.IWindow object for the current TileEntity. The window is then opened within TileEntity.container when the player clicks it.

@deprecated

Client-side method only.


Type declaration

optionalgetScreenByName

getScreenByName?: (screenName?: string, container?: ItemContainer) => IWindow

Called on client side, returns the window to open.


Type declaration

optionalgetScreenName

getScreenName?: (player: number, coords: Vector) => string

Called on server side and returns UI name to open on click.


Type declaration

    • (player: number, coords: Vector): string
    • Parameters

      Returns string

optionalinit

init?: () => void

Called when a TileEntity is initialized in the world.


Type declaration

    • (): void
    • Returns void

optionalload

load?: () => void

Called when the client copy is created.

@since

2.0.2b29


Type declaration

    • (): void
    • Returns void

optionalonCheckerTick

onCheckerTick?: (isInitialized: boolean, isLoaded: boolean, wasLoaded: boolean) => void

Called before every tile ticking to remove them.

@since

2.0.2b29


Type declaration

    • (isInitialized: boolean, isLoaded: boolean, wasLoaded: boolean): void
    • Parameters

      • isInitialized: boolean
      • isLoaded: boolean
      • wasLoaded: boolean

      Returns void

optionalonConnectionPlayer

onConnectionPlayer?: (client: NetworkClient) => void

Called when player connects to server.

@since

2.3.1b116-3


Type declaration

optionalonDisconnectionPlayer

onDisconnectionPlayer?: (client: NetworkClient) => void

Called when player disconnects from server.

@since

2.3.1b116-3


Type declaration

optionalprojectileHit

projectileHit?: (coords: ItemUseCoordinates, target: ProjectileHitTarget) => void

Occurs when a projectile entity hits the TileEntity. See Callback.ProjectileHitFunction for details.


Type declaration

optionalredstone

redstone?: (params: RedstoneSignalParams) => void

Occurs when the TileEntity should handle redstone signal. See Callback.RedstoneSignalFunction for details.


Type declaration

optionalrequireMoreLiquid

requireMoreLiquid?: (liquid: string, amount: number) => void

Called when more liquid is required.


Type declaration

    • (liquid: string, amount: number): void
    • Parameters

      • liquid: string
      • amount: number

      Returns void

optionaltick

tick?: () => void

Called every tick and should be used for all the updates of the TileEntity.


Type declaration

    • (): void
    • Returns void

optionalunload

unload?: () => void

Called on destroying the client copy.

@since

2.0.2b29


Type declaration

    • (): void
    • Returns void

optionaluseNetworkItemContainer

useNetworkItemContainer?: boolean

Use ItemContainer that supports multiplayer.

Variables

consttileEntityCacheMap
internal

tileEntityCacheMap: {}
@since

2.2.1b106


Type declaration

consttileEntityList
internal

tileEntityList: TileEntity[]

consttileEntityPrototypes
internal

tileEntityPrototypes: {}

Type declaration

Functions

addTileEntity

  • If the block on the specified coordinates is a TileEntity block and is not initialized, initializes it and returns created TileEntity object.


    Parameters

    Returns Nullable<TileEntity>

    Tile if one was created, null otherwise.

addUpdatableAsTileEntity

  • addUpdatableAsTileEntity(updatable: Updatable): void
  • Adding attached to block updatable, which is working like ordinary tile entity, except the fact that it registers in any case.


    Parameters

    Returns void

checkTileEntityForIndex

  • checkTileEntityForIndex(index: number): void
  • internal

    Parameters

    • index: number

    Returns void

createTileEntityForPrototype

destroyTileEntity

  • destroyTileEntity(tileEntity: TileEntity): boolean
  • destroyTileEntity(tileEntity: TileEntity, fromDestroyBlock: boolean): boolean
  • destroyTileEntity(tileEntity: TileEntity, fromDestroyBlock: boolean, isDropAllowed: boolean): boolean
  • Destroys TileEntity, dropping it's container.


    Parameters

    Returns boolean

    true if the it was destroyed successfully, false otherwise.

destroyTileEntityAtCoords

  • destroyTileEntityAtCoords(x: number, y: number, z: number, region?: BlockSource, isDropAllowed?: boolean): boolean
  • If the block on the specified coordinates is a TileEntity, destroys it, dropping it's container.


    Parameters

    • x: number
    • y: number
    • z: number
    • optionalregion: BlockSource
    • optionalisDropAllowed: boolean

    Returns boolean

    true if the it was destroyed successfully, false otherwise.

getPrototype

getTileEntity

isTileEntityBlock

  • isTileEntityBlock(blockID: number): boolean

  • Parameters

    • blockID: number

      numeric block ID

    Returns boolean

    true if the specified numeric block ID is a TileEntity block ID, false otherwise.

isTileEntityLoaded

  • isTileEntityLoaded(tileEntity: TileEntity): boolean
  • Checks whether the TileEntity is in the loaded chunk or not.

    @remarks

    The following chunks are verified:

     + +
    #
    + +

    Where "#" is the chunk containing the current TileEntity and "+" are the chunks that are also verified.


    Parameters

    Returns boolean

    true if the chunk with TileEntity and some of the surrounding chunks are loaded, false otherwise.

registerPrototype

  • Registers block as a ticking tile entity.


    Parameters

    • blockID: number

      numeric block ID to be used

    • customPrototype: TileEntityPrototype

      a set of defining parameters behavior

    Returns void

resetEngine

  • resetEngine(): void
  • internal

    Clears active game tile list, maintaining updatable states.


    Returns void