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

BlockRotative

Base class for block

Hierarchy

Index

Constructors

constructor

  • new BlockRotative(stringID: string, blockType?: string | BlockType, hasVerticalFacings?: boolean): BlockRotative
  • Parameters

    • stringID: string
    • optionalblockType: string | BlockType
    • optionalhasVerticalFacings: boolean

    Returns BlockRotative

Properties

blockMaterial

blockMaterial: string

Block material

blockType

blockType: BlockType

Block properties

category

category: number

Item category

hasVerticalFacings

hasVerticalFacings: boolean

readonlyid

id: number

Block numeric id

isDefined

isDefined: boolean

Flag that defines whether block for this instance was defined or not.

miningLevel

miningLevel: number

Block mining level

shapes

shapes: {}

Shapes of block variations


Type declaration

readonlystringID

stringID: string

Block string id

variations

variations: BlockVariation[]

Array of block variations

Methods

addVariation

  • addVariation(name: string, texture: [string, number][], inCreative?: boolean): void
  • Adds variation for the block.


    Parameters

    • name: string

      item name

    • texture: [string, number][]

      block texture

    • optionalinCreative: boolean

      true if should be added to creative inventory

    Returns void

createBlock

  • createBlock(): void
  • Registers block in game.


    Returns void

getDrop

  • getDrop(coords: Vector, block: Tile, level: number, enchant: EnchantData, item: ItemStack, region: BlockSource): ItemInstanceArray[]
  • Method used to get drop from the block


    Parameters

    • coords: Vector

      block coords

    • block: Tile

      block id and data

    • level: number

      tool mining level

    • enchant: EnchantData

      tool enchant data

    • item: ItemStack

      item instance

    • region: BlockSource

      BlockSource object

    Returns ItemInstanceArray[]

    drop items array

onBreak

  • onBreak(coords: Vector, block: Tile, region: BlockSource): void
  • Method called when the block is destroyed by explosion or environment.


    Parameters

    • coords: Vector

      block coords

    • block: Tile

      block id and data

    • region: BlockSource

      BlockSource object

    Returns void

onPlace

  • onPlace(coords: ItemUseCoordinates, item: ItemStack, block: Tile, player: number, region: BlockSource): Vector
  • Parameters

    • coords: ItemUseCoordinates
    • item: ItemStack
    • block: Tile
    • player: number
    • region: BlockSource

    Returns Vector

registerTileEntity

  • registerTileEntity(prototype: TileEntityPrototype): void
  • Registers TileEntity prototype for this block.


    Parameters

    • prototype: TileEntityPrototype

      TileEntity prototype

    Returns void

setBaseBlock

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


    Parameters

    • baseBlock: number

      id of the block to inherit type

    Returns void

setBlockColorSource

  • setBlockColorSource(colorSource: ColorSource): void
  • Makes block use biome color when displayed on the vanilla maps.


    Parameters

    • colorSource: ColorSource

    Returns void

setBlockMaterial

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

    • material: string

      material name

    • optionallevel: number

      block digging level

    Returns void

setCategory

  • setCategory(category: number): void
  • Sets item category.


    Parameters

    • category: number

      item category, should be integer from 1 to 4.

    Returns void

setDestroyTime

  • setDestroyTime(destroyTime: number): void
  • Sets destroy time for the block.


    Parameters

    • destroyTime: number

      block destroy time

    Returns void

setExplosionResistance

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


    Parameters

    • resistance: number

      integer value, default is 3

    Returns void

setFriction

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

    • friction: number

      float value, default is 0.6

    Returns void

setLightLevel

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


    Parameters

    • lightLevel: number

      value from 0 (no light) to 15

    Returns void

setLightOpacity

  • setLightOpacity(lightOpacity: number): void
  • Specifies how opaque block is.


    Parameters

    • 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(color: number): void
  • Sets block color when displayed on the vanilla maps.


    Parameters

    • color: number

      map color of the block

    Returns void

setRarity

  • setRarity(rarity: number): void
  • Sets item rarity.


    Parameters

    • rarity: number

      one of EnumRarity values

    Returns void

setRenderAllFaces

  • setRenderAllFaces(renderAllFaces: boolean): void
  • Sets rendering of the block faces.


    Parameters

    • 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(renderLayer: number): void
  • Specifies the layer that is used to render the block.


    Parameters

    • renderLayer: number

      default is 4

    Returns void

setRenderType

  • setRenderType(renderType: number): void
  • Sets render type of the block.


    Parameters

    • renderType: number

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

    Returns void

setShape

  • setShape(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, data?: number): void
  • Sets block box shape.

    @params

    x1, y1, z1 position of block lower corner (0, 0, 0 for solid block)

    @params

    x2, y2, z2 position of block upper conner (1, 1, 1 for solid block)


    Parameters

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

      sets shape for one block variation if specified and for all variations otherwise

    Returns void

setSolid

  • setSolid(isSolid: boolean): void
  • Sets block to be transparent or opaque.


    Parameters

    • isSolid: boolean

      if true, sets block to be opaque.

    Returns void

setSoundType

  • setSoundType(sound: Sound): void
  • Sets sound type of the block.


    Parameters

    • sound: Sound

      block sound type

    Returns void

setTranslucency

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


    Parameters

    • translucency: number

      float value from 0 (no shadows) to 1

    Returns void