Interface LootableInventory
- All Known Implementing Classes:
BarrelBlockEntity
,ChestBlockEntity
,CrafterBlockEntity
,DecoratedPotBlockEntity
,DispenserBlockEntity
,DropperBlockEntity
,HopperBlockEntity
,LootableContainerBlockEntity
,ShulkerBoxBlockEntity
,TrappedChestBlockEntity
This is usually implemented by block entities, which extend LootableContainerBlockEntity
.
- Mappings:
Namespace Name official bki
intermediary net/minecraft/class_8934
named net/minecraft/inventory/LootableInventory
-
Field Summary
Fields inherited from interface net.minecraft.inventory.Inventory
field_42619, MAX_COUNT_PER_STACK
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
generateLoot
(@Nullable PlayerEntity player) Replaces the contents of this inventory with the generated loot, if it exists.Returns the loot table ID, ornull
if there is no associated loot table.long
Returns the loot table's seed.getPos()
getWorld()
default boolean
readLootTable
(NbtCompound nbt) Reads the loot table ID and seed fromnbt
, if the loot table ID exists innbt
.default void
setLootTable
(Identifier lootTableId, long lootTableSeed) Sets the loot table ID and seed at once.static void
setLootTable
(BlockView world, Random random, BlockPos pos, Identifier lootTableId) Queries the block entity atpos
, checks if it is aLootableInventory
, and sets the loot table ID and seed if applicable.void
setLootTableId
(@Nullable Identifier lootTableId) Sets the loot table ID.void
setLootTableSeed
(long lootTableSeed) Sets the loot table's seed.default boolean
Methods inherited from interface net.minecraft.inventory.Inventory
canPlayerUse, canTransferTo, containsAny, containsAny, count, getMaxCountPerStack, getStack, isEmpty, isValid, markDirty, onClose, onOpen, removeStack, removeStack, setStack, size
-
Field Details
-
LOOT_TABLE_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector official c
Lbki;c:Ljava/lang/String;
intermediary field_47154
Lnet/minecraft/class_8934;field_47154:Ljava/lang/String;
named LOOT_TABLE_KEY
Lnet/minecraft/inventory/LootableInventory;LOOT_TABLE_KEY:Ljava/lang/String;
-
LOOT_TABLE_SEED_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector official d
Lbki;d:Ljava/lang/String;
intermediary field_47155
Lnet/minecraft/class_8934;field_47155:Ljava/lang/String;
named LOOT_TABLE_SEED_KEY
Lnet/minecraft/inventory/LootableInventory;LOOT_TABLE_SEED_KEY:Ljava/lang/String;
-
-
Method Details
-
getLootTableId
Returns the loot table ID, ornull
if there is no associated loot table.This is usually stored under the "LootTable" NBT key.
- Returns:
- the loot table ID, or
null
if there is no associated loot table - Mappings:
Namespace Name Mixin selector official az_
Lbki;az_()Lahg;
intermediary method_54869
Lnet/minecraft/class_8934;method_54869()Lnet/minecraft/class_2960;
named getLootTableId
Lnet/minecraft/inventory/LootableInventory;getLootTableId()Lnet/minecraft/util/Identifier;
-
setLootTableId
Sets the loot table ID.This is usually stored under the "LootTable" NBT key.
- Parameters:
lootTableId
- the loot table ID, ornull
to remove the loot table- Mappings:
Namespace Name Mixin selector official a
Lbki;a(Lahg;)V
intermediary method_11285
Lnet/minecraft/class_8934;method_11285(Lnet/minecraft/class_2960;)V
named setLootTableId
Lnet/minecraft/inventory/LootableInventory;setLootTableId(Lnet/minecraft/util/Identifier;)V
-
setLootTable
Sets the loot table ID and seed at once. This is useful for code-based structure generation.- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lbki;a(Lahg;J)V
intermediary method_54867
Lnet/minecraft/class_8934;method_54867(Lnet/minecraft/class_2960;J)V
named setLootTable
Lnet/minecraft/inventory/LootableInventory;setLootTable(Lnet/minecraft/util/Identifier;J)V
-
getLootTableSeed
long getLootTableSeed()Returns the loot table's seed.Vanilla implementations return
0
when there is no loot table associated with the inventory, although it is not necessary.This is usually stored under the "LootTableSeed" NBT key.
- Returns:
- the loot table's seed
- Mappings:
Namespace Name Mixin selector official aA_
Lbki;aA_()J
intermediary method_54870
Lnet/minecraft/class_8934;method_54870()J
named getLootTableSeed
Lnet/minecraft/inventory/LootableInventory;getLootTableSeed()J
-
setLootTableSeed
void setLootTableSeed(long lootTableSeed) Sets the loot table's seed.Vanilla implementations return
0
when there is no loot table associated with the inventory, although it is not necessary.This is usually stored under the "LootTableSeed" NBT key.
- Mappings:
Namespace Name Mixin selector official a
Lbki;a(J)V
intermediary method_54866
Lnet/minecraft/class_8934;method_54866(J)V
named setLootTableSeed
Lnet/minecraft/inventory/LootableInventory;setLootTableSeed(J)V
-
getPos
BlockPos getPos()- Mappings:
Namespace Name Mixin selector official aB_
Lbki;aB_()Lhx;
intermediary method_11016
Lnet/minecraft/class_8934;method_11016()Lnet/minecraft/class_2338;
named getPos
Lnet/minecraft/inventory/LootableInventory;getPos()Lnet/minecraft/util/math/BlockPos;
-
getWorld
- Mappings:
Namespace Name Mixin selector official i
Lbki;i()Lctp;
intermediary method_10997
Lnet/minecraft/class_8934;method_10997()Lnet/minecraft/class_1937;
named getWorld
Lnet/minecraft/inventory/LootableInventory;getWorld()Lnet/minecraft/world/World;
-
setLootTable
Queries the block entity atpos
, checks if it is aLootableInventory
, and sets the loot table ID and seed if applicable. This is useful for code-based structure generation.- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lbki;a(Lcsv;Lauv;Lhx;Lahg;)V
intermediary method_54868
Lnet/minecraft/class_8934;method_54868(Lnet/minecraft/class_1922;Lnet/minecraft/class_5819;Lnet/minecraft/class_2338;Lnet/minecraft/class_2960;)V
named setLootTable
Lnet/minecraft/inventory/LootableInventory;setLootTable(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Identifier;)V
-
readLootTable
Reads the loot table ID and seed fromnbt
, if the loot table ID exists innbt
. Implementations should skip reading the contents of the inventory if this returnstrue
.- Returns:
- whether the loot table ID was found
- Mappings:
Namespace Name Mixin selector official c_
Lbki;c_(Lsn;)Z
intermediary method_54871
Lnet/minecraft/class_8934;method_54871(Lnet/minecraft/class_2487;)Z
named readLootTable
Lnet/minecraft/inventory/LootableInventory;readLootTable(Lnet/minecraft/nbt/NbtCompound;)Z
-
writeLootTable
Writes the loot table ID and seed tonbt
, if the loot table ID is notnull
. Implementations should skip writing the contents of the inventory if this returnstrue
.This skips writing the seed if it equals
0L
. This has no practical difference in-game, as getting nonexistentlong
values return0L
.- Returns:
- whether the loot table ID was non-
null
- Mappings:
Namespace Name Mixin selector official d_
Lbki;d_(Lsn;)Z
intermediary method_54872
Lnet/minecraft/class_8934;method_54872(Lnet/minecraft/class_2487;)Z
named writeLootTable
Lnet/minecraft/inventory/LootableInventory;writeLootTable(Lnet/minecraft/nbt/NbtCompound;)Z
-
generateLoot
Replaces the contents of this inventory with the generated loot, if it exists. Does nothing if there is no loot table associated with this inventory. After generation, the loot table is removed from the inventory.Implementations should call this method whenever the inventory is accessed.
- Parameters:
player
- the player that triggered this generation (by opening, breaking, etc), ornull
if there was no player involvement- Mappings:
Namespace Name Mixin selector official e_
Lbki;e_(Lcfi;)V
intermediary method_54873
Lnet/minecraft/class_8934;method_54873(Lnet/minecraft/class_1657;)V
named generateLoot
Lnet/minecraft/inventory/LootableInventory;generateLoot(Lnet/minecraft/entity/player/PlayerEntity;)V
-