Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Block

Module used to create and manipulate blocks. The difference between terms "block" and "tile" is in its usage: blocks are used in the inventory, tiles are placed in the world and have different ids for some vanilla blocks. Use Block.convertBlockToItemId and Block.convertItemToBlockId

Index

Functions

convertBlockToItemId

  • convertBlockToItemId(id: number): number
  • Converts tile id to the block id

    Parameters

    • id: number

      numeric tile id

    Returns number

    numeric block id corresponding to the given tile id

convertItemToBlockId

  • convertItemToBlockId(id: number): number
  • Converts block id to the tile id

    Parameters

    • id: number

      numeric tile id

    Returns number

    numeric tile id corresponding to the given block id

createBlock

  • Creates new block using specified params

    Parameters

    • nameID: string

      string id of the block. You should register it via IDRegistry.genBlockID call first

    • defineData: BlockVariation[]

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

    • Optional blockType: SpecialType | string

      SpecialType object, either java-object returned by Block.createSpecialType or js-object with the required properties, you can also pass special type name, if the type was previously registered

    Returns void

createBlockWithRotation

  • Creates new block using specified params, creating four variations for each of the specified variations to be able to place it facing flayer with the front side and defines the appropriate behavior. Useful for different machines and mechanisms

    Parameters

    • nameID: string

      string id of the block. You should register it via IDRegistry.genBlockID call first

    • defineData: BlockVariation[]

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

    • Optional blockType: SpecialType | string

      SpecialType object, either java-object returned by Block.createSpecialType or js-object with the required properties, you can also pass special type name, if the type was previously registered

    Returns void

createSpecialType

  • createSpecialType(description: SpecialType, nameKey?: string): number
  • Creates a new special type using specified params and registers it by name

    Parameters

    • description: SpecialType

      special type properties

    • Optional nameKey: string

      string name to register the special type

    Returns number

getBlockDropViaItem

  • Gets drop for the specified block. Used mostly by Core Engine's ToolAPI, though, can be useful in the mods, too

    Parameters

    • block: Tile

      block info

    • item: ItemInstance

      item that was (or is going to be) used to break the block

    • coords: Vector

      coordinates where the block was (or is going to be) broken

    Returns [number, number, number][]

    block drop, the array of arrays, each containing three values: id, count and data respectively

getDestroyTime

  • getDestroyTime(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    destroy time of the block, in ticks

getExplosionResistance

  • getExplosionResistance(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    explostion resistance of the block

getFriction

  • getFriction(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    friction of the block

getLightLevel

  • getLightLevel(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    light level, emmited by block, from 0 to 15

getLightOpacity

  • getLightOpacity(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    light opacity of the block, from 0 to 15

getMapColor

  • getMapColor(id: number): number
  • Parameters

    • id: number

      numeric block id

    Returns number

    the color specified block is displayed on the vanilla maps

getNumericId

  • getNumericId(id: string): number
  • Parameters

    • id: string

      string id of the block

    Returns number

    block numeric id by its string id or just returns its numeric id if input was a numeric id

getRenderLayer

  • getRenderLayer(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    render layer of the block

getRenderType

  • getRenderType(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    render type of the block

getTranslucency

  • getTranslucency(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    translucency of the block

isNativeTile

  • isNativeTile(id: number): boolean
  • Parameters

    • id: number

      numeric block id

    Returns boolean

    true, if the specified block id is a vanilla block

isSolid

  • isSolid(numericID: number): boolean
  • Parameters

    • numericID: number

      numeric block id

    Returns boolean

    true, if block is solid, false otherwise

registerDropFunction

  • registerDropFunction(nameID: string | number, dropFunc: DropFunction, level?: number): boolean
  • Registers function used by Core Engine to determine block drop for the specified block id

    Parameters

    • nameID: string | number
    • dropFunc: DropFunction

      function to be called to determine what will be dropped when the block is broken

    • Optional level: number

      if level is specified and is not 0, digging level of the block is additionally set

    Returns boolean

    true, if specified string or numeric id exists and the function was registered correctly, false otherwise

registerDropFunctionForID

  • registerDropFunctionForID(numericID: number, dropFunc: DropFunction, level?: number): boolean

registerEntityInsideFunctionForID

  • registerEntityInsideFunctionForID(numericID: number, entityinsideFunc: EntityInsideFunction): void

registerNeighbourChangeFunction

registerPlaceFunction

  • registerPlaceFunction(nameID: string | number, func: PlaceFunction): void
  • Registers function to be called when the block is placed in the world

    Parameters

    • nameID: string | number

      block numeric or string id

    • func: PlaceFunction

      function to be called when the block is placed in the world

    Returns void

registerPlaceFunctionForID

  • registerPlaceFunctionForID(block: number, func: PlaceFunction): void

registerPopResourcesFunction

  • Registeres function used by Core Engine to determine block drop for the specified block id

    Parameters

    • nameID: string | number

      tile string or numeric id

    • func: PopResourcesFunction

      function to be called when a block in the world is broken by environment (explosions, pistons, etc.)

    Returns void

    true, if specified string or numeric id exists and the function was registered correctly, false otherwise

registerPopResourcesFunctionForID

setAnimateTickCallback

setBlockMaterial

  • setBlockMaterial(nameID: string | number, material: string, level: number): void
  • Registers material and digging level for the specified block

    Parameters

    • nameID: string | number

      block numeric or string id

    • material: string

      material name

    • level: number

      block's digging level

    Returns void

setBlockShape

  • setBlockShape(id: number, pos1: Vector, pos2: Vector, data?: number): void
  • Sets block box shape

    Parameters

    • id: number

      block numeric id

    • pos1: Vector

      block lower corner position, in voxels (1/16 of the block)

    • pos2: Vector

      block upper conner position, in voxels (1/16 of the block)

    • Optional data: number

      block data

    Returns void

setDestroyLevel

  • setDestroyLevel(nameID: string | number, level: number, resetData?: boolean): void
  • Registers a default destroy function for the specified block, considering its digging level

    Parameters

    • nameID: string | number

      tile string id

    • level: number

      digging level of the block

    • Optional resetData: boolean

      if true, the block is dropped with data equals to 0

    Returns void

setDestroyLevelForID

  • setDestroyLevelForID(id: number, level: number, resetData?: boolean): void

setDestroyTime

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

    Parameters

    • nameID: string | number

      string or numeric block id

    • time: number

      destroy time for the block, in ticks

    Returns void

setPrototype

  • setPrototype(nameID: string | number, Prototype: any): number
  • deprecated

    No longer supported

    Parameters

    • nameID: string | number
    • Prototype: any

    Returns number

setRandomTickCallback

  • Makes block invoke callback randomly depending on game speed

    Parameters

    • id: number

      block id to register for random ticks

    • callback: RandomTickFunction

      function to be called on random block tick

    Returns void

setRedstoneTile

  • setRedstoneTile(nameID: string | number, data: number, isRedstone: boolean): void

setShape

  • setShape(id: number, x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, data?: number): void
  • Same as Block.setBlockShape, but accepts coordinates as scalar params, not objects

    Parameters

    • id: number

      block numeric id

    • x1: number
    • y1: number
    • z1: number
    • x2: number
    • y2: number
    • z2: number
    • Optional data: number

      block data

    Returns void

setTempDestroyTime

  • setTempDestroyTime(numericID: number, time: number): void
  • Temporarily sets destroy time for block, saving the old value for the further usage

    Parameters

    • numericID: number

      numeric block id

    • time: number

      new destroy time in ticks

    Returns void

setupAsNonRedstoneTile

  • setupAsNonRedstoneTile(id: number | string): void
  • Removes all the redstone functionality from the block

    Parameters

    • id: number | string

      block numeric or string id

    Returns void

setupAsRedstoneEmitter

  • setupAsRedstoneEmitter(id: number | string, connectToRedstone: boolean): void
  • Makes block emit redstone signal

    Parameters

    • id: number | string

      block numeric or string id

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void

setupAsRedstoneReceiver

  • setupAsRedstoneReceiver(id: number | string, connectToRedstone: boolean): void
  • Makes block receive redstone signals via "RedstoneSignal" callback

    Parameters

    • id: number | string

      block numeric or string id

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void

Generated using TypeDoc