A loot table is used to determine what is dropped when the game needs to drop loot.

Импорт класса

Link to импорт-класса

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.loot.LootTable;

Name: fill

Fills the given container with loot rolled by this table.

ZenScript
Copy
LootTable.fill(container as Container, context as LootContext)
ПараметрТипОписание
Параметр
container
Тип
Container
Описание
The container to fill.
Параметр
контекст
Тип
LootContext
Описание
The context that will generate the loot.

Name: getParamSet

Gets the param set that this table uses.

Returns: The param set that this table uses.
Return Type: LootContextParamSet

ZenScript
Copy
// LootTable.getParamSet() as LootContextParamSet

lootTables.getTable(<resource:minecraft:gameplay/cat_morning_gift>).getParamSet();

Name: getRandomItems

Rolls this table and returns the rolled items in a list.

NOTE: The provided LootContext should not be reused from a loot modifier, if you want to reuse a context, look at invalid#copy(LootContext).

Returns: A list containing all the rolled items.
Return Type: stdlib.List<IItemStack>

ZenScript
Copy
// LootTable.getRandomItems(context as LootContext) as stdlib.List<IItemStack>

lootTables.getTable(<resource:minecraft:gameplay/cat_morning_gift>).getRandomItems(new LootContextBuilder(level).withParameter<Vec3>(LootContextParams.origin(), player.position).withParameter<Entity>(LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()));
ПараметрТипОписание
Параметр
контекст
Тип
LootContext
Описание
The context that this loot was generated.

Name: getRandomItems

Rolls this table and passes all the rolled items to the given Consumer<[IItemStack](/vanilla/api/item/IItemStack)>

NOTE: This method does respect max stack sizes NOTE: The provided LootContext should not be reused from a loot modifier, if you want to reuse a context, look at invalid#copy(LootContext).

ZenScript
Copy
// LootTable.getRandomItems(context as LootContext, stackConsumer as Consumer<IItemStack>)

lootTables.getTable(<resource:minecraft:gameplay/cat_morning_gift>).getRandomItems(new LootContextBuilder(level).withParameter<Vec3>(LootContextParams.origin(), player.position).withParameter<Entity>(LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()), (stack) => {

 println(stack.commandString);
 });
ПараметрТипОписание
Параметр
контекст
Тип
LootContext
Описание
The context that will generate the loot.
Параметр
stackConsumer
Тип
Consumer<IItemStack>
Описание
A consumer to act on the rolled stacks.

Link to getRandomItemsRaw

Name: getRandomItemsRaw

Rolls this table and passes all the rolled items to the given Consumer<[IItemStack](/vanilla/api/item/IItemStack)>

NOTE: This method does not respect max stack sizes! NOTE: The provided LootContext should not be reused from a loot modifier, if you want to reuse a context, look at invalid#copy(LootContext).

ZenScript
Copy
// LootTable.getRandomItemsRaw(context as LootContext, stackConsumer as Consumer<IItemStack>)

lootTables.getTable(<resource:minecraft:gameplay/cat_morning_gift>).getRandomItemsRaw(new LootContextBuilder(level).withParameter<Vec3>(LootContextParams.origin(), player.position).withParameter<Entity>(LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()), (stack) => {

 println(stack.commandString);
 });
ПараметрТипОписание
Параметр
контекст
Тип
LootContext
Описание
The context that will generate the loot.
Параметр
stackConsumer
Тип
Consumer<IItemStack>
Описание
A consumer to act on the rolled stacks.

Свойства

Link to свойства

НазваниеТипИмеет GetterИмеет SetterОписание
Название
paramSet
Тип
LootContextParamSet
Имеет Getter
true
Имеет Setter
false
Описание
Gets the param set that this table uses.