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

BlockSource

New class to work with world instead of some methods from World module.

Index

Constructors

constructor

Methods

addToTickingQueue

  • addToTickingQueue(x: number, y: number, z: number, state: BlockState, delay: number, todo?: number): void
  • addToTickingQueue(x: number, y: number, z: number, delay: number, todo?: number): void
  • @since

    2.2.1b102


    Parameters

    • x: number
    • y: number
    • z: number
    • state: BlockState
    • delay: number
    • optionaltodo: number

    Returns void

breakBlock

  • breakBlock(x: number, y: number, z: number, allowDrop: boolean, entityUid?: number, item?: ItemInstance): void
  • breakBlock(x: number, y: number, z: number, allowDrop: boolean, item: ItemInstance): void
  • Destroys block on coords by entity using specified item or without it.

    @since

    2.2.0b83


    Parameters

    • x: number
    • y: number
    • z: number
    • allowDrop: boolean

      whether to provide drop for the block or not

    • optionalentityUid: number

      entity ID or -1 ID if entity is not specified

    • optionalitem: ItemInstance

      tool which broke block

    Returns void

breakBlockForJsResult

  • Same as breakBlock, but returns object containing drop and experience.

    @since

    2.2.0b83


    Parameters

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

      entity ID or -1 ID if entity is not specified

    • optionalitem: ItemInstance

      tool which broke block

    Returns BlockBreakResult

canSeeSky

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

  • Parameters

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

    Returns boolean

    Whether the sky can be seen from coords.

clip

  • clip(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, mode: number, output: number[]): number
  • Parameters

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

      certain modes also working with actors

    • output: number[]

    Returns number

destroyBlock

  • destroyBlock(x: number, y: number, z: number, drop?: boolean): void
  • Destroys block on coords 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

explode

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


    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

fetchEntitiesInAABB

  • fetchEntitiesInAABB(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, type?: number, blacklist?: boolean): number[]

  • Parameters

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

      entity type, since 2.3.1b115 could be used to fetch all entities via 0 or 256

    • optionalblacklist: boolean

    Returns number[]

    Iterator of entity IDs in given box, that are equal to the given type, if blacklist value is false, and all except the entities of the given type, if blacklist value is true.

fetchEntitiesOfTypeInAABB

  • fetchEntitiesOfTypeInAABB(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, namespace: string, type: string): number[]
  • fetchEntitiesOfTypeInAABB(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, type: string): number[]
  • @since

    2.3.1b115


    Parameters

    • x1: number
    • y1: number
    • z1: number
    • x2: number
    • y2: number
    • z2: number
    • namespace: string

      entity namespace, e.g. "minecraft"

    • type: string

      entity type, e.g. "chicken"

    Returns number[]

    Iterator of entity IDs in given box, that are equal to the given type.

getBiome

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

  • Parameters

    • x: number

      X coord of the block

    • z: number

      Z coord of the block

    Returns number

    Biome ID.

getBiomeDownfallAt

  • getBiomeDownfallAt(x: number, y: number, z: number): number
  • @since

    2.2.1b96


    Parameters

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

    Returns number

    Downfall of the biome on coords.

getBiomeTemperatureAt

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

  • Parameters

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

    Returns number

    Temperature of the biome on coords.

getBlock

  • @since

    2.1.0b59


    Parameters

    • x: number

      X coord of the block

    • y: number

      Y coord of the block

    • z: number

      Z coord of the block

    Returns Tile | BlockState

    Object of the block on given coords or Tile object in Legacy pack.

getBlockData

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

  • Parameters

    • x: number

      X coord of the block

    • y: number

      Y coord of the block

    • z: number

      Z coord of the block

    Returns number

    Block's data at coords.

getBlockEntity


  • Parameters

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

    Returns NativeTileEntity

    Interface to the vanilla TileEntity (chest, furnace, etc.) on the coords, and null if it's not found.

getBlockID

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

    2.2.1b96


    Parameters

    • x: number

      X coord of the block

    • y: number

      Y coord of the block

    • z: number

      Z coord of the block

    Returns number

    Block's ID at coords.

getBlockId

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

  • Parameters

    • x: number

      X coord of the block

    • y: number

      Y coord of the block

    • z: number

      Z coord of the block

    Returns number

    Block's ID at coords.

getBlockUpdateAllowed

  • getBlockUpdateAllowed(): boolean
  • Returns boolean

getBlockUpdateType

  • getBlockUpdateType(): number
  • Returns number

getChunkState

  • getChunkState(chunkX: number, chunkZ: number): number

  • Parameters

    • chunkX: number

      X coord of the chunk

    • chunkZ: number

      Z coord of the chunk

    Returns number

    Loading state of the chunk by chunk coords.

getChunkStateAt

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

  • Parameters

    • x: number

      X coord of the position

    • z: number

      Z coord of the position

    Returns number

    Loading state of the chunk by coords.

getDestroyParticlesEnabled

  • getDestroyParticlesEnabled(): boolean
  • @since

    2.2.1b102


    Returns boolean

getDimension

  • getDimension(): number

  • Returns number

    Dimension ID to which the following object belongs.

getExtraBlock

  • getExtraBlock(x: number, y: number, z: number): BlockState
  • @since

    2.2.1b95


    Parameters

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

    Returns BlockState

    Object of the extra block on given coords.

getGrassColor

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

  • Parameters

    • x: number
    • z: number

    Returns number

    Grass color on chunk coords.

getLightLevel

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

    2.1.0b69


    Parameters

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

    Returns number

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

getLightningLevel

  • getLightningLevel(): number
    @since

    2.4.0b119


    Returns number

getPointer

  • getPointer(): number
  • Returns number

getRainLevel

  • getRainLevel(): number
    @since

    2.4.0b119


    Returns number

isChunkLoaded

  • isChunkLoaded(chunkX: number, chunkZ: number): boolean

  • Parameters

    • chunkX: number

      X coord of the chunk

    • chunkZ: number

      Z coord of the chunk

    Returns boolean

    true if chunk is loaded, false otherwise.

isChunkLoadedAt

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

  • Parameters

    • x: number

      X coord of the position

    • z: number

      Z coord of the position

    Returns boolean

    true if chunk on the position is loaded, false otherwise.

listEntitiesInAABB

  • listEntitiesInAABB(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, type?: number, blacklist?: boolean): number[]

  • Parameters

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

      entity type, since 2.3.1b115 could be used to fetch all entities via 0 or 256

    • optionalblacklist: boolean

    Returns number[]

    List of entity IDs in given box, that are equal to the given type, if blacklist value is false, and all except the entities of the given type, if blacklist value is true.

listEntitiesOfTypeInAABB

  • listEntitiesOfTypeInAABB(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, namespace: string, type: string): number[]
  • listEntitiesOfTypeInAABB(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, type: string): number[]
  • @since

    2.3.1b115


    Parameters

    • x1: number
    • y1: number
    • z1: number
    • x2: number
    • y2: number
    • z2: number
    • namespace: string

      entity namespace, e.g. "minecraft"

    • type: string

      entity type, e.g. "chicken"

    Returns number[]

    List of entity IDs in given box, that are equal to the given type.

setBiome

  • setBiome(chunkX: number, chunkZ: number, biomeID: number): void
  • Sets biome ID by coords.


    Parameters

    • chunkX: number
    • chunkZ: number
    • biomeID: number

      ID of the biome to set

    Returns void

setBlock

  • setBlock(x: number, y: number, z: number, id: number, data: number): void
  • setBlock(x: number, y: number, z: number, id: number): void
  • setBlock(x: number, y: number, z: number, state: BlockState): void
  • Sets block on coords.


    Parameters

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

      ID of the block to set

    • data: number

      data of the block to set

    Returns void

setBlockUpdateAllowed

  • setBlockUpdateAllowed(allowed: boolean): void
  • Parameters

    • allowed: boolean

    Returns void

setBlockUpdateType

  • setBlockUpdateType(type: number): void
  • Parameters

    • type: number

    Returns void

setDestroyParticlesEnabled

  • setDestroyParticlesEnabled(enabled: boolean): void
  • Whether or not particles must be emitted when destroying blocks with this source.

    @since

    2.2.1b102


    Parameters

    • enabled: boolean

    Returns void

setExtraBlock

  • setExtraBlock(x: number, y: number, z: number, id: number, data?: number): void
  • setExtraBlock(x: number, y: number, z: number, state: BlockState): void
  • Sets extra block (for example, water inside another blocks), on given coords by given ID and data.

    @since

    2.2.1b95


    Parameters

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

    Returns void

setLightningLevel

  • setLightningLevel(level: number): void
  • @since

    2.4.0b119


    Parameters

    • level: number

    Returns void

setRainLevel

  • setRainLevel(level: number): void
  • @since

    2.4.0b119


    Parameters

    • level: number

    Returns void

spawnDroppedItem

  • spawnDroppedItem(x: number, y: number, z: number, id: number, count: number, data: number, extra?: ItemExtraData): number
  • Creates dropped item and returns entity ID.


    Parameters

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

      ID of the item to drop

    • count: number

      count of the item to drop

    • data: number

      data of the item to drop

    • optionalextra: ItemExtraData

      extra of the item to drop

    Returns number

    Drop entity ID.

spawnEntity

  • spawnEntity(x: number, y: number, z: number, type: string | number): number
  • spawnEntity(x: number, y: number, z: number, namespace: string, type: string, initData?: string): number
  • Spawns entity of given numeric or namespaced type on coords.

    @example
    Callback.addCallback("ItemUse", (coords: ItemUseCoordinates, item: ItemInstance, block: Tile, isExternal: boolean, player: number) =>
    BlockSource.getDefaultForActor(player)?.spawnEntity(coords.relative.x, coords.relative.y, coords.relative.z, EEntityType.CHICKEN));

    Parameters

    • x: number
    • y: number
    • z: number
    • type: string | number

      numeric entity type, e.g. EEntityType.CHICKEN or namespaced type with possible ommitions, e.g. "minecraft:chicken:", "minecraft:chicken", "chicken" does same

    Returns number

spawnExpOrbs

  • spawnExpOrbs(x: number, y: number, z: number, amount: number): void
  • Spawns experience orbs on coords.


    Parameters

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

      experience amount

    Returns void

staticgetCurrentClientRegion

  • @since

    2.1.0b57 (caching since 2.3.1b115)


    Returns BlockSource

    BlockSource for the current client.

staticgetCurrentWorldGenRegion

staticgetDefaultForActor


  • Parameters

    • entityUid: number

    Returns BlockSource

    Interface to the dimension where the given entity is (null if given entity does not exist or the dimension is not loaded and interface was not created).

staticgetDefaultForDimension


  • Parameters

    • dimension: number

    Returns BlockSource

    Interface to given dimension by default (null if given dimension is not loaded and this interface was not created yet).

staticgetFromCallbackPointer

staticgetFromServerCallbackPointer

  • getFromServerCallbackPointer(pointer: number): BlockSource
  • @since

    2.3.1b115


    Parameters

    • pointer: number

    Returns BlockSource

staticresetDefaultBlockSources

  • resetDefaultBlockSources(): void
  • Returns void