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

BlockRegistry

Module for advanced block definition.

Index

Functions

addBlockDropOnExplosion

  • addBlockDropOnExplosion(blockID: string | number): void
  • Registers block drop on explosion with 25% chance.


    Parameters

    • blockID: string | number

    Returns void

convertBlockTypeToSpecialType

  • convertBlockTypeToSpecialType(properites: BlockType): Block.SpecialType
  • Converts block type to special type.


    Parameters

    Returns Block.SpecialType

    block special type

createBlock

  • createBlock(stringID: string, defineData: BlockVariation[], blockType?: string | BlockType): void
  • Creates new block using specified params.


    Parameters

    • stringID: string

      string id of the block.

    • defineData: BlockVariation[]

      array containing all variations of the block. Each variation corresponds to block data value, data values are assigned according to variations order.

    • optionalblockType: string | BlockType

      BlockType object or block type name, if the type was previously registered.

    Returns void

createBlockType

  • createBlockType(name: string, type: BlockType, isNative?: boolean): void
  • Registers block type in BlockEngine and as Block.SpecialType.


    Parameters

    • name: string

      block type name

    • type: BlockType

      BlockType object

    • optionalisNative: boolean

      if true doesn't create special type

    Returns void

createBlockWithRotation

  • createBlockWithRotation(stringID: string, defineData: BlockVariation[], blockType?: string | BlockType, hasVerticalFacings?: boolean): void
  • Creates new block with horizontal or all sides rotation.


    Parameters

    • stringID: string

      string id of the block

    • defineData: BlockVariation[]

      array containing all variations of the block. Supports 2 variations, each occupying 6 data values for rotation.

    • optionalblockType: string | BlockType

      BlockType object or block type name, if the type was previously registered.

    • optionalhasVerticalFacings: boolean

      true if the block has vertical facings, false otherwise.

    Returns void

createSlabs

  • createSlabs(slabID: string, doubleSlabID: string, defineData: BlockVariation[], blockType?: string | BlockType): void
  • Creates slabs and its double slabs using specified params


    Parameters

    • slabID: string

      string id of the

    • doubleSlabID: string

      string id of the double slab

    • defineData: BlockVariation[]

      array containing all variations of the block. Each variation corresponds to block data value, data values are assigned according to variations order.

    • optionalblockType: string | BlockType

      BlockType object or block type name, if the type was previously registered.

    Returns void

createStairs

  • createStairs(stringID: string, defineData: BlockVariation[], blockType?: string | BlockType): void
  • Creates stairs using specified params


    Parameters

    • stringID: string

      string id of the block

    • defineData: BlockVariation[]

      array containing one variation of the block (for similarity with other methods).

    • optionalblockType: string | BlockType

      BlockType object or block type name, if the type was previously registered.

    Returns void

extendBlockType

  • Inherits default values from type specified in "extends" property.


    Parameters

    Returns void

getBlockDrop

  • getBlockDrop(x: number, y: number, z: number, block: Tile, level: number, item: ItemInstance, region?: BlockSource): ItemInstanceArray[]
  • That feature is obsolete

    Parameters

    • x: number
    • y: number
    • z: number
    • block: Tile
    • level: number
    • item: ItemInstance
    • optionalregion: BlockSource

    Returns ItemInstanceArray[]

getBlockRotation

  • getBlockRotation(player: number, hasVertical?: boolean): number
  • Parameters

    • player: number

      player uid

    • optionalhasVertical: boolean

      if true can return vertical sides as well

    Returns number

    block side opposite to player rotation.

getBlockType

  • getBlockType(name: string): Nullable<BlockType>
  • Parameters

    • name: string

      block type name

    Returns Nullable<BlockType>

    BlockType object by name

getInstanceOf

  • getInstanceOf(blockID: string | number): Nullable<BlockBase>
  • Parameters

    • blockID: string | number

      block numeric or string id

    Returns Nullable<BlockBase>

    instance of block class if it exists

getPlacePosition

  • getPlacePosition(coords: ItemUseCoordinates, block: Tile, region: BlockSource): Vector
  • Parameters

    • coords: ItemUseCoordinates

      click coords

    • block: Tile

      touched block

    • region: BlockSource

      BlockSource

    Returns Vector

    block place position for click coords in world.

registerBlock

  • Registers instance of BlockBase class and creates block for it.


    Parameters

    Returns BlockBase

    the same BlockBase instance with isDefined flag set to true

registerBlockFuncs

  • registerBlockFuncs(blockID: string | number, blockFuncs: BlockBehavior): void
  • Registers all block functions.


    Parameters

    • blockID: string | number

      block numeric or string id

    • blockFuncs: BlockBehavior

      object containing block functions

    Returns void

registerDrop

  • registerDrop(blockID: string | number, dropFunc: DropFunction, level?: number): void
  • Registers drop function for block.


    Parameters

    • blockID: string | number

      block numeric or string id

    • dropFunc: DropFunction

      drop function

    • optionallevel: number

      mining level

    Returns void

registerOnExplosionFunction

  • registerOnExplosionFunction(blockID: string | number, func: PopResourcesFunction): void
  • Registers function called when block is destroyed by explosion.


    Parameters

    • blockID: string | number

      block numeric or string id

    • func: PopResourcesFunction

      function on explosion

    Returns void

setBaseBlock

  • setBaseBlock(blockID: string | number, baseBlock: number): void
  • Sets the block type of another block, which allows to inherit some of its properties.


    Parameters

    • blockID: string | number

      block numeric or string id

    • baseBlock: number

      id of the block to inherit type

    Returns void

setBlockColorSource

  • setBlockColorSource(blockID: string | number, color: ColorSource): void
  • Makes block use biome color when displayed on the vanilla maps.


    Parameters

    • blockID: string | number

      block numeric or string id

    • color: ColorSource

      block color source

    Returns void

setBlockMaterial

  • setBlockMaterial(blockID: string | number, material: string, level?: number): void
  • Registers block material and digging level. If you are registering block with 'stone' material ensure that its block type has baseBlock id 1 to be correctly destroyed by pickaxes.


    Parameters

    • blockID: string | number

      block numeric or string id

    • material: string

      material name

    • optionallevel: number

      block's digging level

    Returns void

setDestroyLevel

  • setDestroyLevel(blockID: string | number, level: number): void
  • Sets mining level for block.


    Parameters

    • blockID: string | number

      block numeric or string id

    • level: number

      mining level

    Returns void

setDestroyTime

  • setDestroyTime(blockID: string | number, time: number): void
  • Sets destroy time for the block with specified id.


    Parameters

    • blockID: string | number

      block numeric or string id

    • time: number

      block destroy time

    Returns void

setExplosionResistance

  • setExplosionResistance(blockID: string | number, resistance: number): void
  • Specifies how block resists to the explosions.


    Parameters

    • blockID: string | number

      block numeric or string id

    • resistance: number

      integer value, default is 3

    Returns void

setFriction

  • setFriction(blockID: string | number, friction: number): void
  • Sets block friction. It specifies how player walks on the block. The higher the friction is, the more difficult it is to change speed and direction.


    Parameters

    • blockID: string | number

      block numeric or string id

    • friction: number

      float value, default is 0.6

    Returns void

setLightLevel

  • setLightLevel(blockID: string | number, lightLevel: number): void
  • Sets level of the light emitted by the block.


    Parameters

    • blockID: string | number

      block numeric or string id

    • lightLevel: number

      value from 0 (no light) to 15

    Returns void

setLightOpacity

  • setLightOpacity(blockID: string | number, lightOpacity: number): void
  • Specifies how opaque block is.


    Parameters

    • blockID: string | number

      block numeric or string id

    • lightOpacity: number

      Value from 0 to 15 which will be substracted from the light level when the light passes through the block

    Returns void

setMapColor

  • setMapColor(blockID: string | number, color: number): void
  • Sets block color when displayed on the vanilla maps.


    Parameters

    • blockID: string | number

      block numeric or string id

    • color: number

      map color of the block

    Returns void

setRenderAllFaces

  • setRenderAllFaces(blockID: string | number, renderAllFaces: boolean): void
  • Sets rendering of the block faces.


    Parameters

    • blockID: string | number

      block numeric or string id

    • renderAllFaces: boolean

      If true, all block faces are rendered, otherwise back faces are not rendered (for optimization purposes). Default is false

    Returns void

setRenderLayer

  • setRenderLayer(blockID: string | number, renderLayer: number): void
  • Specifies the layer that is used to render the block.


    Parameters

    • blockID: string | number

      block numeric or string id

    • renderLayer: number

      default is 4

    Returns void

setRenderType

  • setRenderType(blockID: string | number, renderType: number): void
  • Sets render type of the block.


    Parameters

    • blockID: string | number

      block numeric or string id

    • renderType: number

      default is 0 (full block), use other values to change block's model

    Returns void

setRotationFunction

  • setRotationFunction(id: string | number, hasVertical?: boolean, placeSound?: string): void
  • Registers place function for block with rotation.


    Parameters

    • id: string | number

      block numeric or string id

    • optionalhasVertical: boolean

      true if the block has vertical facings, false otherwise.

    • optionalplaceSound: string

    Returns void

setSolid

  • setSolid(blockID: string | number, isSolid: boolean): void
  • Sets block to be transparent or opaque.


    Parameters

    • blockID: string | number

      block numeric or string id

    • isSolid: boolean

      if true, sets block to be opaque.

    Returns void

setSoundType

  • setSoundType(blockID: string | number, sound: Sound): void
  • Sets sound type of the block.


    Parameters

    • blockID: string | number

      block numeric or string id

    • sound: Sound

      block sound type

    Returns void

setTranslucency

  • setTranslucency(blockID: string | number, translucency: number): void
  • Specifies rendering of shadows on the block.


    Parameters

    • blockID: string | number

      block numeric or string id

    • translucency: number

      float value from 0 (no shadows) to 1

    Returns void