Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Container

Containers are used to properly manipulate windows and save slots contents and windows state between window opens. Every TileEntity has a built-in container that can be accessed as TileEntity.container

deprecated

Hierarchy

  • Container

Implements

Index

Constructors

constructor

Properties

parent

parent: Nullable<TileEntity> | any

If container is a part of TileEntity, this field stores reference to it, otherwise null. You can also assign any value of any type to it using Container.setParent method or using constructor parameter. Consider using Container.getParent instead of direct field access

slots

slots: {}

Type declaration

  • [key: string]: Slot

tileEntity

tileEntity: Nullable<TileEntity> | any

Methods

applyChanges

  • applyChanges(): void

asScriptableField

  • asScriptableField(): Slot[]

clearSlot

close

  • close(): void

dropAt

  • dropAt(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

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

    Returns void

dropSlot

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

    Parameters

    • name: ElementName

      slot name

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

    Returns void

getBinding

  • getBinding(elementName: ElementName, bindingName: string): any
  • Gets any value from the element

    Parameters

    • elementName: ElementName

      element name

    • bindingName: string

      binding name, you can access the value from the element by this name. Some binding names are reserved for additional element information, e.g. "element_obj" contains pointer to the current object and "element_rect" contains android.graphics.Rect object containing drawing rectangle

    Returns any

    value that was get from the element or null if the element doesn't exist

getElement

getFieldSlot

  • getFieldSlot(slot: number): Slot

getFullSlot

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

    Parameters

    Returns FullSlot

    contents of the slot in a FullSlot object containing more useful methods for slot manipulation

getGuiContent

getGuiScreen

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 Slot

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

getText

  • Parameters

    Returns Nullable<string>

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

getValue

getWindow

invalidateUI

  • invalidateUI(onCurrentThread?: boolean): void
  • Forces ui elements and drawables of the window to refresh

    Parameters

    • Optional onCurrentThread: boolean

      if true, the elements drawables will be refreshed immediately, otherwise refresh event will be posted. Default value if false. Ensure you are in the UI thread if you pass true as the parameter

    Returns void

invalidateUIDrawing

  • invalidateUIDrawing(onCurrentThread?: boolean): void
  • Forces ui drawables of the window to refresh

    Parameters

    • Optional onCurrentThread: boolean

      if true, the drawables will be refreshed immediately, otherwise refresh event will be posted. Default value if false. Ensure you are in the UI thread if you pass true as the parameter

    Returns void

invalidateUIElements

  • invalidateUIElements(onCurrentThread?: boolean): void
  • Forces ui elements of the window to refresh

    Parameters

    • Optional onCurrentThread: boolean

      if true, the elements will be refreshed immediately, otherwise refresh event will be posted. Default value if false. Ensure you are in the UI thread if you pass true as the parameter

    Returns void

isElementTouched

isLegacyContainer

  • isLegacyContainer(): true

isOpened

  • isOpened(): boolean

openAs

refreshSlots

  • refreshSlots(): void

setBinding

  • setBinding(elementName: ElementName, bindingName: string, value: any): void
  • Passes any value to the element

    Parameters

    • elementName: ElementName

      element name

    • bindingName: string

      binding name, you can access the value from the element by this name

    • value: any

      value to be passed to the element

    Returns void

setOnCloseListener

  • setOnCloseListener(listener: { onClose: (container: Container, window: IWindow) => void }): void

setParent

setScale

  • Sets "value" binding value for the element. Used to set scales values

    Parameters

    • name: ElementName

      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 an empty one with specified name and item

    Parameters

    • name: ElementName

      slot name

    • id: number
    • count: number
    • data: number

    Returns void

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

    Parameters

    • name: ElementName

      slot name

    • id: number
    • count: number
    • data: number
    • extra: ItemExtraData

      item extra value. Note that it should be an instance of ItemExtraData and not its numeric id

    Returns void

setText

  • Sets "text" binding value for the element. Used to set element's text

    Parameters

    • name: ElementName

      element name

    • value: string

      value to be set for the element

    Returns void

setWbSlotNamePrefix

  • setWbSlotNamePrefix(prefix: string): void
  • If the container is a custom workbench, you can set the slot prefix via this method call. Container.getFieldSlot will get field slot by prefix + slot name

    Parameters

    • prefix: string

      custom workbench slot prefix

    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

Generated using TypeDoc