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

ItemContainer

Type of TileEntity container that supports multiplayer.

Implements

Index

Constructors

constructor

Properties

readonlyisServer

isServer: boolean

readonlyslots

slots: {}

Type declaration

readonlytransactionLock

transactionLock: any

Methods

addServerCloseListener

addServerEventListener

addServerOpenListener

addToSlot

  • addToSlot(name: string, id: number, count: number, data: number, extra: ItemExtraData, player: number): number
  • Parameters

    • name: string
    • id: number
    • count: number
    • data: number
    • extra: ItemExtraData
    • player: number

    Returns number

asLegacyContainer

  • @since

    2.2.0b82


    Parameters

    • allSlots: boolean

    Returns Container

asScriptableField


  • Returns AbstractSlot[]

    JS array of all slots.

clearSlot

  • clearSlot(name: string): void
  • Clears slot's contents.


    Parameters

    • name: string

      slot name

    Returns void

close

  • close(): void
  • Closes UI for all clients


    Returns void

closeFor

  • Closes UI for client.


    Parameters

    Returns void

dropAt

  • dropAt(region: BlockSource, x: number, y: number, z: number): void
  • Parameters

    Returns void

dropSlot

  • dropSlot(region: BlockSource, name: string, x: number, y: number, z: number): void
  • Drops slot's contents on the specified coordinates and clears the slot.


    Parameters

    • region: BlockSource
    • name: string

      slot name

    • x: number
    • y: number
    • z: number

    Returns void

getAddTransferPolicy

getBinding

getBindingValidator

getClientContainerTypeName

  • getClientContainerTypeName(): string
  • Returns string

getFieldSlot


  • Parameters

    • slot: number

      slot index

    Returns AbstractSlot

    Workbench slot instance by slot index.

getFromSlot

  • getFromSlot(name: string, id: number, count: number, data: number, extra: ItemExtraData, player: number): number
  • Parameters

    • name: string
    • id: number
    • count: number
    • data: number
    • extra: ItemExtraData
    • player: number

    Returns number

getFullSlot

getGetTransferPolicy

getNetworkEntity

getNetworkName

  • getNetworkName(): string
  • Returns string

getParent

  • getParent(): any

  • Returns any

    Tile if the following container is part of it, and null otherwise.

getSlot

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


    Parameters

    • name: string

      slot name

    Returns ItemContainerSlot

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

getText

  • getText(elementName: string): string

  • Parameters

    • elementName: string

      element name

    Returns string

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

getUiAdapter

getValue

  • getValue(elementName: string, value: number): number

  • Parameters

    • elementName: string

      element name

    • value: number

    Returns number

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

getWindow

getWindowContent

getWorkbenchFieldSize

  • getWorkbenchFieldSize(): number
  • @since

    2.2.1b106


    Returns number

handleDirtyBindingsPacket

  • handleDirtyBindingsPacket(client: NetworkClient, packet: JSONObject): void

handleInventoryToSlotTransaction

  • handleInventoryToSlotTransaction(player: number, inventorySlot: number, slotName: string, amount: number): void
  • Parameters

    • player: number
    • inventorySlot: number
    • slotName: string
    • amount: number

    Returns void

handleSlotToInventoryTransaction

  • handleSlotToInventoryTransaction(player: number, slotName: string, inventorySlot: number, amount: number): void
  • Parameters

    • player: number
    • slotName: string
    • inventorySlot: number
    • amount: number

    Returns void

handleSlotToSlotTransaction

  • handleSlotToSlotTransaction(player: number, slot1: string, slot2: string, amount: number): void
  • Parameters

    • player: number
    • slot1: string
    • slot2: string
    • amount: number

    Returns void

isGlobalSlotSavingEnabled

  • isGlobalSlotSavingEnabled(): boolean
  • @since

    2.2.0b82


    Returns boolean

isLegacyContainer

  • isLegacyContainer(): false

  • Returns false

    false if container supports multiplayer, true otherwise.

isSlotSavingEnabled

  • isSlotSavingEnabled(name: string): boolean
  • @since

    2.2.0b82


    Parameters

    • name: string

    Returns boolean

markAllSlotsDirty

  • markAllSlotsDirty(): void
  • Returns void

markSlotDirty

  • markSlotDirty(name: string): void
  • Parameters

    • name: string

    Returns void

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

removeEntity

  • removeEntity(): void
  • Returns void

resetSlotSavingEnabled

  • resetSlotSavingEnabled(name: string): void
  • @since

    2.2.0b82


    Parameters

    • name: string

    Returns void

runTransaction

sealAllSlots

  • sealAllSlots(): void
  • Returns void

sealSlot

  • sealSlot(slotName: string): void
  • Parameters

    • slotName: string

    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

sendClosed

  • sendClosed(): void
  • Returns void

sendDirtyClientBinding

sendEvent

  • Sends packet from client container copy to server.


    Parameters

    Returns void

sendInventoryToSlotTransaction

  • sendInventoryToSlotTransaction(inventorySlot: number, slotName: string, amount: number): void
  • Sends event to move specified amount of items from the player inventory slot by given index to container slot by given name. This event is sent from client to server, so you should use it only on the client side, for example, in custom slot element touch events, etc.


    Parameters

    • inventorySlot: number

      numeric index of the inventory slot, from where to retrieve the item

    • slotName: string

      string name of the container slot, where to put taken item

    • amount: number

      item count to be retrieved from inventory slot

    Returns void

sendResponseEvent

  • sendResponseEvent(name: string, data: string | PacketData): void
  • Sends packet from server container.

    @remarks

    Available only in server container events!


    Parameters

    Returns void

sendSlotToInventoryTransaction

  • sendSlotToInventoryTransaction(slot: string, amount: number): void
  • Sends event to move specified amount of items from the container slot by given name to player's inventory. The index of the inventory slot, where to put item, can't be specified, because it's decided by ItemContainer automatically, and you just don't need to do this. This event is sent from client to server, so you should use it only on the client side, for example, in custom slot element touch events, etc.


    Parameters

    • slot: string

      string name of the container slot, from where to retrieve item

    • amount: number

      item count to be retrieved from container slot

    Returns void

sendSlotToSlotTransaction

  • sendSlotToSlotTransaction(slot1: string, slot2: string, amount: number): void
  • Sends event to move specified amount of items from one container slot to another by given names. This event is sent from client to server, so you should use it only on the client side, for example, in custom slot element touch events, etc.


    Parameters

    • slot1: string

      string name of the container slot, from where to retrieve item

    • slot2: string

      string name of the container slot, where to put taken item

    • amount: number

      item count to be retrieved from container slot

    Returns void

setBinding

  • setBinding(composedBindingName: string, value: PrimitiveTypes): void
  • setBinding(elementName: string, bindingName: string, value: PrimitiveTypes): void
  • Parameters

    Returns void

setBindingValidator

  • setBindingValidator(composedBindingName: string, validator: BindingValidator): void

setClientBinding

  • setClientBinding(composedBindingName: string, value: PrimitiveTypes): void
  • setClientBinding(elementName: string, bindingName: string, value: PrimitiveTypes): void
  • Parameters

    Returns void

setClientContainerTypeName

  • setClientContainerTypeName(type: string): void
  • Parameters

    • type: string

    Returns void

setClientScale

  • setClientScale(elementName: string, value: number): void
  • Parameters

    • elementName: string
    • value: number

    Returns void

setClientText

  • setClientText(elementName: string, text: string): void
  • Parameters

    • elementName: string
    • text: string

    Returns void

setDirtySlotListener

setGlobalAddTransferPolicy

setGlobalBindingValidator

setGlobalDirtySlotListener

setGlobalGetTransferPolicy

setGlobalSlotSavingEnabled

  • setGlobalSlotSavingEnabled(enabled: boolean): void
  • @since

    2.2.0b82


    Parameters

    • enabled: boolean

    Returns void

setParent

  • setParent(parent: any): void
  • Sets container's parent object, for TileEntity's container it should be it reference, otherwise you can pass any value to be used in your code later.


    Parameters

    • parent: any

      an object to be set as container's parent

    Returns void

setScale

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


    Parameters

    • elementName: string

      element name

    • value: number

      value to be set for the element

    Returns void

setSlot

  • setSlot(name: string, slot: ItemContainerSlot): void
  • setSlot(name: string, id: number, count: number, data: number): void
  • setSlot(name: string, id: number, count: number, data: number, extra: ItemExtraData): void
  • Sets slot's content by it's name from given slot object. If a slot with specified name doesn't exist, a new slot with specified name and item will be created.


    Parameters

    Returns void

setSlotAddTransferPolicy

setSlotGetTransferPolicy

setSlotSavingEnabled

  • setSlotSavingEnabled(name: string, enabled: boolean): void
  • @since

    2.2.0b82


    Parameters

    • name: string
    • enabled: boolean

    Returns void

setText

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


    Parameters

    • elementName: string

      element name

    • text: string | number

      value to be set for the element

    Returns void

setWorkbenchFieldPrefix

  • setWorkbenchFieldPrefix(prefix: string): void
  • Parameters

    • prefix: string

    Returns void

setWorkbenchFieldSize

  • setWorkbenchFieldSize(workbenchFieldSize: number): void
  • @since

    2.2.1b106


    Parameters

    • workbenchFieldSize: number

    Returns void

validateAll

  • validateAll(): void
  • Validates all the slots in the container.


    Returns void

validateSlot

  • validateSlot(name: string): void
  • 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

    • name: string

      slot name

    Returns void

staticaddClientCloseListener

staticaddClientEventListener

  • addClientEventListener(typeName: string, packetName: string, listener: ClientEventListener): void

staticaddClientOpenListener

staticgetClientContainerInstance

staticloadClass

  • loadClass(): void
  • Returns void

staticregisterScreenFactory

Page Options