Namespace Block

Module used to create and manipulate blocks. The difference between terms "block" and "tile" is in it's 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 to perform conversion between block and it item variation.

Functions

  • 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).

    2.2.1b95

  • Parameters

    • id: number

    Returns boolean

    Whether the block of given ID can contain liquid inside.

    2.2.1b95

  • Converts tile ID to the block ID.

    Parameters

    • id: number

      numeric tile ID

    Returns number

    Numeric block ID corresponding to the given tile ID.

  • 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

    • OptionalblockType: string | SpecialType

      Block.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

    • OptionalblockType: 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

    • OptionalblockType: 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

    2.2.1b102

  • Creates a new special type using specified params and optionally registers it by name.

    Parameters

    • description: SpecialType

      special type properties

    • Optionalname: 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.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Destroy time of the block, in ticks.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Explosion resistance of the block.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Friction of the block.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Light level, emitted by block, from 0 to 15.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Light opacity of the block, from 0 to 15.

  • Parameters

    • id: number

      numeric block ID

    Returns number

    Color specified block is displayed on the vanilla maps.

  • Parameters

    • id: number

    Returns number

    Given block's material numeric ID.

    2.2.1b101 (TODO: fix in changelog)

  • Parameters

    • id: string | number

      string ID of the block

    Returns number

    Block numeric ID by it's string ID or just returns it's numeric ID if input was a numeric ID.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Render layer of the block.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Render type of the block.

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Translucency of the block.

  • Parameters

    • id: number

      numeric block ID

    Returns boolean

    true, if the specified block ID is a vanilla block.

  • Parameters

    • numericId: number

      numeric block ID

    Returns boolean

    true, if block is solid, false otherwise.

  • Defines custom behavior when the player clicks on the block with definite ID.

    Parameters

    • id: 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

    2.2.1b103 (TODO: changelog says it 104)

  • Defines custom behavior when the player clicks on the block with definite ID.

    Parameters

    • numericId: number

      block's numeric ID

    • func: ClickFunction

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

    Returns void

    2.2.1b103 (TODO: changelog says it 104)

  • Registers function used by Core Engine to determine block drop for the specified block ID.

    Parameters

    • id: string | number

      tile string or numeric ID

    • dropFunc: DropFunction

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

    • Optionallevel: 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.

  • Registers function used by Core Engine to determine block drop for the specified block ID.

    Parameters

    • numericId: number

      tile numeric ID

    • dropFunc: DropFunction

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

    • Optionallevel: 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.

  • Registers function on entity being inside the block. Can be used to create portals.

    Parameters

    • id: string | number

      tile string or numeric ID

    • func: EntityInsideFunction

      function to be called when entity is inside the block

    Returns boolean

    true, if the function was registered correctly, false otherwise.

    2.0.2b26

  • Registers function on entity being inside the block. Can be used to create portals.

    Parameters

    • numericId: number

      tile string or numeric ID

    • func: EntityInsideFunction

      function to be called when entity is inside the block

    Returns boolean

    true, if the function was registered correctly, false otherwise.

    2.0.2b26

  • Registers function on entity step on the block.

    Parameters

    • id: string | number

      tile string or numeric ID

    • func: EntityStepOnFunction

      function to be called when entity step on the block

    Returns boolean

    true, if the function was registered correctly, false otherwise.

    2.3.1b116 (implemented in 2.0.2b26)

  • Registers function on entity step on the block.

    Parameters

    • numericId: number

      tile numeric ID

    • func: EntityStepOnFunction

      function to be called when entity step on the block

    Returns boolean

    true, if the function was registered correctly, false otherwise.

    2.3.1b116 (implemented in 2.0.2b26)

  • Registers function on neighbour blocks updates.

    Parameters

    • id: string | number

      tile string or numeric ID

    • func: NeighbourChangeFunction

      function to be called when neighbour block updates

    Returns boolean

    true, if the function was registered correctly, false otherwise.

    2.0.2b26

  • Registers function on neighbour blocks updates.

    Parameters

    Returns boolean

    true, if the function was registered correctly, false otherwise.

    2.0.2b26

  • Registers function to be called when the block is placed in the world.

    Parameters

    • id: string | number

      block numeric or string ID

    • func: PlaceFunction

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

    Returns void

  • Registers function to be called when the block is placed in the world.

    Parameters

    • numericId: number

      block numeric ID

    • func: PlaceFunction

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

    Returns void

  • Registered function used by Core Engine to determine block drop for the specified block ID.

    Parameters

    • id: 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.

  • Registered function used by Core Engine to determine block drop for the specified block ID.

    Parameters

    • numericId: number

      tile 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.

  • Makes block invoke callback randomly depending on game speed. Occurs more often then Block.setRandomTickCallback and only if the block is not far away from player.

    Parameters

    Returns 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 boolean

    true if specified string or numeric ID exists, false otherwise.

  • Sets block box shape, like Block.setShape, but in voxel objects for each coordinate.

    Parameters

    • id: number

      block numeric ID

    • pos1: Vector

      block lower corner position

    • pos2: Vector

      block upper conner position

    • Optionaldata: number

      block optional data (or -1)

    Returns void

  • Registers a default destroy function for the specified block, considering it's digging level.

    Parameters

    • id: string | number

      tile string or numeric ID

    • level: number

      digging level of the block

    • OptionalresetData: boolean

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

    Returns void

  • Registers a default destroy function for the specified block, considering it's digging level.

    Parameters

    • numericId: number

      tile numeric ID

    • level: number

      digging level of the block

    • OptionalresetData: boolean

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

    Returns 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

  • Parameters

    Returns void

    Better performance should be inherited by manually manipulation with properties and special type.

  • 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

  • Makes block accept redstone signal.

    Parameters

    • nameID: string | number

      block numeric or string ID

    • data: number

      block data, currently not used

    • isRedstone: boolean

      if true, the redstone changes at the block will notify the "RedstoneSignal" callback

    Returns void

  • Sets block box shape via scalar coordinates, usually presented in voxels (1/16 of block).

    Parameters

    • id: number

      block numeric ID

    • x1: number
    • y1: number
    • z1: number
    • x2: number
    • y2: number
    • z2: number
    • Optionaldata: number

      block optional data (or -1)

    Returns 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

  • Removes all the redstone functionality from the block.

    Parameters

    • nameID: string | number

      block numeric or string ID

    Returns void

    2.0.2b23

  • Makes block emit redstone signal.

    Parameters

    • nameID: string | number

      block numeric or string ID

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void

    2.0.2b23

  • Makes block receive redstone signals via "RedstoneSignal" callback.

    Parameters

    • nameID: string | number

      block numeric or string ID

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void

    2.0.2b23

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"

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