Skip to content

API reference Obsidian.API.Loot

LootTable class

A vanilla loot table: pools of weighted entries that generate item stacks. The vanilla tables are in LootTables.

public sealed class LootTable

In Obsidian.API.

Remarks

Generating with a context seeded from LootTable.CreateRandom gives the same items in the same order (and LootTable.Fill the same slots) as vanilla for the same seed.

Constructors

public LootTable();

Properties

Empty

public static LootTable Empty { get; }

A table that generates nothing; vanilla uses it for unknown ids.

Functions

public ImmutableArray<LootFunction> Functions { get; init; }

Applied to every stack the table generates, after the pool's functions.

Identifier

public string Identifier { get; init; }

Registry id (e.g. minecraft:chests/simple_dungeon), or empty for tables defined inline.

public ImmutableArray<LootPool> Pools { get; init; }

RandomSequence

public string RandomSequence { get; init; }

The level random sequence used when the table is generated without a seed (see LootTable.CreateRandom).

Type

public string Type { get; init; }

The context parameter set the table is meant for, e.g. minecraft:chest or minecraft:archaeology.

Methods

CreateRandom(long, RandomSequences)

public IRandomSource CreateRandom(long seed, RandomSequences sequences = null);

Creates the random source vanilla uses for a stored loot table seed: a non-zero seed seeds a fresh LegacyRandomSource; seed 0 means "unseeded" and takes the next values of the level's random sequence for LootTable.RandomSequence, or an arbitrary seed when there is none.

Fill(BaseContainer, LootContext)

public void Fill(BaseContainer container, LootContext context);

Generates the table's stacks into the empty slots of container, like vanilla's LootTable.fill: stacks are split up to spread over the free slots, shuffled and put in random slots.

GetRandomItems(LootContext)

public List<ItemStack> GetRandomItems(LootContext context);

Generates the table's stacks. Stacks above their item's max stack size are split into full stacks and a remainder, like vanilla's stack splitter. Stacks that functions emptied are kept, as in vanilla.

GetRandomItemsRaw(LootContext, Action<ItemStack>)

public void GetRandomItemsRaw(LootContext context, Action<ItemStack> output);

Generates the table's stacks without splitting oversized stacks. Used for nested tables.

On this page