Search the docs

Find a guide, global, type or member

TypeContentcontent.luau

ContentApi

The content global. It exists only in content.luau, which runs once when the experience's content is built, before any game script starts; game scripts cannot declare content. The file sees content, the standard library and require of modules inside the experience, nothing of the world or players.

Every id is a key this call declares: bare ("ruby") becomes <experience>:ruby, and an explicit namespace must be the experience's own. References to other content may also name minecraft: keys; another experience's keys are unreachable. Key paths are 1 to 128 of lowercase a-z, 0-9, _, -, . and /. Each kind of thing (block, item, tag, model, image, mob, recipe) has its own keys; a block with item also takes the item key.

Models and textures come from the experience's assets/ folder: textures/**/*.png, models/**/*.json and items/**/*.json, nothing else. A model key x of this experience needs assets/models/x.json or assets/textures/x.png. Each file is at most 1 MiB, the folder at most 16 MiB and 4096 files, and a PNG at most 1024 pixels a side.

Mistakes are refused when content is built and reported as file:line of the call that caused them, even inside pcall: a malformed table or unknown field, a duplicate key, a key outside the experience, a missing asset, an unknown reference, or a quota passed. Quotas: 2048 declarations, 256 donor states, 512 models, and a 5 second, 32 MiB run of the script.

Methods

contentApi.block(id: string, def: BlockDef)#

Declares a custom block.

contentApi.item(id: string, def: ItemDef)#

Declares a custom item.

contentApi.mob(id: string, def: MobDef)#

Declares a custom mob.

contentApi.model(id: string)#

Declares a display model scripts can show, from assets/models/<path>.json or assets/textures/<path>.png.

contentApi.image(id: string, def: ImageDef)#

Declares a font image or HUD font.

contentApi.itemTag(id: string, members: { string })#

Declares an item tag. Members are item keys, declared here or minecraft:; "#name" includes another item tag declared here. A tag may not include itself.

contentApi.blockTag(id: string, members: { string })#

Declares a block tag. Members are block keys, declared here or minecraft:; "#name" includes another block tag declared here. A tag may not include itself.

contentApi.shaped(id: string, def: { pattern: { string }, key: { [string]: string }, result: Result })#

Declares a crafting-table recipe. pattern is 1 to 3 rows of 1 to 3 symbols, space for an empty slot; key maps every symbol to an item key or "#tag", and only those.

contentApi.shapeless(id: string, def: { ingredients: { string }, result: Result })#

Declares a crafting recipe of 1 to 9 ingredients in any arrangement, each an item key or "#tag".

contentApi.smelting(id: string, def: { input: string, result: Result, time: number?, xp: number? })#

Declares a furnace recipe. input is an item key or "#tag"; time is the cook time in ticks, default 200; xp is the experience granted, default 0.