Skip to content

Block Reader

Picture

!Image of the Block Reader block

This block is able to read data about any blocks or tile entities in front of it.


Peripheral Name Interfaces with Has events Introduced in
block_reader Blocks No 0.7r

Functions

getBlockName

getBlockName() -> string | nil

Returns the registry name of the block (ex. minecraft:dirt), or nil if nothing is in front of the reader.

1
2
3
local reader = peripheral.find("block_reader")

print("There is a " .. read.getBlockName() .. " in front.")

getBlockState

getBlockState() -> table | nil

Returns the block state of the block, or nil if nothing is in front of the reader.

1
2
3
4
5
local reader = peripheral.find("block_reader")

for k, v in pairs(reader.getBlockState()) do 
    print(k, v)
end

getBlockData

getBlockData() -> table | nil

Returns the block data of the block if block is a tile entity.

1
2
3
4
5
6
local reader = peripheral.find("block_reader")

--Prints the contents of the data
for k, v in pairs(reader.getBlockData()) do 
    print(k, v)
end

Added in version 1.19.2-0.7.33r | 1.20.1-0.7.37r

hasBlockEntity

hasBlockEntity() -> boolean | nil

Returns whether the block is a block entity or not


Changelog/Trivia

1.19.2-0.7.33r/1.20.1-0.7.37r Added getBlockStates and isTileEntity

0.7r
Added the Block Reader peripheral.

Comments