Class: LootTableManager
Beta
战利品表相关 API 的管理器。可根据方块和实体的战利品表生成掉落物。
Manager for Loot Table related APIs. Allows for generation of drops from blocks and entities according to their loot tables.
Methods
generateLootFromBlock()
generateLootFromBlock(
block,tool?):ItemStack[] |undefined
Beta
Parameters
block
要生成战利品的方块。
The block to generate loot from.
tool?
可选。用于挖掘的工具。
Optional. The tool to use in the looting operation.
Returns
ItemStack[] | undefined
战利品掉落事件中掉落的物品堆数组。若没有掉落物则为空数组;若所提供的工具不足以挖掘该方块,则返回 undefined。
An array of item stacks dropped from the loot drop event. Can be empty if no loot dropped, or undefined if the provided tool is insufficient to mine the block.
Remarks
模拟挖掘行为,根据给定的方块生成战利品。
Generates loot from a given block as if it had been mined.
Throws
当方块位于未加载的区块中,或方块位置超出世界边界时抛出。
Throws if the block is in an unloaded chunk, or if the block's position is outside of world bounds.
LocationOutOfWorldBoundariesError
generateLootFromBlockPermutation()
generateLootFromBlockPermutation(
blockPermutation,tool?):ItemStack[] |undefined
Beta
Parameters
blockPermutation
tool?
可选。用于挖掘的工具。
Optional. The tool to use in the looting operation.
Returns
ItemStack[] | undefined
战利品掉落事件中掉落的物品堆数组。若没有掉落物则为空数组;若所提供的工具不足以挖掘该方块,则返回 undefined。
An array of item stacks dropped from the loot drop event. Can be empty if no loot dropped, or undefined if the provided tool is insufficient to mine the block.
Remarks
模拟挖掘行为,根据给定的方块状态(BlockPermutation)生成战利品。
Generates loot from a given block permutation as if it had been mined.
generateLootFromBlockType()
generateLootFromBlockType(
scriptBlockType,tool?):ItemStack[] |undefined
Beta
Parameters
scriptBlockType
tool?
可选。用于挖掘的工具。
Optional. The tool to use in the looting operation.
Returns
ItemStack[] | undefined
战利品掉落事件中掉落的物品堆数组。若没有掉落物则为空数组;若所提供的工具不足以挖掘该方块,则返回 undefined。
An array of item stacks dropped from the loot drop event. Can be empty if no loot dropped, or undefined if the provided tool is insufficient to mine the block.
Remarks
模拟挖掘行为,根据给定的方块类型生成战利品。
Generates loot from a given block type as if it had been mined.
generateLootFromEntity()
generateLootFromEntity(
entity,tool?):ItemStack[] |undefined
Beta
Parameters
entity
tool?
可选。用于击杀的工具。
Optional. The tool to use in the looting operation.
Returns
ItemStack[] | undefined
战利品掉落事件中掉落的物品堆数组。若没有掉落物则为空数组;若实体无效则返回 undefined。
An array of item stacks dropped from the loot drop event. Can be empty if no loot dropped, or undefined if the entity was invalid.
Remarks
模拟击杀行为,根据给定的实体生成战利品。
Generates loot from given a entity as if it had been killed.
Throws
This function can throw errors.
generateLootFromEntityType()
generateLootFromEntityType(
entityType,tool?):ItemStack[] |undefined
Beta
Parameters
entityType
tool?
可选。用于击杀的工具。
Optional. The tool to use in the looting operation.
Returns
ItemStack[] | undefined
战利品掉落事件中掉落的物品堆数组。若没有掉落物则为空数组。
An array of item stacks dropped from the loot drop event. Can be empty if no loot dropped.
Remarks
模拟击杀行为,根据给定的实体类型生成战利品。
Generates loot from given a entity type as if it had been killed.
generateLootFromTable()
generateLootFromTable(
lootTable,tool?):ItemStack[] |undefined
Beta
Parameters
lootTable
tool?
可选。用于挖掘的工具。
Optional. The tool to use in the looting operation.
Returns
ItemStack[] | undefined
战利品掉落事件中掉落的物品堆数组。若没有掉落物则为空数组;若所提供的工具不足以挖掘该方块,则返回 undefined。
An array of item stacks dropped from the loot drop event. Can be empty if no loot dropped, or undefined if the provided tool is insufficient to mine the block.
Remarks
根据给定的战利品表(LootTable)生成战利品。
Generates loot from a given LootTable.
getLootTable()
getLootTable(
path):LootTable|undefined
Beta
Parameters
path
string
要获取的战利品表路径。不含文件扩展名,也不含 loot_tables/ 前缀。例如:entities/creeper。
Path to the table to retrieve. Does not include file
extension, or 'loot_tables/' folder prefix. Example:
entities/creeper.
Returns
LootTable | undefined
若找到对应的战利品表则返回该 LootTable,若所提供的路径不存在对应战利品表则返回 undefined。
Returns a LootTable if one is found, or undefined if the
provided path does not correspond to an existing loot table.
Remarks
从当前关卡的注册表中获取单个战利品表。
Retrieves a single loot table from the level's current registry.
