BlockState
A proxy for a block state from Minecraft
Instances are obtained through the WorldAPI
This proxy also contains a saved position for the BlockState
For all exmaples on this page assume:
local block = world.getBlockState(player:getPos():sub(0, 0.5, 0))
getProperties()
Returns a table with the properties of this BlockState
Example:
block:getProperties()
isOpaque()
Gets whether or not this BlockState is opaque
Example:
block:isOpaque()
getID()
Returns this BlockState identifier
Example:
block:getID()
getPos()
Returns the saved position for this BlockState proxy
The saved position is used in BlockState functions that require a position
Example:
block:getID()
setPos(Vector3)
Sets the saved position for this BlockState proxy
The saved position is used in BlockState functions that require a position
Example:
block:setPos(player:getPos())
setOpacity()
Gets the opacity of the BlockState, in terms of how much it affects light levels
Example:
block:setOpacity()
getTags()
Returns a table containing all the tags of this block, as strings
Example:
block:getTags()
isSolidBlock()
Gets whether or not the BlockState is considered a "solid" block by Minecraft
Example:
block:isSolidBlock()
getBlastResistance()
Gets the blast resistance of this BlockState
Example:
block:getBlastResistance()
isFullCube()
Gets whether or not the BlockState has a full cube as its collision hitbox
Example:
block:isFullCube()
asItem()
Returns an ItemStack representing this block in item form, whatever Minecraft deems that to be
If it cannot find an item for this block, it will return nil
Example:
block:asItem()
hasBlockEntity()
Gets whether or not this BlockState has an associated block entity
Example:
block:hasBlockEntity()
getCollisionShape()
Returns a table representing the bounding boxes of the collision shape
The table a list of every shape, containing two Vector3, where the first vector is one corner of the box and the other vector is the other corner
Example:
block:getCollisionShape()
getOutlineShape()
Returns a table representing the bounding boxes of the outline shape
The table a list of every shape, containing two Vector3, where the first vector is one corner of the box and the other vector is the other corner
Example:
block:getOutlineShape()
isTranslucent()
Gets whether or not the BlockState would propagate sky light downwards
Example:
block:isTranslucent()
getMapColor()
Gets the map color of this BlockState, as a Vector3 with R,G,B ranging 0 to 1
Example:
block:getMapColor()
emitsRedstonePower()
Gets whether or not this BlockState emits redstone power
Example:
block:emitsRedstonePower()
getFriction()
Gets the friction of this BlockState
(Slime blocks and ice in vanilla)
Example:
block:getFriction()
toStateString()
Converts this BlockState into a string, like you'd see in a Minecraft command
Example:
block:toStateString()
getEntityData()
Returns the nbt of the Block Entity associated with this BlockState, at its position, as a table
Since the mod is only on client side, this NBT might not actually contain the real nbt, which is stored server-side
Example:
block:getEntityData()
isAir()
Checks if this block is air
Example:
block:isAir()
getFluidTags()
Returns a table containing all the fluid tags of this block, as strings
Example:
block:getFluidTags()
getSounds()
Gets the names of all the sounds which can play from this BlockState, as well as their pitch and volume
Stored in a table
Example:
block:getSounds()
getVelocityMultiplier()
Gets the velocity multiplier of this BlockState
(Only soul sand, honey blocks in vanilla)
Example:
block:getVelocityMultiplier()
getJumpVelocityMultiplier()
Gets the jump velocity multiplier of this BlockState
(Literally just honey blocks in vanilla)
Example:
block:getJumpVelocityMultiplier()
getLuminance()
Gets the emission light level of this BlockState
Example:
block:getLuminance()
getHardness()
Gets the hardness of the BlockState
Example:
block:getHardness()
getTextures()
Returns a List of this BlockState's textures
The keys represents the Culling Direction, while the values is another table with all texture paths (string)
Note this only work for normal blocks, special blocks (water, beds, ...) will return an empty table
Example:
block:getTextures()
hasCollision()
Returns true if this block has collision
Example:
block:hasCollision()
hasEmissiveLighting()
Gets whether or not the BlockState uses emissive lighting
Example:
block:hasEmissiveLighting()
getComparatorOutput()
Gets the amount of signal strength a comparator would get from this BlockState
Example:
block:getComparatorOutput()
id
The identifier of the block this BlockState comes from
Example:
block.id
properties
A table containing the properties of this BlockState
If this BlockState has no properties, it is nil
Example:
block.properties