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

World

Module that allows to work with current Minecraft world. Most of the methods are client-side, use BlockSource instead.

Index

Interfaces

ChunkStateChangedFunction

  • ChunkStateChangedFunction(chunkX: number, chunkZ: number, dimensionId: number, lastState: number, state: number, discarded: boolean): void
  • Parameters

    • chunkX: number

      chunk X coordinate; multiply by 16 to receive corner block coordinates

    • chunkZ: number

      chunk Z coordinate; multiply by 16 to receive corner block coordinates

    • dimensionId: number

      current dimension's numeric ID

    • lastState: number

      previous chunk loading state

    • state: number

      new chunk loading state

    • discarded: boolean

      was chunk previously loaded and unloaded from memory (only after generation was completed)

    Returns void

Functions

addGenerationCallback

  • addGenerationCallback(callbackName: string, callback: GenerateChunkFunction, uniqueHashStr?: string): void
  • Adds a new generation callback using string hash to generate a unique random seed for the chunk generator.

    @since

    2.0.1b11


    Parameters

    • callbackName: string

      one of the generation callbacks

    • callback: GenerateChunkFunction

      callback function

    • optionaluniqueHashStr: string

      if specified, will be used as string hash for seed generation, otherwise default hash string will be used

    Returns void

addListenerChunkStateChanged

  • Listens for chunk loading state changes.

    @since

    2.4.0b122


    Parameters

    • listener: ChunkStateChangedFunction

      chunk state function watcher

    • states: number[]

      chunk states that should be received by watcher

    Returns void

addLocalListenerChunkStateChanged

  • Listens for local chunk loading state changes.

    @since

    2.4.0b122


    Parameters

    • listener: ChunkStateChangedFunction

      chunk state function watcher

    • states: number[]

      chunk states that should be received by watcher

    Returns void

addTileEntity

  • If the block on the specified coordinates is a TileEntity block and is not initialized, initializes it and returns created TileEntity object.


    Parameters

    Returns Nullable<TileEntity>

    Tile if one was created, null otherwise.

canSeeSky

  • canSeeSky(x: number, y: number, z: number): boolean
  • @remarks

    Client only method!


    Parameters

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

    Returns boolean

    true, if one can see sky from the specified position, false otherwise.

canTileBeReplaced

  • canTileBeReplaced(id: number, data: number): boolean

  • Parameters

    • id: number
    • data: number

    Returns boolean

    true, if tile can be replaced (for example, grass (not block) and water can be replaced), false otherwise

clip

  • clip(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, mode?: number): void
  • @since

    2.0.2b27


    Parameters

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

      certain modes also working with actors

    Returns void

destroyBlock

  • destroyBlock(x: number, y: number, z: number, drop?: boolean): void
  • Destroys block on the specified coordinates producing appropriate drop and particles. Do not use for massive tasks due to particles being produced.


    Parameters

    • x: number
    • y: number
    • z: number
    • optionaldrop: boolean

      whether to provide drop for the block or not

    Returns void

doesVanillaTileHasUI

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

    2.0.2b27


    Parameters

    • id: number

    Returns boolean

drop

  • drop(x: number, y: number, z: number, id: number, count: number, data: number, extra?: ItemExtraData): number
  • Drops item or block with specified ID, count, data and extra on the specified coordinates. For blocks, be sure to use block ID, not the tile ID.


    Parameters

    • x: number
    • y: number
    • z: number
    • id: number
    • count: number
    • data: number
    • optionalextra: ItemExtraData

    Returns number

    Spawned drop entity ID.

explode

  • explode(x: number, y: number, z: number, power: number, fire: boolean): void
  • Creates an explosion on the specified coordinates.


    Parameters

    • x: number
    • y: number
    • z: number
    • power: number

      defines how many blocks can the explosion destroy and what blocks can or cannot be destroyed

    • fire: boolean

      if true, puts the crater on fire

    Returns void

getBiome

  • getBiome(x: number, z: number): number

  • Parameters

    • x: number
    • z: number

    Returns number

    Biome ID on the specified coordinates.

getBiomeMap

  • getBiomeMap(x: number, z: number): number
  • Gets biome on the specified coordinates when generating biome map. Should be called only in GenerateBiomeMap callback.

    @since

    2.0.1b11


    Parameters

    • x: number

      block x coordinate

    • z: number

      block z coordinate

    Returns number

    Biome's numeric ID.

getBiomeName

  • getBiomeName(x: number, z: number): string

  • Parameters

    • x: number
    • z: number

    Returns string

    Biome name on the specified coordinates.

getBiomeNameById

  • getBiomeNameById(biome: number): string

  • Parameters

    • biome: number

    Returns string

    Biome name by specified identifier.

getBlock

  • getBlock(x: number, y: number, z: number): Tile

  • Parameters

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

    Returns Tile

    Tile object containing tile ID and data of the block located. on the specified coordinates

getBlockData

  • getBlockData(x: number, y: number, z: number): number

  • Parameters

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

    Returns number

    Data of the block located on the specified coordinates.

getBlockID

  • getBlockID(x: number, y: number, z: number): number

  • Parameters

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

    Returns number

    Tile ID of the block located on the specified coordinates.

getChunkState

  • getChunkState(x: number, z: number): number
  • Returns chunk state on specified location, like loaded, unloaded or interrupted.


    Parameters

    • x: number
    • z: number

    Returns number

getChunkStateAt

  • getChunkStateAt(x: number, y: number, z: number): number
  • Returns chunk state on specified coordinates, like loaded, unloaded or interrupted.


    Parameters

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

    Returns number

getContainer

getGrassColor

  • getGrassColor(x: number, z: number): number

  • Parameters

    • x: number
    • z: number

    Returns number

    Grass color for specified coordinates, uses android integer color model.

getGrassColorRGB

  • getGrassColorRGB(x: number, z: number): Color

  • Parameters

    • x: number
    • z: number

    Returns Color

    Grass color for specified coordinates, uses rgb color model.

getInverseBlockSide

  • getInverseBlockSide(side: number): number

  • Parameters

    • side: number

      number from 0 to 6 (exclusive) *

    Returns number

    Opposite side to argument.

getLightLevel

  • getLightLevel(x: number, y: number, z: number): number
  • @remarks

    Client only method!


    Parameters

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

    Returns number

    Light level on the specified coordinates, from 0 to 15.

getRelativeCoords

  • getRelativeCoords(x: number, y: number, z: number, side: number): Vector
  • Retrieves coordinates relative to the block.

    @example

    Return coordinates of the block above the specified:

    World.getRelativeCoords(x, y, z, EBlockSide.UP);

    Parameters

    • x: number
    • y: number
    • z: number
    • side: number

      block side

    Returns Vector

    Relative coordinates.

getSeed

  • getSeed(): number

  • Returns number

    Currently world seed, which is used, for example, in generation callbacks.

getTemperature

  • getTemperature(x: number, y: number, z: number): number
  • @remarks

    Client only method!


    Parameters

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

    Returns number

    Biome temperature on specified coordinates.

getThreadTime

  • getThreadTime(): number

  • Returns number

    Tick number since the player joined the world.

getTileEntity

getVectorByBlockSide

  • getVectorByBlockSide(side: number): Vector

  • Parameters

    • side: number

      block side

    Returns Vector

    Normalized vector for this side.

getWeather


  • Returns Weather

    Current weather object. This value should not be edited, call World.setWeather to change current weather.

getWorldDir

  • getWorldDir(): string

  • Returns string

    Loaded world directory full path.

getWorldTime

  • getWorldTime(): number
  • @since

    2.3.1b116-3 (client-side)


    Returns number

    Current world's time in ticks.

isChunkLoaded

  • isChunkLoaded(x: number, z: number): boolean

  • Parameters

    • x: number

      chunk coordinate

    • z: number

      chunk coordinate

    Returns boolean

    Whether the chunk with specified coordinates is loaded or not.

isChunkLoadedAt

  • isChunkLoadedAt(x: number, y: number, z: number): boolean

  • Parameters

    • x: number

      block coordinate

    • y: number

      block coordinate

    • z: number

      block coordinate

    Returns boolean

    Whether the chunk containing specified block coordinates is loaded or not.

isWorldLoaded

  • isWorldLoaded(): boolean

  • Returns boolean

    Whether the world is loaded or not.

nativeGetBlockData

  • nativeGetBlockData(x: number, y: number, z: number): number
  • @deprecated

    Consider using World.getBlockData instead.


    Parameters

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

    Returns number

    Data of the block located on the specified coordinates.

nativeGetBlockID

  • nativeGetBlockID(x: number, y: number, z: number): number
  • @deprecated

    Consider using World.getBlockID instead.


    Parameters

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

    Returns number

    Tile ID of the block located on the specified coordinates.

nativeSetBlock

  • nativeSetBlock(x: number, y: number, z: number, id: number, data: number): void
  • Sets block in the world using it's tile ID and data.

    @deprecated

    Consider using World.setBlock instead.


    Parameters

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

      block tile ID

    • data: number

      block data

    Returns void

playSound

  • playSound(x: number, y: number, z: number, name: string, volume: number, pitch?: number): void
  • Plays standart Minecraft sound on the specified coordinates.


    Parameters

    • x: number
    • y: number
    • z: number
    • name: string

      sound name

    • volume: number

      sound volume from 0 to 1

    • optionalpitch: number

      sound pitch, from 0 to 1, 0.5 is default value

    Returns void

playSoundAtEntity

  • playSoundAtEntity(entity: number, name: string, volume: number, pitch?: number): void
  • Plays standart Minecraft sound from the specified entity.


    Parameters

    • entity: number
    • name: string

      sound name

    • volume: number

      sound volume from 0 to 1

    • optionalpitch: number

      sound pitch, from 0 to 1, 0.5 is default value

    Returns void

registerBlockChangeCallback

  • registerBlockChangeCallback(ids: string | number | (string | number)[], callback: BlockChangedFunction): void
  • Enables "BlockChanged" event for specified block IDs and registers callback function for the IDs.


    Parameters

    • ids: string | number | (string | number)[]

      string or numeric tile ID, or an array of string and/or numeric tile IDs

    • callback: BlockChangedFunction

      function that will be called when "BlockChanged" callback occurs involving one of the blocks. Warning! If both old and new blocks are in the IDs list, callback function will be called twice.

    Returns void

removeTileEntity

  • removeTileEntity(x: number, y: number, z: number, region?: BlockSource): boolean
  • If the block on the specified coordinates is a TileEntity, destroys it, dropping it's container.


    Parameters

    Returns boolean

    true if the tile was destroyed successfully, false otherwise.

setBiome

  • setBiome(x: number, z: number): void
  • Overrides currently biome on specified coordinates. Consider using World.setBiomeMap in GenerateBiomeMap callback.


    Parameters

    • x: number
    • z: number

    Returns void

setBiomeMap

  • setBiomeMap(x: number, z: number, id: number): void
  • Sets biome on the specified coordinates when generating biome map. Should be called only in GenerateBiomeMap callback.

    @since

    2.0.1b11


    Parameters

    • x: number

      block x coordinate

    • z: number

      block z coordinate

    • id: number

      biome ID to be set on the specified coordinates

    Returns void

setBlock

  • setBlock(x: number, y: number, z: number, id: number, data: number): void
  • Sets block in the world using it's tile ID and data.


    Parameters

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

      block tile ID

    • data: number

      block data

    Returns void

setBlockChangeCallbackEnabled

  • setBlockChangeCallbackEnabled(id: number, enabled: boolean): void
  • Enables "BlockChanged" event for the block ID. Event occurs when either old block or new block is registered using this method.


    Parameters

    • id: number

      numeric tile ID

    • enabled: boolean

      if true, the block will be watched

    Returns void

setBlockUpdateAllowed

  • setBlockUpdateAllowed(allowed: boolean): void
  • @since

    2.0.2b27

    @remarks

    Client only method!


    Parameters

    • allowed: boolean

    Returns void

setBlockUpdateType

  • setBlockUpdateType(type: number): void
  • @since

    2.0.2b27

    @remarks

    Client only method!


    Parameters

    • type: number

    Returns void

setDayMode

  • setDayMode(day: boolean): void
  • Sets current time to day or night.

    @deprecated

    Consider using World.setWorldTime instead.


    Parameters

    • day: boolean

      if true, sets time to 10000 (day), else to 13000 (night)

    Returns void

setFullBlock

  • setFullBlock(x: number, y: number, z: number, fullTile: Tile): void
  • Sets block in the world using specified Tile object.


    Parameters

    • x: number
    • y: number
    • z: number
    • fullTile: Tile

      object containing ID and data of the tile

    Returns void

setGrassColor

  • setGrassColor(x: number, z: number, color: number): void
  • Sets grass color on the specified coordinates, uses android-like integer color model.


    Parameters

    • x: number
    • z: number
    • color: number

      grass color to be set for the specified coordinates

    Returns void

setGrassColorRGB

  • setGrassColorRGB(x: number, z: number, rgb: Color): void
  • Sets grass color on the specified coordinates, uses rgb color model.


    Parameters

    • x: number
    • z: number
    • rgb: Color

      grass color to be set for the specified coordinates

    Returns void

setLoaded

  • setLoaded(isLoaded: boolean): boolean
  • internal

    Setups the module to work properly with the world. Usually called by Core Engine, so you generally shouldn't call it yourself.


    Parameters

    • isLoaded: boolean

      whether the world is loaded or not

    Returns boolean

setNightMode

  • setNightMode(night: boolean): void
  • Sets current time to day or night.

    @deprecated

    Consider using World.setWorldTime instead.


    Parameters

    • night: boolean

      if true, sets time to 13000 (night), else to 10000 (day)

    Returns void

setWeather

  • Sets current weather in the world.


    Parameters

    Returns void

setWorldTime

  • setWorldTime(time: number): number
  • Sets current world time.


    Parameters

    • time: number

      time in ticks

    Returns number