Class ExpandLootTable
java.lang.Object
com.blamejared.crafttweaker.natives.loot.table.ExpandLootTable
A loot table is used to determine what is dropped when the game needs to drop loot.
- DocParam:
- this lootTables.getTable(<resource:minecraft:gameplay/cat_morning_gift>)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfill(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.Container container, net.minecraft.world.level.storage.loot.LootParams params, long seed) Fills the given container with loot rolled by this table.static net.minecraft.world.level.storage.loot.parameters.LootContextParamSetgetParamSet(net.minecraft.world.level.storage.loot.LootTable internal) Gets the param set that this table uses.static List<IItemStack>getRandomItems(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootContext context) Rolls this table and returns the rolled items in a list.static voidgetRandomItems(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootContext context, Consumer<IItemStack> stackConsumer) Rolls this table and passes all the rolled items to the givenConsumer<{@link IItemStack}>static List<IItemStack>getRandomItems(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootParams params) Rolls this table and returns the rolled items in a list.static voidgetRandomItemsRaw(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootContext context, Consumer<IItemStack> stackConsumer) Rolls this table and passes all the rolled items to the givenConsumer<{@link IItemStack}>
-
Constructor Details
-
ExpandLootTable
public ExpandLootTable()
-
-
Method Details
-
getRandomItemsRaw
public static void getRandomItemsRaw(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootContext context, Consumer<IItemStack> stackConsumer) Rolls this table and passes all the rolled items to the givenConsumer<{@link IItemStack}>NOTE: This method does not respect max stack sizes!
NOTE: The provided
LootContextshould not be reused from a loot modifier, if you want to reuse a context, look atExpandLootContextBuilder.copy(LootContext).- Parameters:
context- The context that will generate the loot.stackConsumer- A consumer to act on the rolled stacks.- DocParam:
- context new LootContextBuilder(level).withParameter
(LootContextParams.origin(), player.position).withParameter (LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()), stackConsumer (stack) => { println(stack.commandString); }
-
getRandomItems
public static void getRandomItems(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootContext context, Consumer<IItemStack> stackConsumer) Rolls this table and passes all the rolled items to the givenConsumer<{@link IItemStack}>NOTE: This method does respect max stack sizes
NOTE: The provided
LootContextshould not be reused from a loot modifier, if you want to reuse a context, look atExpandLootContextBuilder.copy(LootContext).- Parameters:
context- The context that will generate the loot.stackConsumer- A consumer to act on the rolled stacks.- DocParam:
- context new LootContextBuilder(level).withParameter
(LootContextParams.origin(), player.position).withParameter (LootContextParams.thisEntity(), player).create(LootContextParamSets.gift()), stackConsumer (stack) => { println(stack.commandString); }
-
getRandomItems
public static List<IItemStack> getRandomItems(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootContext context) Rolls this table and returns the rolled items in a list.NOTE: The provided
LootContextshould not be reused from a loot modifier, if you want to reuse a context, look atExpandLootContextBuilder.copy(LootContext).- Parameters:
context- The context that this loot was generated with.- Returns:
- A list containing all the rolled items.
- DocParam:
- context new LootContextBuilder(level).withParameter
(LootContextParams.origin(), player.position).withParameter (LootContextParams.thisEntity(), player).create(LootContextParamSets.gift())
-
getRandomItems
public static List<IItemStack> getRandomItems(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.level.storage.loot.LootParams params) Rolls this table and returns the rolled items in a list.NOTE: The provided
LootContextshould not be reused from a loot modifier, if you want to reuse a context, look atExpandLootContextBuilder.copy(LootContext).- Parameters:
params- The params that this loot was generated with.- Returns:
- A list containing all the rolled items.
- DocParam:
- context new LootContextBuilder(level).withParameter
(LootContextParams.origin(), player.position).withParameter (LootContextParams.thisEntity(), player).create(LootContextParamSets.gift())
-
getParamSet
public static net.minecraft.world.level.storage.loot.parameters.LootContextParamSet getParamSet(net.minecraft.world.level.storage.loot.LootTable internal) Gets the param set that this table uses.- Returns:
- The param set that this table uses.
-
fill
public static void fill(net.minecraft.world.level.storage.loot.LootTable internal, net.minecraft.world.Container container, net.minecraft.world.level.storage.loot.LootParams params, long seed) Fills the given container with loot rolled by this table.- Parameters:
container- The container to fill.params- The params that will be used to generate the loot.seed- An Optional seed used to generate the loot, defaults to0if not supplied.- DocParam:
- container container
-