Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Type Aliases

ColorSource: "grass" | "leaves" | "water"
Sound: "normal" | "gravel" | "wood" | "grass" | "metal" | "stone" | "cloth" | "glass" | "sand" | "snow" | "ladder" | "anvil" | "slime" | "silent" | "itemframe" | "turtle_egg" | "bamboo" | "bamboo_sapling" | "lantern" | "scaffolding" | "sweet_berry_bush" | "default"

Functions

  • canBeExtraBlock(id: number): boolean
  • Parameters

    • id: number

    Returns boolean

    whether the block of given id can be an extra block (it's the block that can be set inside of another blocks, for ex. water and other liquids)

  • canContainLiquid(id: number): boolean
  • Parameters

    • id: number

    Returns boolean

    whether the block of given id can contain liquid inside

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

  • 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: string | SpecialType

      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

  • 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: string | SpecialType

      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

  • Creates new liquid block using specified params

    Parameters

    • nameID: string

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

    • defineData: LiquidDescriptor

      object containing all needed params to describe your custom liquid block. There you can specify custom name IDs for static and dynamic liquid blocks separately, and if you do this, you have to register those name IDs via IDRegistry.genBlockID before using them

    • Optional blockType: string | SpecialType

      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(description: SpecialType, nameKey?: string): string
  • 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 string

    special type name

  • 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

    • region: BlockSource

    Returns ItemInstanceArray[]

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

  • getDestroyTime(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    destroy time of the block, in ticks

  • getExplosionResistance(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    explosion resistance of the block

  • getFriction(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    friction of the block

  • getLightLevel(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    light level, emitted by block, from 0 to 15

  • getLightOpacity(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    light opacity of the block, from 0 to 15

  • getMapColor(id: number): number
  • Parameters

    • id: number

      numeric block id

    Returns number

    the color specified block is displayed on the vanilla maps

  • getMaterial(id: number): number
  • getNumericId(id: string | number): number
  • Parameters

    • id: string | number

      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(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    render layer of the block

  • getRenderType(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    render type of the block

  • getTranslucency(numericID: number): number
  • Parameters

    • numericID: number

      numeric block id

    Returns number

    translucency of the block

  • isNativeTile(id: number): boolean
  • Parameters

    • id: number

      numeric block id

    Returns boolean

    true, if the specified block id is a vanilla block

  • isSolid(numericID: number): boolean
  • Parameters

    • numericID: number

      numeric block id

    Returns boolean

    true, if block is solid, false otherwise

  • registerClickFunction(nameId: string | number, func: ClickFunction): void
  • Defines custom behavior when the player clicks on the block with definite id

    Parameters

    • nameId: string | number

      block's numeric or string id

    • func: ClickFunction

      function that will be called when the player clicks the block with given id

    Returns void

  • registerClickFunctionForID(id: number, func: ClickFunction): void
  • 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

      tile string or numeric id

    • 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(numericID: number, dropFunc: DropFunction, level?: number): boolean
  • Registers function on entity being inside the block. Can be used to create portals.

    Parameters

    • nameID: string | number
    • func: EntityInsideFunction

      function to be called when entity is inside the block

    Returns boolean

    true, if the function was registered correctly, false otherwise

  • Registers function on entity step on the block.

    Parameters

    Returns boolean

    true, if the function was registered correctly, false otherwise

  • Registers function on neighbour blocks updates

    Parameters

    Returns boolean

    true, if the function was registered correctly, false otherwise

  • 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(block: number, func: PlaceFunction): void
  • Registered 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 boolean

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

  • setBlockChangeCallbackEnabled(id: number, enabled: boolean): void
  • setBlockMaterial(nameID: string | number, material: string, level: number): boolean
  • 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 boolean

    true if specified string or numeric id exists, false otherwise

  • 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(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(id: number, level: number, resetData?: boolean): void
  • 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

  • setEntityInsideCallbackEnabled(id: number, enabled: boolean): void
  • setEntityStepOnCallbackEnabled(id: number, enabled: boolean): void
  • setNeighbourChangeCallbackEnabled(id: number, enabled: boolean): void
  • setPrototype(nameID: string | number, Prototype: any): number
  • deprecated

    No longer supported

    Parameters

    • nameID: string | number
    • Prototype: any

    Returns number

  • 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

  • setRedstoneConnector(id: number, data: number, redstone: boolean): void
  • setRedstoneEmitter(id: number, data: number, redstone: boolean): void
  • setRedstoneTile(nameID: string | number, data: number, isRedstone: boolean): void
  • 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(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(id: string | number): void
  • Removes all the redstone functionality from the block

    Parameters

    • id: string | number

      block numeric or string id

    Returns void

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

    Parameters

    • id: string | number

      block numeric or string id

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void

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

    Parameters

    • id: string | number

      block numeric or string id

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void

Generated using TypeDoc