Package net.minecraft.inventory
Interface LootableInventory
- All Superinterfaces:
Clearable,Inventory,Iterable<ItemStack>,StackReferenceGetter
- All Known Implementing Classes:
BarrelBlockEntity,ChestBlockEntity,CrafterBlockEntity,DecoratedPotBlockEntity,DispenserBlockEntity,DropperBlockEntity,HopperBlockEntity,LootableContainerBlockEntity,ShulkerBoxBlockEntity,TrappedChestBlockEntity
An inventory whose contents can be supplied from a loot table.
This is usually implemented by block entities, which extend LootableContainerBlockEntity.
- Mappings:
Namespace Name named net/minecraft/inventory/LootableInventoryintermediary net/minecraft/class_8934official cdh
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.inventory.Inventory
Inventory.Iterator -
Field Summary
FieldsFields inherited from interface net.minecraft.inventory.Inventory
DEFAULT_MAX_INTERACTION_RANGE -
Method Summary
Modifier and TypeMethodDescriptiondefault voidgenerateLoot(@Nullable PlayerEntity player) Replaces the contents of this inventory with the generated loot, if it exists.@Nullable RegistryKey<LootTable> longReturns the loot table's seed.getPos()@Nullable WorldgetWorld()default booleanreadLootTable(ReadView view) Reads the loot table and seed fromnbt, if the loot table exists innbt.voidsetLootTable(@Nullable RegistryKey<LootTable> lootTable) default voidsetLootTable(RegistryKey<LootTable> lootTableId, long lootTableSeed) Sets the loot table and seed at once.static voidsetLootTable(BlockView world, Random random, BlockPos pos, RegistryKey<LootTable> lootTableId) Queries the block entity atpos, checks if it is aLootableInventory, and sets the loot table and seed if applicable.voidsetLootTableSeed(long lootTableSeed) Sets the loot table's seed.default booleanwriteLootTable(WriteView view) Methods inherited from interface net.minecraft.inventory.Inventory
canPlayerUse, canTransferTo, containsAny, containsAny, count, getMaxCount, getMaxCountPerStack, getStack, getStackReference, getViewingUsers, isEmpty, isValid, iterator, markDirty, onClose, onOpen, removeStack, removeStack, setStack, sizeMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.minecraft.inventory.StackReferenceGetter
getStackReferences
-
Field Details
-
LOOT_TABLE_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector named LOOT_TABLE_KEYLnet/minecraft/inventory/LootableInventory;LOOT_TABLE_KEY:Ljava/lang/String;intermediary field_47154Lnet/minecraft/class_8934;field_47154:Ljava/lang/String;official bLcdh;b:Ljava/lang/String;
-
LOOT_TABLE_SEED_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector named LOOT_TABLE_SEED_KEYLnet/minecraft/inventory/LootableInventory;LOOT_TABLE_SEED_KEY:Ljava/lang/String;intermediary field_47155Lnet/minecraft/class_8934;field_47155:Ljava/lang/String;official cLcdh;c:Ljava/lang/String;
-
-
Method Details
-
getLootTable
@Nullable RegistryKey<LootTable> getLootTable()- Mappings:
Namespace Name Mixin selector named getLootTableLnet/minecraft/inventory/LootableInventory;getLootTable()Lnet/minecraft/registry/RegistryKey;intermediary method_54869Lnet/minecraft/class_8934;method_54869()Lnet/minecraft/class_5321;official ay_Lcdh;ay_()Lamt;
-
setLootTable
- Mappings:
Namespace Name Mixin selector named setLootTableLnet/minecraft/inventory/LootableInventory;setLootTable(Lnet/minecraft/registry/RegistryKey;)Vintermediary method_11285Lnet/minecraft/class_8934;method_11285(Lnet/minecraft/class_5321;)Vofficial aLcdh;a(Lamt;)V
-
setLootTable
Sets the loot table and seed at once. This is useful for code-based structure generation.- See Also:
- Mappings:
Namespace Name Mixin selector named setLootTableLnet/minecraft/inventory/LootableInventory;setLootTable(Lnet/minecraft/registry/RegistryKey;J)Vintermediary method_54867Lnet/minecraft/class_8934;method_54867(Lnet/minecraft/class_5321;J)Vofficial aLcdh;a(Lamt;J)V
-
getLootTableSeed
long getLootTableSeed()Returns the loot table's seed.Vanilla implementations return
0when 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 named getLootTableSeedLnet/minecraft/inventory/LootableInventory;getLootTableSeed()Jintermediary method_54870Lnet/minecraft/class_8934;method_54870()Jofficial aB_Lcdh;aB_()J
-
setLootTableSeed
void setLootTableSeed(long lootTableSeed) Sets the loot table's seed.Vanilla implementations return
0when 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 named setLootTableSeedLnet/minecraft/inventory/LootableInventory;setLootTableSeed(J)Vintermediary method_54866Lnet/minecraft/class_8934;method_54866(J)Vofficial aLcdh;a(J)V
-
getPos
BlockPos getPos()- Mappings:
Namespace Name Mixin selector named getPosLnet/minecraft/inventory/LootableInventory;getPos()Lnet/minecraft/util/math/BlockPos;intermediary method_11016Lnet/minecraft/class_8934;method_11016()Lnet/minecraft/class_2338;official aC_Lcdh;aC_()Lis;
-
getWorld
@Nullable World getWorld()- Mappings:
Namespace Name Mixin selector named getWorldLnet/minecraft/inventory/LootableInventory;getWorld()Lnet/minecraft/world/World;intermediary method_10997Lnet/minecraft/class_8934;method_10997()Lnet/minecraft/class_1937;official jLcdh;j()Ldvg;
-
setLootTable
static void setLootTable(BlockView world, Random random, BlockPos pos, RegistryKey<LootTable> lootTableId) Queries the block entity atpos, checks if it is aLootableInventory, and sets the loot table and seed if applicable. This is useful for code-based structure generation.- See Also:
- Mappings:
Namespace Name Mixin selector named setLootTableLnet/minecraft/inventory/LootableInventory;setLootTable(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/registry/RegistryKey;)Vintermediary method_54868Lnet/minecraft/class_8934;method_54868(Lnet/minecraft/class_1922;Lnet/minecraft/class_5819;Lnet/minecraft/class_2338;Lnet/minecraft/class_5321;)Vofficial aLcdh;a(Ldul;Lbgq;Lis;Lamt;)V
-
readLootTable
Reads the loot table and seed fromnbt, if the loot table exists innbt. Implementations should skip reading the contents of the inventory if this returnstrue.- Returns:
- whether the loot table was found
- Mappings:
Namespace Name Mixin selector named readLootTableLnet/minecraft/inventory/LootableInventory;readLootTable(Lnet/minecraft/storage/ReadView;)Zintermediary method_54871Lnet/minecraft/class_8934;method_54871(Lnet/minecraft/class_11368;)Zofficial c_Lcdh;c_(Lfmi;)Z
-
writeLootTable
Writes the loot table and seed tonbt, if the loot table 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 nonexistentlongvalues return0L.- Returns:
- whether the loot table was non-
null - Mappings:
Namespace Name Mixin selector named writeLootTableLnet/minecraft/inventory/LootableInventory;writeLootTable(Lnet/minecraft/storage/WriteView;)Zintermediary method_54872Lnet/minecraft/class_8934;method_54872(Lnet/minecraft/class_11372;)Zofficial d_Lcdh;d_(Lfmk;)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), ornullif there was no player involvement- Mappings:
Namespace Name Mixin selector named generateLootLnet/minecraft/inventory/LootableInventory;generateLoot(Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_54873Lnet/minecraft/class_8934;method_54873(Lnet/minecraft/class_1657;)Vofficial e_Lcdh;e_(Ldcm;)V
-