LootTable
Importing the class
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.
import crafttweaker.api.loot.LootTable;
Description
A loot table is used to determine what is dropped when the game needs to drop loot.Members
myLootTable.fill(container, myLootParams, myLong);
Parameters:
seed: long
(optional) Type: long
- An Optional seed used to generate the loot, defaults to 0
if not supplied.
Default Value: 0
Consumer<{@link 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 com.blamejared.crafttweaker.natives.loot.ExpandLootContextBuilder#copy(LootContext).
// LootTable.getRandomItems(context as LootContext, stackConsumer as function(t as IItemStack) as void);myLootTable.getRandomItems(new LootContextBuilder(level).withParameter<Vec3>(LootContextParams.origin(), player.position).withParameter<Entity>(LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()), (stack) => {println(stack.commandString);});
Parameters:
stackConsumer: function(t as IItemStack) as void
Type: function(t as IItemStack) as void
- A consumer to act on the rolled stacks. NOTE: The provided LootContext
should not be reused from a loot modifier, if you want to reuse a context, look at com.blamejared.crafttweaker.natives.loot.ExpandLootContextBuilder#copy(LootContext).
Returns: A list containing all the rolled items.
myLootTable.getRandomItems(new LootContextBuilder(level).withParameter<Vec3>(LootContextParams.origin(), player.position).withParameter<Entity>(LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()));
Parameters:
Return Type:
List<IItemStack>
NOTE: The provided LootContext
should not be reused from a loot modifier, if you want to reuse a context, look at com.blamejared.crafttweaker.natives.loot.ExpandLootContextBuilder#copy(LootContext).
Returns: A list containing all the rolled items.
myLootTable.getRandomItems(myLootParams);
Parameters:
Return Type:
List<IItemStack>
Consumer<{@link 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 com.blamejared.crafttweaker.natives.loot.ExpandLootContextBuilder#copy(LootContext).
// LootTable.getRandomItemsRaw(context as LootContext, stackConsumer as function(t as IItemStack) as void);myLootTable.getRandomItemsRaw(new LootContextBuilder(level).withParameter<Vec3>(LootContextParams.origin(), player.position).withParameter<Entity>(LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()), (stack) => {println(stack.commandString);});
Parameters:
stackConsumer: function(t as IItemStack) as void
Type: function(t as IItemStack) as void
- A consumer to act on the rolled stacks. // LootTable.id as ResourceLocationmyLootTable.id
Return Type:
ResourceLocation
Returns: The ID of this loot table.
myLootTable.id();
Return Type:
ResourceLocation
// LootTable.paramSet as LootContextParamSetmyLootTable.paramSet
Return Type:
LootContextParamSet
Returns: The param set that this table uses.
myLootTable.paramSet();
Return Type:
LootContextParamSet