Skip to content

Block Loot Table Data Generation

Maksym Uimanov edited this page Feb 12, 2026 · 1 revision

Block Loot Table Data Generation

The Temporal API provides a comprehensive set of annotations for automatically generating block loot tables during data generation. These annotations eliminate the need for manual JSON loot table creation by programmatically registering loot behavior based on predefined strategies.

Responsibilities / Purpose

  • Automates loot generation: Generates loot table JSON files without manual asset creation
  • Provides loot variety: Supports different block types (ores, crops, leaves, etc.)
  • Integrates with data generation: Works seamlessly with NeoForge's data generation system
  • Enables customization: Allows custom loot strategies for specialized block types

How it works

  1. Annotation processing: The framework scans fields annotated with loot table annotations
  2. Strategy selection: Each annotation maps to a specific LootProviderStrategy implementation
  3. Loot creation: Strategies create appropriate loot tables using the loot provider
  4. Data generation: During data generation, loot tables are automatically registered and JSON files are generated

Common Loot Table Annotations

@GenerateSelfBlockLootTable

Generates a loot table that drops the block itself when broken.

@GenerateSelfBlockLootTable
public static final DeferredBlock<?> EXAMPLE_BLOCK = BLOCK_FACTORY.create("example_block", BlockPropertiesFactory.empty());

Use cases: Building blocks, decorative blocks, blocks that should drop themselves

@GenerateEmptyBlockLootTable

Generates an empty loot table that drops nothing when broken.

@GenerateEmptyBlockLootTable
public static final DeferredBlock<?> EMPTY_BLOCK = BLOCK_FACTORY.create("empty_block", BlockPropertiesFactory.empty());

Use cases: Technical blocks, air-like blocks, blocks that should not drop anything

Resource-Based Loot Tables

@GenerateOreBlockLootTable

Generates a loot table that drops raw ore items with fortune bonus support.

@GenerateOreBlockLootTable(rawOre = "example:example_ingot")
public static final DeferredBlock<?> EXAMPLE_ORE = BLOCK_FACTORY.create("example_ore", BlockPropertiesFactory.stone());

Parameters:

  • rawOre (required): Resource location of the raw ore item to drop

@GenerateMultipleOreBlockLootTable

Generates a loot table that drops multiple raw ore items with configurable range.

@GenerateMultipleOreBlockLootTable(
    rawOre = "example:example_ingot",
    min = 1.0f,
    max = 3.0f
)
public static final DeferredBlock<?> RICH_ORE = BLOCK_FACTORY.create("rich_ore", BlockPropertiesFactory.stone());

Parameters:

  • rawOre (required): Resource location of the raw ore item to drop
  • min (required): Minimum number of items to drop
  • max (required): Maximum number of items to drop

Plant-Based Loot Tables

@GenerateLeavesBlockLootTable

Generates a loot table that drops saplings with configurable chances based on fortune level.

@GenerateLeavesBlockLootTable(sapling = "example:example_sapling", chances = {0.02F, 0.022222223F, 0.025F, 0.033333335F, 0.1F})
public static final DeferredBlock<?> EXAMPLE_LEAVES = BLOCK_FACTORY.createLeaves("example_leaves");

Parameters:

  • sapling (required): Resource location of the sapling item to drop
  • chances (required): Array of drop chances for fortune levels 0-4

Chance array format:

  • Index 0: Fortune level 0 (no fortune)
  • Index 1: Fortune level 1
  • Index 2: Fortune level 2
  • Index 3: Fortune level 3
  • Index 4: Fortune level 4+

@GenerateGrassBlockLootTable

Generates a loot table that drops seeds when broken.

@GenerateGrassBlockLootTable(seeds = "minecraft:seeds")
public static final DeferredBlock<?> EXAMPLE_GRASS = BLOCK_FACTORY.createFlower("example_grass", BlockPropertiesFactory.shortGrass(), MobEffects.DAMAGE_RESISTANCE, 1);

Parameters:

  • seeds (required): Resource location of the seeds item to drop

@GenerateCropBlockLootTable

Generates a loot table for crop blocks with age-based drops.

@GenerateCropBlockLootTable(
    grown = "example:example_crop",
    seeds = "example:example_seeds",
    grownAge = 7,
    minAge = 0,
    maxAge = 3
)
public static final DeferredBlock<?> EXAMPLE_CROP = BLOCK_FACTORY.createCrop("example_crop", BlockPropertiesFactory.crop());

Parameters:

  • grown (required): Resource location of the fully grown crop item
  • seeds (required): Resource location of the seeds item
  • grownAge (required): Age value when the crop is fully grown
  • minAge (required): Minimum age for seed drops
  • maxAge (required): Maximum age for seed drops

Specialized Loot Tables

@GenerateDoorBlockLootTable

Generates a loot table for door blocks that drops the door item.

@GenerateDoorBlockLootTable
public static final DeferredBlock<?> EXAMPLE_DOOR = BLOCK_FACTORY.createDoor("example_door", ExampleWoodTypes.EXAMPLE_WOOD_TYPE);

Use cases: Wooden doors, iron doors, custom doors

@GenerateShulkerBoxBlockLootTable

Generates a loot table for shulker box blocks that preserves contents.

@GenerateShulkerBoxBlockLootTable
public static final DeferredBlock<?> EXAMPLE_SHULKER_BOX = BLOCK_FACTORY.createShulkerBox("example_shulker_box");

Use cases: Shulker boxes, storage blocks with contents preservation

@GenerateBannerBlockLootTable

Generates a loot table for banner blocks that preserves patterns.

Use cases: Banners, patterned blocks with custom designs

@GenerateMushroomBlockLootTable

Generates a loot table for mushroom blocks.

Use cases: Red mushrooms, brown mushrooms, custom mushroom blocks

Tool-Specific Loot Tables

@GenerateSilkTouchBlockLootTable

Generates a loot table that drops the block only with silk touch.

@GenerateSilkTouchBlockLootTable
public static final DeferredBlock<?> SILK_TOUCH_BLOCK = BLOCK_FACTORY.create("silk_touch_block", BlockPropertiesFactory.stone());

Use cases: Glass blocks, ice blocks, blocks that should only drop with silk touch

@GenerateShearsOnlyBlockLootTable

Generates a loot table that drops the block only when broken with shears.

@GenerateShearsOnlyBlockLootTable
public static final DeferredBlock<?> SHEARS_BLOCK = BLOCK_FACTORY.create("shears_block", BlockPropertiesFactory.plant());

Use cases: Plants, leaves, wool blocks, blocks that require shears to drop

Container Loot Tables

@GeneratePottedContentBlockLootTable

Generates a loot table for potted blocks that drops the content item.

@GeneratePottedContentBlockLootTable
public static final DeferredBlock<?> POTTED_EXAMPLE_FLOWER = BLOCK_FACTORY.createPottedFlower("potted_example_flower", EXAMPLE_FLOWER);

Use cases: Potted flowers, potted saplings, potted plants

Custom Loot Table Annotation

@GenerateCustomBlockLootTable

Allows custom loot table generation using a custom strategy.

@GenerateCustomBlockLootTable(
    strategy = CustomBlockLootTableStrategy.class,
    additionalData = {"custom_param1", "custom_param2"}
)
public static final DeferredBlock<?> CUSTOM_BLOCK = BLOCK_FACTORY.create("custom_block", BlockPropertiesFactory.empty());

Parameters:

  • strategy: Custom strategy class implementing LootProviderStrategy<CustomBlockLootTableSpec>
  • additionalData (optional): String array for custom parameters

Fortune and Tool Support

Many loot table annotations automatically support:

  • Fortune enchantment: Increases drop chances for applicable blocks
  • Tool requirements: Some blocks only drop with specific tools
  • Silk touch: Special handling for silk touch enchantment
  • Shears: Special handling for shears tool

Loot Table Structure

Generated loot tables follow Minecraft's standard loot table format:

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "modid:item_name"
        }
      ],
      "conditions": [
        {
          "condition": "minecraft:survives_explosion"
        }
      ]
    }
  ]
}

When to use

  • Standard blocks: Use @GenerateSelfBlockLootTable for blocks that drop themselves
  • Ore blocks: Use @GenerateOreBlockLootTable or @GenerateMultipleOreBlockLootTable for ores
  • Plant blocks: Use @GenerateLeavesBlockLootTable, @GenerateGrassBlockLootTable, or @GenerateCropBlockLootTable
  • Tool-specific: Use @GenerateSilkTouchBlockLootTable or @GenerateShearsOnlyBlockLootTable for special requirements
  • Empty drops: Use @GenerateEmptyBlockLootTable for blocks that should not drop anything
  • Custom needs: Use @GenerateCustomBlockLootTable for unique loot requirements

Extension Points

The annotation system integrates with the Temporal API's metadata processing:

  • Strategy interface: LootProviderStrategy<T> for custom loot generation
  • Custom strategies: Implement custom strategies for specialized loot table needs
  • Fortune support: Built-in fortune enchantment handling for applicable blocks
  • Tool conditions: Automatic tool requirement handling for specialized blocks

Each annotation maps to a specific strategy implementation that handles the loot table generation logic, allowing for easy extension and customization of the block loot generation system.

Clone this wiki locally