Interface BlockInventory
- All Superinterfaces:
Container
- All Known Subinterfaces:
BarrelInventory, ChestInventory, HopperInventory
The slots a block keeps in its block entity: those of a chest, of a barrel or of a hopper.
What is read is what the block holds, what is written is saved with its chunk and shows at once in the window of every player looking into it. Once the block is gone, the inventory reads as empty and ignores what is written to it.
A block still holding a loot table rolls it the first time its contents are read: when a player opens it, a comparator reads it, it is broken, or a plugin reads one of its slots.
Use it on the thread of the region owning the block.
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the name shown at the top of the window, empty for the default one.Returns the loot table the block has yet to roll, empty once rolled or for a block that never had one.position()Returns where the block is.voidsetCustomName(@Nullable Component name) Names the block, as an item renamed in an anvil names the block it places.voidsetLootTable(@Nullable Key table, long seed) Gives the block a loot table to roll the first time its contents are read, as the chests of dungeons have.world()Returns the world of the block.Methods inherited from interface Container
clear, contents, firstEmpty, get, isEmpty, set, setContents, size
-
Method Details
-
world
-
position
-
customName
-
setCustomName
-
lootTable
-
setLootTable
Gives the block a loot table to roll the first time its contents are read, as the chests of dungeons have. What the block holds stays until then, the loot only filling its empty slots.- Parameters:
table- the loot table, such asminecraft:chests/simple_dungeon;nullto forget the one it hasseed- the seed of the roll,0for a random one- Since:
- 0.1.0
-