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.

This is a legacy container that does not synchronize between clients and server. It should be used to store data on one side either server or client.

Implements

Constructors

Methods

  • Clears slot's contents.

    Parameters

    • name: string

      slot name

    Returns 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

    Client only, use BlockSource.spawnDroppedItem instead.

  • Drops slot's contents on the specified coordinates and clears the slot.

    Parameters

    • name: string

      slot name

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

    Returns void

    Client only, use BlockSource.spawnDroppedItem instead.

  • Gets any value from the element.

    Type Parameters

    • T = any

    Parameters

    • elementName: string

      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 Rect | IElement | T

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

  • 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 Slot

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

  • 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 Slot

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

  • Parameters

    • name: string

      element name

    Returns string

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

  • Parameters

    • name: string

      element name

    Returns number

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

  • Forces ui elements and drawables of the window to refresh.

    Parameters

    • onCurrentThread: boolean

      if true, the drawables will be refreshed immediately, otherwise refresh event will be posted; ensure you are in the UI thread if you pass true as the parameter

    Returns void

    onCurrentThread: false
    
  • Forces ui elements and drawables of the window to refresh.

    Returns void

  • Forces ui drawables of the window to refresh.

    Parameters

    • onCurrentThread: boolean

      if true, the drawables will be refreshed immediately, otherwise refresh event will be posted; ensure you are in the UI thread if you pass true as the parameter

    Returns void

    onCurrentThread: false
    
  • Returns void

  • Forces ui elements of the window to refresh.

    Parameters

    • onCurrentThread: boolean

      if true, the drawables will be refreshed immediately, otherwise refresh event will be posted; ensure you are in the UI thread if you pass true as the parameter

    Returns void

    onCurrentThread: false
    
  • Forces ui elements of the window to refresh.

    Returns void

  • Parameters

    • name: string

      element name

    Returns boolean

    true if the element is currently hovered.

  • Returns boolean

    false if container supports multiplayer, true otherwise.

  • Returns boolean

    true, if some window is opened in the container.

  • Passes any value to the element.

    Parameters

    • elementName: string

      element name

    • bindingName: string

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

    • val: any

      value to be passed to the element

    Returns void

  • Sets an object to be notified when the window is closed.

    Parameters

    Returns void

  • Sets an object to be notified when the window is opened.

    Parameters

    Returns void

    2.0.4b43

  • Sets container's parent object, for TileEntity's container it should be a TileEntity 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

  • 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

  • Set slot's content by it's name. If a slot with specified name doesn't exists, creates an empty one with specified name and item.

    Parameters

    • name: string

      slot name

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

    Returns void

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

    Parameters

    • name: string

      slot name

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

      item extra value; note that it should be an instance of ItemExtraData and not it's numeric ID

    Returns 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

  • If the container is a custom workbench, you can set the slot prefix via this method call. UI.Container.getFieldSlot will get field slot by prefix + slot name.

    Parameters

    • wbsnp: string

      custom workbench slot prefix

    Returns void

  • Validates all the slots in the container.

    Returns 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

Properties

parent: 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 UI.Container.setParent method or using constructor parameter. Consider using UI.Container.getParent instead of direct field access.

slots: {
    [slotName: string]: Slot;
}
tileEntity: any
isContainer: boolean

Copyright © 2024 Nernar. Copyright © 2020 #mineprogramming. Built with ❤ and TypeDoc.