Adding a Loot Table, Spawn Rule & Crafting Recipe
Next, we'll enhance the custom Ghost entity by adding some more basic mechanics to it.
Loot Tables
First, we'll make the ghost drop Ectoplasm upon death: create the following file:
{ "pools": [ { "rolls": 1, "entries": [ { "type": "item", "name": "wiki:ectoplasm", "weight": 1, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 3 } } ] } ] } ]}
Loot Tables consist of "pools"
. Each pool defines a different loot. A pool consists of 3 parts: "rolls"
, "entries"
and "conditions"
(optional, see Loot Tables guide for details).
"rolls"
: Defines how many times a random entry will be chosen from the following"entries"
object."entries"
: Defines the items from which the loot table can choose. Each roll selects a new item."type"
: Can be"item"
or"loot_table"
."name"
: The item identifier (e.g.,wiki:ectoplasm
)."weight"
: (Optional, default 1) Likelihood of this entry being chosen relative to others in the same pool."functions"
: (Optional) Modifies the output item. Example:"set_count"
defines the min/max number of items dropped via the"count"
property.
For more information on loot tables, see our extended guide: Loot Tables!
Spawn Rules
Next, we'll make the ghost spawn in deserts at night:
{ "format_version": "1.8.0", "minecraft:spawn_rules": { "description": { "identifier": "wiki:ghost", "population_control": "monster" }, "conditions": [ { "minecraft:spawns_on_surface": {}, "minecraft:brightness_filter": { "min": 0, "max": 7, "adjust_for_weather": true }, "minecraft:difficulty_filter": { "min": "easy", "max": "hard" }, "minecraft:weight": { "default": 80 }, "minecraft:herd": { "min_size": 1, "max_size": 3 }, "minecraft:biome_filter": { "test": "has_biome_tag", "operator": "==", "value": "desert" } } ] }}
Inside "minecraft:spawn_rules"
we define the rules:
"description"
: Contains the"identifier"
of the entity this rule applies to (wiki:ghost
) and"population_control"
(e.g.,"monster"
,"animal"
) to limit spawning based on mob caps."conditions"
: An array of rules that must be met for spawning."minecraft:spawns_on_surface"
: Allows spawning only on surfaces."minecraft:brightness_filter"
: Limits spawning based on light level (0-7 here).adjust_for_weather
ignores temporary darkness from weather."minecraft:difficulty_filter"
: Limits spawning to certain game difficulties."minecraft:weight"
: How likely this mob is to be chosen for spawning (higher is more common)."minecraft:herd"
: Defines the min/max number of entities spawning together."minecraft:biome_filter"
: Restricts spawning to specific biomes or biome tags (here, only biomes tagged as"desert"
).
To learn more about conditions and how to use them, see the Spawn Rules section or look at the guide on Vanilla Spawn Rules.
Crafting Recipes
Finally, as an introduction to recipes, we'll make the Ectoplasm craftable into Slime Blocks:
{ "format_version": "1.12.0", "minecraft:recipe_shaped": { "description": { "identifier": "wiki:ectoplasm_slime_block" }, "tags": ["crafting_table"], "pattern": ["###", "###", "###"], "key": { "#": { "item": "wiki:ectoplasm" } }, "result": { "item": "minecraft:slime" } }}
Using "minecraft:recipe_shaped"
means ingredients must be in specific slots:
"description"
: Contains the unique"identifier"
for this recipe."tags"
: A list of crafting stations where this recipe works (e.g.,"crafting_table"
)."pattern"
: Defines the shape of items in the grid. Each character corresponds to an item defined in"key"
."key"
: Maps characters used in the pattern to specific item identifiers (here,"#"
maps towiki:ectoplasm
)."result"
: Defines the output item (minecraft:slime
).
For more information on shaped, shapeless, furnace recipes and more, visit our page about Recipes!
What You Have Learned
- How to create a loot table and define which items a mob drops.
- How to set the rules for where and when a mob can spawn.
- How to create new shaped crafting recipes.
Your Progress So Far
Beginner's Guide Checklist
- Setup your pack
- Create a custom item
- Create a custom entity
- Create the entity's loot, spawn rules, and a custom recipe
Congratulations! You have finished the Beginner's Guide and created your first Add-on. 🎉
Next Steps
You've covered the basics! Where do you want to go next?
Explore More Topics
Dive deeper into specific areas like advanced entities, blocks, UI, or scripting.
Join the Community
Connect with other creators, ask questions, and share your work on Discord.