CONFIGURATION

Container Assignments

Container assignments determine which loot table is used when a player opens a container. They connect your loot tables to the containers players discover throughout your world.

Understanding assignments

An assignment connects a container to a specific loot table. This lets you control which rewards are available from different containers without needing to create a separate loot system for every container.

Why use assignments?

  • Give different containers access to different loot tables.
  • Organize rewards around different areas or dimensions.
  • Reuse loot tables across multiple containers.
  • Keep reward configuration separate from container placement.

Assignment configuration file

Container assignments are stored in a JSON file inside your Minecraft configuration directory:

File location
config/lootcontainers/loot_tables/container_assignments.json

If the file does not exist when the assignment manager loads, the mod creates a default configuration automatically.

Default assignment

The default configuration creates an enabled assignment namedOverworld Containers.

Default assignment values
{
  "id": "overworld_containers",
  "displayName": "Overworld Containers",
  "blockId": "",
  "blockTag": "lootcontainers:loot_containers",
  "lootTableId": "overworld",
  "enabled": true
}

This assignment uses a block tag rather than an individual block ID and connects matching containers to the Overworld loot table.

Assignment properties

Every container assignment contains several properties that determine which blocks it applies to and which loot table those blocks use.

PropertyPurpose
idUnique identifier for the assignment.
displayNameName displayed for the assignment.
dimensionIdDimension where the assignment applies. Empty means any dimension.
blockIdTargets one specific block.
blockTagTargets blocks belonging to a block tag.
blockIdsTargets multiple individually specified blocks.
lootTableIdID of the loot table used by this assignment.
enabledDetermines whether the assignment is enabled.

Choosing a block selection method

Each assignment must use exactly one of the three available block selection methods. Combining them or leaving all three empty will cause validation to fail.

1. Individual block

Use blockId when you want an assignment to target one specific block.

Example
{
  "blockId": "minecraft:chest",
  "blockTag": "",
  "blockIds": []
}

2. Block tag

Use blockTag when you want an assignment to target every block belonging to a particular tag.

Example
{
  "blockId": "",
  "blockTag": "lootcontainers:loot_containers",
  "blockIds": []
}

3. Multiple block IDs

Use blockIds when you want one assignment to target several individually specified blocks.

Example
{
  "blockId": "",
  "blockTag": "",
  "blockIds": [
    "minecraft:chest",
    "minecraft:trapped_chest",
    "minecraft:barrel"
  ]
}

Dimension matching

Assignments can optionally target a specific Minecraft dimension. This lets you use different loot tables for containers in the Overworld, Nether, End, or custom dimensions.

The dimensionId property accepts a Minecraft resource location, such as minecraft:the_nether.

Nether-only assignment
{
  "dimensionId": "minecraft:the_nether"
}

All dimensions

Leave dimensionId empty to allow the assignment to match in any dimension.

Validation rules

The assignment validator checks configurations before they can be saved. Invalid assignments are rejected.

  • Assignment IDs must contain only lowercase letters, numbers, underscores, and hyphens.
  • Assignment IDs must be unique.
  • Dimension IDs must be valid resource locations when provided.
  • Block IDs and block tags must be valid resource locations.
  • Block ID lists cannot contain invalid or duplicate entries.
  • Exactly one block selection method must be configured.
  • The referenced loot table must exist in the loot table registry.

Important

A valid assignment is not automatically active just because it exists in the JSON file. Its enabled property must also be true.

Assignment priority

Container assignments are evaluated in the order they appear incontainer_assignments.json. When multiple assignments could match the same block, the first matching assignment takes priority.

First matching assignment wins

Once an enabled assignment matches the block and dimension, the registry immediately returns its assigned loot table. Assignments below it are not evaluated.

Example

Imagine you have two assignments targeting the same chest:

container_assignments.json
{
  "assignments": [
    {
      "id": "special_chests",
      "displayName": "Special Chests",
      "blockId": "minecraft:chest",
      "blockTag": "",
      "blockIds": [],
      "lootTableId": "rare_rewards",
      "enabled": true,
      "dimensionId": ""
    },
    {
      "id": "general_chests",
      "displayName": "General Chests",
      "blockId": "minecraft:chest",
      "blockTag": "",
      "blockIds": [],
      "lootTableId": "overworld",
      "enabled": true,
      "dimensionId": ""
    }
  ]
}

In this example, a chest matches both assignments, butspecial_chests comes first. Therefore, it receives the rare_rewards loot table.

Changing assignment priority

You can change priority by moving assignments to different positions in the assignment list. The assignment manager supports moving an assignment to a new position and saving the updated configuration.

When no assignment matches

If the block does not match any enabled assignment, or if its dimension does not match the configured dimension, the registry returns no loot table for that block.

The hasAssignment method can also be used to check whether a block has an enabled assignment that resolves to a loot table.

Container interaction and rewards

When a player right-clicks an assigned container, the server handles the interaction and determines whether the player has already received a reward result from that specific container.

One reward attempt per player

Each container has a unique identity, and reward results are tracked separately for every player. Once a player has attempted to receive a reward from a container, that result is saved.

Failed attempts count too

A failed reward roll is recorded just like a successful one. Players cannot repeatedly interact with the same container to reroll until they receive a reward.

What happens when no reward is found?

If the reward roll fails, the unsuccessful result is saved. The player cannot make another reward attempt from that same container.

Unlike successful rewards, failed reward attempts do not cancel the original block interaction. Normal block interaction behavior can therefore continue.

Container identity

Containers use unique UUIDs to distinguish individual placed containers. This allows the mod to maintain separate reward records even when multiple containers use the same block type and loot table.

Moving containers

The mod also supports restoring container identity when an assigned container is placed from an item that carries its saved identity. This helps preserve its existing tracking information when it is moved.

Important behavior

  • Only server-side main-hand right-click interactions are processed by this handler.
  • Unassigned blocks are not processed by this reward handler.
  • Each player has their own reward result for each container.
  • Both successful and unsuccessful results are saved.
  • Container records persist through Minecraft's SavedData system.

Per-player container tracking

Loot Containers tracks container interactions separately for each player. This allows the mod to remember which players have interacted with a particular container.

How tracking works

  • Container ID: Each tracked container has a unique UUID.
  • Player ID: Each player is identified by their Minecraft UUID.
  • Opening records: The mod records whether a player has opened a particular container.
  • Reward results: The mod separately records whether a player received a reward from that container.

Why track players individually?

A container can keep separate interaction records for different players. This means one player's interaction does not automatically count as another player's interaction.

Saved container data

Container tracking is stored using Minecraft's SavedData system. The data storage identifier islootcontainers_data.

Both opening records and reward results are written to world data and restored when that data is loaded again. This prevents the tracking information from simply disappearing when the world is restarted.