BlockSource
Index
Constructors
Methods
- addToTickingQueue
- breakBlock
- breakBlockForJsResult
- canSeeSky
- clip
- containsMaterial
- destroyBlock
- explode
- fetchEntitiesInAABB
- fetchEntitiesOfTypeInAABB
- getBiome
- getBiomeDownfallAt
- getBiomeTemperatureAt
- getBlock
- getBlockData
- getBlockEntity
- getBlockID
- getBlockId
- getBlockUpdateAllowed
- getBlockUpdateType
- getChunkState
- getChunkStateAt
- getDestroyParticlesEnabled
- getDimension
- getExtraBlock
- getGrassColor
- getLightLevel
- getLightningLevel
- getPointer
- getRainLevel
- getRedstoneSignal
- isChunkLoaded
- isChunkLoadedAt
- listEntitiesInAABB
- listEntitiesOfTypeInAABB
- playSound
- playSoundAtEntity
- randomTick
- setBiome
- setBlock
- setBlockUpdateAllowed
- setBlockUpdateType
- setDestroyParticlesEnabled
- setExtraBlock
- setLightningLevel
- setRainLevel
- setRedstoneSignal
- spawnDroppedItem
- spawnEntity
- spawnExpOrbs
- stopSound
- getCurrentClientRegion
- getCurrentWorldGenRegion
- getDefaultForActor
- getDefaultForDimension
- getFromCallbackPointer
- getFromServerCallbackPointer
- resetDefaultBlockSources
Constructors
constructor
Returns BlockSource
Methods
addToTickingQueue
- since: 2.2.1b102
Parameters
x: number
y: number
z: number
state: BlockState
delay: number
optionaltodo: number
Returns void
breakBlock
- since: 2.2.0b83
Destroys block on coords by entity using specified item or without it.
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
- since: 2.2.0b83
Same as breakBlock, but returns object containing drop and experience.
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
Parameters
x: number
y: number
z: number
Returns boolean
Whether the sky can be seen from coords.
clip
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
containsMaterial
- since: 2.4.0b122-4
Parameters
x1: number
y1: number
z1: number
x2: number
y2: number
z2: number
material: number
numeric identifier of block material, which is specified when it is registered in Block.SpecialType, e.g. 5 for liquids and 3 by default
Returns boolean
Is requested material available in that bounds, preferably for a quick check of block pile. *
destroyBlock
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
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
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
0or256optionalblacklist: 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 istrue.
fetchEntitiesOfTypeInAABB
- 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
Parameters
x: number
X coord of the block
z: number
Z coord of the block
Returns number
Biome ID.
getBiomeDownfallAt
- since: 2.2.1b96
Parameters
x: number
y: number
z: number
Returns number
Downfall of the biome on coords.
getBiomeTemperatureAt
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 BlockState | Tile
Object of the block on given coords or Tile object in Legacy pack.
getBlockData
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
- 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
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
Returns boolean
getBlockUpdateType
Returns number
getChunkState
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
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
- since: 2.2.1b102
Returns boolean
getDimension
Returns number
Dimension ID to which the following object belongs.
getExtraBlock
- since: 2.2.1b95
Parameters
x: number
y: number
z: number
Returns BlockState
Object of the extra block on given coords.
getGrassColor
Parameters
x: number
z: number
Returns number
Grass color on chunk coords.
getLightLevel
- since: 2.1.0b69
Parameters
x: number
y: number
z: number
Returns number
Light level on the specified coordinates, from 0 to 15.
getLightningLevel
- since: 2.4.0b119
Returns number
getPointer
Returns number
getRainLevel
- since: 2.4.0b119
Returns number
getRedstoneSignal
- since: 3.1.0b125
Gets signal strength at specified coordinates that consumers can receive.
Parameters
x: number
y: number
z: number
Returns number
isChunkLoaded
Parameters
chunkX: number
X coord of the chunk
chunkZ: number
Z coord of the chunk
Returns boolean
trueif chunk is loaded,falseotherwise.
isChunkLoadedAt
Parameters
x: number
X coord of the position
z: number
Z coord of the position
Returns boolean
trueif chunk on the position is loaded,falseotherwise.
listEntitiesInAABB
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
0or256optionalblacklist: 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 istrue.
listEntitiesOfTypeInAABB
- 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.
playSound
- since: 3.1.1b127
Plays sound on defined coordsby radius 16 blocks from source, if volume bigger than 1.0, radius multiplies to volume.
Parameters
x: number
y: number
z: number
sound: string
resource pack sound name
optionalvolume: number
default
1.0optionalpitch: number
default
1.0optionalplayerUids: number[]
if not set, players in volume multiplied radius will be detected automatically
Returns void
playSoundAtEntity
- since: 3.1.1b127
Plays sound to entity by radius 16 blocks from source, if volume bigger than 1.0, radius multiplies to volume.
Parameters
entity: number
entity uid
sound: string
resource pack sound name
optionalvolume: number
default
1.0optionalpitch: number
default
1.0optionalplayerUids: number[]
if not set, players in volume multiplied radius will be detected automatically
Returns void
randomTick
- since: 3.1.0b125
Causes a random tick event, usually affecting rate of plant growth or grass spread and leaf disappearings.
Parameters
x: number
y: number
z: number
Returns void
setBiome
Sets biome ID by coords.
Parameters
chunkX: number
chunkZ: number
biomeID: number
ID of the biome to set
Returns void
setBlock
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
Parameters
allowed: boolean
Returns void
setBlockUpdateType
Parameters
type: number
Returns void
setDestroyParticlesEnabled
- since: 2.2.1b102
Whether or not particles must be emitted when destroying blocks with this source.
Parameters
enabled: boolean
Returns void
setExtraBlock
- since: 2.2.1b95
Sets extra block (for example, water inside another blocks), on given coords by given ID and data.
Parameters
x: number
y: number
z: number
id: number
optionaldata: number
Returns void
setLightningLevel
- since: 2.4.0b119
Parameters
level: number
Returns void
setRainLevel
- since: 2.4.0b119
Parameters
level: number
Returns void
setRedstoneSignal
- since: 3.1.0b125
Sets signal with specified strength to block, it is recommended to call Block.setupAsRedstoneEmitter to be able to add a source. Once block is destroyed, signal will be reset.
Parameters
x: number
y: number
z: number
strength: number
level between 0-15 (inclusive)
optionaldelay: number
time in ticks after which signal strength will be reset, should be more than zero, updated depending on redstone tick (1 redstone tick = 2 regular ticks), default is
4optionalfacing: number
world side of EBlockSide to which signal from source will be applied, use -1 to apply it to all sides (as from redstone block), default is
-1
Returns void
spawnDroppedItem
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
Spawns entity of given numeric or namespaced type on coords.
Learn how to useCallback.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.CHICKENor namespaced type with possible ommitions, e.g. "minecraft:chicken:", "minecraft:chicken", "chicken" does same
Returns number
spawnExpOrbs
Spawns experience orbs on coords.
Parameters
x: number
y: number
z: number
amount: number
experience amount
Returns void
stopSound
- since: 3.1.1b127
Method to stop sound by name for defined player list.
Parameters
sound: string
resource pack sound name
optionalplayerUids: number[]
if not set, players in volume multiplied radius will be detected automatically
Returns void
staticgetCurrentClientRegion
- since: 2.1.0b57 (caching since 2.3.1b115)
Returns BlockSource
BlockSource for the current client.
staticgetCurrentWorldGenRegion
Returns BlockSource
BlockSource for world generation.
staticgetDefaultForActor
Parameters
entityUid: number
Returns BlockSource
Interface to the dimension where the given entity is (
nullif 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 (
nullif given dimension is not loaded and this interface was not created yet).
staticgetFromCallbackPointer
Parameters
pointer: number
Returns BlockSource
staticgetFromServerCallbackPointer
- since: 2.3.1b115
Parameters
pointer: number
Returns BlockSource
staticresetDefaultBlockSources
Returns void
New class to work with world instead of some methods from World module.