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

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.

Index

Interfaces

AnimateTickFunction

  • AnimateTickFunction(x: number, y: number, z: number, id: number, data: number): void
  • Parameters

    • x: number
    • y: number
    • z: number
    • id: number

      block numeric identifier

    • data: number

      block data

    Returns void

BlockAtlasTextureCoords

BlockAtlasTextureCoords:

u1

u1: number

u2

u2: number

v1

v1: number

v2

v2: number

BlockLegacyPrototype

BlockLegacyPrototype:

Once upon a time, a new way of registering blocks, however, in current state, either does not work or is undesirable to use.

optionalgetCategory

getCategory?: (item: null) => number

Unused at all.


Type declaration

    • (item: null): number
    • Parameters

      • item: null

      Returns number

optionalgetDestroyLevel

getDestroyLevel?: (item: null) => number

Type declaration

    • (item: null): number
    • Parameters

      • item: null

      Returns number

optionalgetDrop

getDrop?: (coords: Vector, id: number, data: number, diggingLevel: number, enchant: any) => ItemInstanceArray[]

Type declaration

optionalgetEnchant

getEnchant?: (item: null) => number

Unused at all.


Type declaration

    • (item: null): number
    • Parameters

      • item: null

      Returns number

optionalgetMaterial

getMaterial?: (item: null) => number

Type declaration

    • (item: null): number
    • Parameters

      • item: null

      Returns number

optionalgetProperties

getProperties?: (item: null) => object

Unused at all.


Type declaration

    • (item: null): object
    • Parameters

      • item: null

      Returns object

optionalgetShape

getShape?: (item: null) => number[]

Type declaration

    • (item: null): number[]
    • Parameters

      • item: null

      Returns number[]

optionalgetSpecialType

getSpecialType?: (item: null) => SpecialType

Type declaration

getVariations

getVariations: (item: null) => BlockVariation[]

Type declaration

optionalinit

init?: () => void

Type declaration

    • (): void
    • Returns void

optionalisEnchanted

isEnchanted?: (item: null) => boolean

Unused at all.


Type declaration

    • (item: null): boolean
    • Parameters

      • item: null

      Returns boolean

optionalisStackedByData

isStackedByData?: (item: null) => boolean

Unused at all.


Type declaration

    • (item: null): boolean
    • Parameters

      • item: null

      Returns boolean

optionalonItemUsed

onItemUsed?: (coords: Vector, item: ItemInstance, block: Tile) => void

Unused at all.


Type declaration

optionalonPlaced

onPlaced?: (coords: Vector, item: ItemInstance, block: Tile) => void

Incorrect function, it will considered as BlockLegacyPrototype.getDrop


Type declaration

type

type: createBlock | createBlockWithRotation

BlockVariation

BlockVariation:

Object used to represent single block variation.

optionalinCreative

inCreative?: boolean = false

If true, block variation will be added to creative inventory.

optionalname

name?: string = “Unknown Block”

Variation name, displayed as item name everywhere.

texture

texture: [string, number][]

Variation textures, array containing pairs of texture name and data. Texture file should be located in items-opaque folder and it's name should be in the format: "name_data", e.g. if the file name is "ingot_copper_0", you should specify an array ["ingot_copper", 0].

@remarks

There should be from one to six texture pairs in the array, if less then six variations are specified, the last texture is used for missing textures. The sides go in the following order:

texture: [
["name1", index1], // bottom (Y: -1)
["name2", index2], // top (Y: +1)
["name3", index3], // back (X: -1)
["name4", index4], // front (X: +1)
["name5", index5], // left (Z: -1)
["name6", index6] // right (Z: +1)
]

ClickFunction

DropFunction

EntityInsideFunction

  • EntityInsideFunction(blockCoords: Vector, block: Tile, entity: number): void
  • Parameters

    Returns void

EntityStepOnFunction

  • EntityStepOnFunction(coords: Vector, block: Tile, entity: number): void
  • Parameters

    Returns void

LiquidDescriptor

LiquidDescriptor:

Object to specify needed params for custom liquid block.

@since

2.2.1b102

optionalbucket

bucket?: { emptyId?: number; emptySound?: string; fillSound?: string; id?: string; isTech?: boolean; name?: string; texture: { meta?: number; name: string } }

Optional section, if added, this will create fully functional (including dispensers) bucket items.

@since

2.2.1b103


Type declaration

  • optionalemptyId?: number

    An item that can capture liquid (including when using a dispenser and obtaining it with your hand).

    @since

    2.3.1b116

  • optionalemptySound?: string
  • optionalfillSound?: string
  • optionalid?: string

    Optional, name ID for bucket item.

  • optionalisTech?: boolean

    If true, bucket cannot be obtained from creative inventory.

  • optionalname?: string

    Name of the filled with liquid bucket to be displayed.

  • texture: { meta?: number; name: string }
    • optionalmeta?: number
    • name: string

flowing

flowing: { id?: string; texture: [string, number] }

Object to describe dynamic liquid block texture, and name ID additionally.


Type declaration

  • optionalid?: string

    Optional, name ID for dynamic liquid block.

  • texture: [string, number]

    Unlike static liquid blocks, for dynamic ones, texture must look like "texture.liquid.png" (with no index).

optionalinCreative

inCreative?: boolean = false

Whether to add liquid block to creative inventory.

optionalisRenewable

isRenewable?: boolean = false

True if the liquid will be renewable, as water.

@since

2.2.1b103

optionalmodelTextures

modelTextures?: string

name

name: string

Name of the block to be displayed.

still

still: { id?: string; texture: [string, number] }

Object to describe static liquid block texture, and name ID additionally.


Type declaration

  • optionalid?: string

    Optional, name ID for static liquid block.

  • texture: [string, number]

    For static liquid block, textures must be of standard block texture format.

optionaltickDelay

tickDelay?: number = 10

Delay between liquid spreading steps in ticks.

optionaluiTextures

uiTextures?: string

NeighbourChangeFunction

PlaceFunction

PopResourcesFunction

  • PopResourcesFunction(blockCoords: Vector, block: Tile, region: BlockSource, explosionRadius: number, i: number): void

RandomTickFunction

  • RandomTickFunction(x: number, y: number, z: number, id: number, data: number, region: BlockSource): void
  • Parameters

    • x: number
    • y: number
    • z: number
    • id: number

      block numeric identifier

    • data: number

      block data

    • region: BlockSource

      block source instance

    Returns void

SpecialType

SpecialType:

Special types are used to set properties to the block. Unlike items, blocks properties are defined using special types, due to old Inner Core's block IDs limitations.

optionalbase

base?: number = 0

Vanilla block ID to inherit some of the properties.

optionalcan_be_extra_block

can_be_extra_block?: boolean = false

Whether or not block may overlay different block, like water overlapping fillable blocks.

@since

2.2.1b95

optionalcan_contain_liquid

can_contain_liquid?: boolean = false

Whether or not block may filled by water bucket or other custom fillable liquids.

@since

2.2.1b95

optionalcolor_source

color_source?: ColorSource

Makes block use biome color source when displayed on the vanilla maps.

@since

2.1.0b56

optionaldestroytime

destroytime?: number

Specifies the time required to destroy the block, in ticks.

optionalexplosionres

explosionres?: number = 3

Specifies how block resists to the explosions.

optionalfriction

friction?: number = 0.6000000238418579

Specifies how player walks on this block. The higher the friction is, the more difficult it is to change speed and direction.

optionallightlevel

lightlevel?: number = 0

If non-zero value is used, the block emits light of that value. Default is no lighting, use values from 1 to 15 to set light level.

optionallightopacity

lightopacity?: number = 0

Specifies how opaque the block is. Default is transparent, use values from 1 to 15 to make the block opaque.

optionalmapcolor

mapcolor?: number

Block color when displayed on the vanilla maps.

@since

2.0.2b23

optionalmaterial

material?: number = 3

Block material constant to be inherited.

optionalname

name?: string

Unique string identifier of the SpecialType.

optionalrenderallfaces

renderallfaces?: boolean = false

If true, all block faces are rendered, otherwise back faces are not rendered, like for glass.

optionalrenderlayer

renderlayer?: number = 4

Specifies the layer that is used to render the block.

optionalrendertype

rendertype?: number = 0

Sets render type of the block. Default is full block, use other values to change block's shape.

optionalsolid

solid?: boolean = false

If true, the block is not transparent.

optionalsound

sound?: Sound

Specifies sounds of the block, one of Block.Sound.

@since

2.0.2b25

optionaltranslucency

translucency?: number = 0

If non-zero value is used, the shadows will be rendered on the block. Default is zero, allows float values from 0 to 1.

Type Aliases

ColorSource

ColorSource: grass | leaves | water

Sound

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

  • canBeExtraBlock(id: number): boolean
  • @since

    2.2.1b95


    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

  • canContainLiquid(id: number): boolean
  • @since

    2.2.1b95


    Parameters

    • id: number

    Returns boolean

    Whether the block of given ID can contain liquid inside.

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

    • 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

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

    • 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

createLiquidBlock

  • Creates new liquid block using specified params.

    @since

    2.2.1b102


    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

createSpecialType

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

getBlockAtlasTextureCoords

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

    • region: BlockSource

    Returns ItemInstanceArray[]

    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.

getDropFunction


  • Parameters

    • id: number

    Returns Block.DropFunction

    Drop function of the block with given numeric ID.

getExplosionResistance

  • getExplosionResistance(numericId: number): number

  • Parameters

    • numericId: number

      numeric block ID

    Returns number

    Explosion 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, emitted 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

    Color specified block is displayed on the vanilla maps.

getMaterial

  • getMaterial(id: number): number
  • @since

    2.2.1b101 (TODO: fix in changelog)


    Parameters

    • id: number

    Returns number

    Given block's material numeric ID.

getNumericId

  • getNumericId(id: string | number): number

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

getPlaceFunc


  • Parameters

    • id: number

    Returns Block.PlaceFunction

    Place function of the block with given numeric ID, or undefined if it was not specified.

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.

registerClickFunction

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

    @since

    2.2.1b103 (TODO: changelog says it 104)


    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

registerClickFunctionForID

  • registerClickFunctionForID(numericId: number, func: ClickFunction): void
  • Defines custom behavior when the player clicks on the block with definite ID.

    @since

    2.2.1b103 (TODO: changelog says it 104)


    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

registerDropFunction

  • registerDropFunction(id: string | number, dropFunc: DropFunction, level?: number): boolean
  • 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.

registerDropFunctionForID

  • registerDropFunctionForID(numericId: number, dropFunc: DropFunction, level?: number): boolean
  • 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.

registerEntityInsideFunction

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

    @since

    2.0.2b26


    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.

registerEntityInsideFunctionForID

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

    @since

    2.0.2b26


    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.

registerEntityStepOnFunction

  • Registers function on entity step on the block.

    @since

    2.3.1b116 (implemented in 2.0.2b26)


    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.

registerEntityStepOnFunctionForID

  • Registers function on entity step on the block.

    @since

    2.3.1b116 (implemented in 2.0.2b26)


    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.

registerNeighbourChangeFunction

  • Registers function on neighbour blocks updates.

    @since

    2.0.2b26


    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.

registerNeighbourChangeFunctionForID

  • Registers function on neighbour blocks updates.

    @since

    2.0.2b26


    Parameters

    Returns boolean

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

registerPlaceFunction

  • registerPlaceFunction(id: string | number, func: PlaceFunction): void
  • 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

registerPlaceFunctionForID

  • registerPlaceFunctionForID(numericId: number, func: PlaceFunction): 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

registerPopResourcesFunction

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

registerPopResourcesFunctionForID

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

setAnimateTickCallback

  • 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

setBlockMaterial

  • 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

  • setBlockShape(id: number, pos1: Vector, pos2: Vector, data?: number): void
  • 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

setDestroyLevel

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

setDestroyLevelForID

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

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

  • @deprecated

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


    Parameters

    Returns void

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
  • Makes block accept redstone signal.

    @deprecated

    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

setShape

  • setShape(id: number, x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, data?: number): 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

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(nameID: string | number): void
  • Removes all the redstone functionality from the block.

    @since

    2.0.2b23


    Parameters

    • nameID: string | number

      block numeric or string ID

    Returns void

setupAsRedstoneEmitter

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

    @since

    2.0.2b23


    Parameters

    • nameID: string | number

      block numeric or string ID

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void

setupAsRedstoneReceiver

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

    @since

    2.0.2b23


    Parameters

    • nameID: string | number

      block numeric or string ID

    • connectToRedstone: boolean

      if true, redstone wires will connect to the block

    Returns void