Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ItemContainer

New type of TileEntity container that supports multiplayer

Hierarchy

  • ItemContainer

Index

Constructors

constructor

Properties

parent

parent: Nullable<TileEntity> | any

If container is a part of TileEntity, this field stores reference to it, otherwise null. Consider using Container.getParent instead of direct field access

slots

slots: {}

Type declaration

Methods

addServerCloseListener

addServerEventListener

addServerOpenListener

clearSlot

close

  • close(): void

closeFor

dropAt

  • dropAt(region: BlockSource, x: number, y: number, z: number): void
  • Drops the contents of all the slots in the container on the specified coordinates and clears them

    Parameters

    Returns void

dropSlot

getClientContainerTypeName

  • getClientContainerTypeName(): string

getParent

getSlot

  • Gets the slot by its name. If a slot with specified name doesn't exists, creates an empty one with specified name

    Parameters

    Returns ItemContainerSlot

    contents of the slot in a Slot object. You can modify it to change the contents of the slot

getText

  • getText(name: string): Nullable<string>
  • Parameters

    • name: string

      element name

    Returns Nullable<string>

    "text" binding value, usually the text displayed on the element, or null if no element with specified name exist

getValue

  • getValue(name: string): Nullable<number>
  • Parameters

    • name: string

      element name

    Returns Nullable<number>

    "value" binding value, e.g. scale value, or null if no element with specified name exist

handleInventoryToSlotTransaction

  • handleInventoryToSlotTransaction(from: number, to: string, count: number): void
  • Handler for moving items from inventory to container slot. Can be used in custom slot click events. Works only with the CLIENT instance of ItemContainer

    Parameters

    • from: number

      numeric index of the inventory slot where the transaction happened

    • to: string

      string name of the container slot where the transaction happened

    • count: number

      count of the items to be moved

    Returns void

handleSlotToInventoryTransaction

  • handleSlotToInventoryTransaction(from: string, count: number): void
  • Handler for moving items from container slot to inventory. Can be used in custom slot click events. Works only with the CLIENT instance of ItemContainer

    Parameters

    • from: string

      string name of the container slot where the transaction happened

    • count: number

      count of the items to be moved

    Returns void

isLegacyContainer

  • isLegacyContainer(): false

openFor

  • Opens UI for client

    Parameters

    • client: NetworkClient

      client in which UI will be open

    • screenName: string

      name of the screen to open

    Returns void

sendChanges

  • sendChanges(): void
  • Sends changes in container to all clients. Needs to be used every time when something changes in container.

    Returns void

sendEvent

  • sendEvent(eventName: string, someData: object | string): void
  • Sends packet from client container copy to server.

    Parameters

    • eventName: string
    • someData: object | string

    Returns void

sendResponseEvent

  • sendResponseEvent(eventName: string, someData: object | string): void
  • Sends packet from server container. ONLY AVAILABLE IN SERVER CONTAINER EVENTS

    Parameters

    • eventName: string
    • someData: object | string

    Returns void

setClientContainerTypeName

  • setClientContainerTypeName(name: string): void

setGlobalAddTransferPolicy

setGlobalGetTransferPolicy

setParent

setScale

  • setScale(name: string, value: number): void
  • Sets "value" binding value for the element. Used to set scales values

    Parameters

    • name: string

      element name

    • value: number

      value to be set for the element

    Returns void

setSlot

  • Set slot's content by its name. If a slot with specified name doesn't exists, creates new with specified name and item

    Parameters

    Returns void

setSlotAddTransferPolicy

  • setSlotAddTransferPolicy(slotName: string, transferPolicy: TransferPolicy): void

setSlotGetTransferPolicy

  • setSlotGetTransferPolicy(slotName: string, transferPolicy: TransferPolicy): void

setText

  • setText(name: string, value: string | number): void
  • Sets "text" binding value for the element. Used to set element's text

    Parameters

    • name: string

      element name

    • value: string | number

      value to be set for the element

    Returns void

validateAll

  • validateAll(): void

validateSlot

  • Validates slot contents. If the data value is less then 0, it becomes 0, if id is 0 or count is less then or equals to zero, slot is reset to an empty one

    Parameters

    Returns void

Static registerScreenFactory

  • registerScreenFactory(name: string, screenFactory: (container: ItemContainer, name: string) => Window): void

Generated using TypeDoc