5.3 KiB
Block
Block.fromStateId(stateId, biomeId)
Block.fromString(stateString, biomeId)
stateStringis the string representation of a blockbiomeIdis the biome numerical id
Block.fromProperties(typeId, properties, biomeId)
typeId- The block type ID (numerical or string)properties- A dictionary of block state properties to build frombiomeId- The biome numerical id
Block(type, biomeId, metadata, stateId = null)
Constructor of a block
typeis the block numerical idbiomeIdis the biome numerical idmetadatais the metadata numerical valuestateId(optional) represents the state of the block (same as metadata in newer versions)
block.canHarvest(heldItemType)
Tells you if heldItemType is one of the right tool to harvest the block.
heldItemTypethe id of the held item (or null if nothing is held)
block.getProperties()
Parse the block state and return its properties.
getHash(prefixedName, states)
(Bedrock Edition) Returns an integer hash to represent the block state.
prefixedName- The name of the block, including theminecraft:prefix (string).states- A record of block state properties.
block.digTime(heldItemType, creative, inWater, notOnGround, enchantments = [], effects = {})
Tells you how long it will take to dig the block, in milliseconds.
heldItemTypethe id of the held item (or null if nothing is held)creativegame in creativeinWaterthe bot is in waternotOnGroundthe bot is not on the groundenchantmentslist of enchantments from the held item (from simplified nbt data) AND equipped armor - Aqua Affinity enchantment on helmet also affects breaking speedeffectseffects on the bot (bot.entity.effects)
block.stateId
The numeric ID for this block and its state, post-flattening. Pre-flattening, this is generated by combining the block ID and the metadata bits into one integer.
block.type
The numeric ID for this block, pre-flattening. Post-flattening, this holds the index for the block in minecraft-data's block list.
block.name
A string used to uniquely identify this block internally.
block.displayName
The English formatted display name for this block.
block.position
Vec3 instance.
Note: This is not present on prismarine-block instantiation, it's defined externally by prismarine-chunk's getBlock methods.
block.shapes
Array of bounding boxes representing the block shape. Each bounding box is an array of the form [xmin, ymin, zmin, xmax, ymax, zmax]. Depends on the type and state of the block.
block.entity
If this block is a block entity, this contains the NBT data for the entity.
block.blockEntity
Simplified block entity data using prismarine-nbt's simplify() function. Only for reading - data modified here cannot be saved back later.
block.metadata
Number which represents different things depending on the block. See http://www.minecraftwiki.net/wiki/Data_values#Data
block.hash
(Bedrock Edition) A hash uniquely representing the block name and its properties (number).
block.light
block.skyLight
block.hardness
block.biome
A biome instance. See Biome.
block.signText
If the block is a sign, contains the sign text.
block.painting
If the block is a painting, contains information about the painting.
idpositionnamedirection- direction vector telling how the painting is facing.
block.diggable
Boolean, whether the block is considered diggable.
block.isWaterlogged
Whether the block's state is currently waterlogged. This is only possible since the aqatic update.
block.boundingBox
The shape of the block according to the physics engine's collision detection. Currently one of:
block- currently, partially solid blocks, such as half-slabs and ladders, are considered entirely solid.empty- such as flowers and lava.
block.transparent
Boolean, true if the block texture has some transparency.
block.material
This tells what types of tools will be effective against the block. Possible
values are: null, rock, wood, plant, melon, leaves, dirt, web, and wool.
See http://www.minecraftwiki.net/wiki/Digging and the toolMultipliers
variable at the top of lib/plugins/digging.js for more info.
block.harvestTools
The set of tools that will allow you to harvest the block.
block.drops
The blocks or items dropped by that block.
Block entities
Some blocks may have entity data attached to them. If they do, they contain extra fields which can manipulate the entity NBT data
sign
setSignText (front, back)
Sets the text for the sign, can be plaintext, or array of JSON or prismarine-chat instances.
getSignText (): [string, string?]
Gets the plain text content of the sign. The first item of the array returned and the second is the back, which will be undefined for versions that don't support writing on the back of signs.
get .signText
Deprecated, returns a plaintext string containing the sign's text.
set .signText
Deprecated, sets the text for a sign's text. Can be plaintext, or array of JSON or prismarine-chat instances.