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

BlockEngine.LiquidTank

Class to store and manipulate liquids in TileEntity.

Index

Constructors

constructor

  • Creates new instance of LiquidTank and binds it to TileEntity.


    Parameters

    • tileEntity: TileEntity

      TileEntity instance

    • name: string

      liquid tank name

    • limit: number

      max liquid amount

    • optionalliquids: string[]

      types of valid liquids

    Returns LiquidTank

Properties

data

data: { amount: number; liquid: string }

Liquid data stored in TileEntity data object.


Type declaration

  • amount: number
  • liquid: string

limit

limit: number

Max liquid amount.

liquids

liquids: object

Set of valid liquids

readonlyname

name: string

Liquid tank name

tileEntity

tileEntity: TileEntity

Parent TileEntity instance

Methods

addLiquid

  • addLiquid(liquid: string, amount: number): number
  • Adds liquid to tank.


    Parameters

    • liquid: string

      liquid type

    • amount: number

      amount of liquid to add

    Returns number

    amount of liquid that wasn't added

addLiquidToItem

  • Tries to fill item with liquid from tank.


    Parameters

    Returns boolean

    true if liquid was added, false otherwise.

getAmount

  • getAmount(liquid?: string): number
  • Gets amount of liquid in tank. If liquid parameter is set, returns amount of the specified liquid.


    Parameters

    • optionalliquid: string

      liquid type

    Returns number

    amount of liquid

getLimit

  • getLimit(): number
  • Gets max amount of liquid in tank.


    Returns number

    amount of liquid

getLiquid

  • getLiquid(amount: number): number
  • getLiquid(liquid: string, amount: number): number
  • Gets liquid from tank.


    Parameters

    • amount: number

      max amount of liquid to get

    Returns number

    amount of got liquid

getLiquidFromItem

  • Tries to fill tank with liquid from item.


    Parameters

    Returns boolean

    true if liquid was extracted, false otherwise.

getLiquidStored

  • getLiquidStored(): string
  • Gets type of liquid stored in tank.


    Returns string

    liquid type

getRelativeAmount

  • getRelativeAmount(): number
  • Gets amount of liquid divided by max amount.


    Returns number

    scalar value from 0 to 1

isEmpty

  • isEmpty(): boolean
  • Returns boolean

    true if tank is empty, false otherwise

isFull

  • isFull(): boolean
  • Returns boolean

    true if tank is full, false otherwise

isValidLiquid

  • isValidLiquid(liquid: string): boolean
  • Parameters

    • liquid: string

      liquid type

    Returns boolean

    true if liquid can be stored in tank, false otherwise.

setAmount

  • setAmount(liquid: string, amount: number): void
  • Sets liquid to tank.


    Parameters

    • liquid: string

      liquid type

    • amount: number

      amount of liquid

    Returns void

setParent

  • Binds liquid tank to TileEntity.


    Parameters

    Returns void

setValidLiquids

  • setValidLiquids(liquids: string[]): void
  • Sets liquids that can be stored in tank.


    Parameters

    • liquids: string[]

      arrays of liquid types

    Returns void

updateUiScale

  • updateUiScale(scale: string): void
  • Updates UI bar of liquid. Uses LiquidStorage method for legacy container and container event from TileEntityBase for multiplayer container.


    Parameters

    • scale: string

      name of liquid bar

    Returns void