Class ExpandLootTable

java.lang.Object
com.blamejared.crafttweaker.natives.loot.table.ExpandLootTable

@ZenRegister public final class ExpandLootTable extends Object
A loot table is used to determine what is dropped when the game needs to drop loot.
DocParam:
this lootTables.getTable(invalid input: '<'resource:minecraft:gameplay/cat_morning_gift>)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    static net.minecraft.resources.ResourceLocation
    getId(net.minecraft.world.level.storage.loot.LootTable internal)
    Gets the ID of this loot table.
    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.
    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 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 given Consumer<{@link 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 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 given Consumer<{@link IItemStack}>

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 given 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 ExpandLootContextBuilder.copy(LootContext).

      Parameters:
      context - The context that will generate the loot.
      stackConsumer - A consumer to act on the rolled stacks.
      DocParam:
      context LootContextBuilder.create(LootParamsBuilder.create(level).withParameter(LootContextParams.origin(), player.position).withParameter(LootContextParams.thisEntity(), player).build(LootContextParamSets.gift())).create(), 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 given 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 ExpandLootContextBuilder.copy(LootContext).

      Parameters:
      context - The context that will generate the loot.
      stackConsumer - A consumer to act on the rolled stacks.
      DocParam:
      context LootContextBuilder.create(LootParamsBuilder.create(level).withParameter(LootContextParams.origin(), player.position).withParameter(LootContextParams.thisEntity(), player).build(LootContextParamSets.gift())).create(), 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 LootContext should not be reused from a loot modifier, if you want to reuse a context, look at ExpandLootContextBuilder.copy(LootContext).

      Parameters:
      context - The context that this loot was generated with.
      Returns:
      A list containing all the rolled items.
      DocParam:
      context LootContextBuilder.create(LootParamsBuilder.create(level).withParameter(LootContextParams.origin(), player.position).withParameter(LootContextParams.thisEntity(), player).build(LootContextParamSets.gift())).create()
    • 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 LootContext should not be reused from a loot modifier, if you want to reuse a context, look at ExpandLootContextBuilder.copy(LootContext).

      Parameters:
      params - The params that this loot was generated with.
      Returns:
      A list containing all the rolled items.
      DocParam:
      context LootContextBuilder.create(LootParamsBuilder.create(level).withParameter(LootContextParams.origin(), player.position).withParameter(LootContextParams.thisEntity(), player).build(LootContextParamSets.gift())).create()
    • 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.
    • getId

      public static net.minecraft.resources.ResourceLocation getId(net.minecraft.world.level.storage.loot.LootTable internal)
      Gets the ID of this loot table.
      Returns:
      The ID of this loot table.
    • 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 to 0 if not supplied.
      DocParam:
      container container