Custom content
content.luau is where you add new things to Minecraft: blocks, items, mobs, display models, font images, tags and recipes. It sits at the top of your experience, next to experience.toml, and every world shares it.
content.luau is not a game script. It runs once, when your content is built, before any game starts. It can't see players or the world. It only has the content global, Luau's standard library, and require for modules inside your experience.
Items
Coin Rush's content.luau is a single line:
--!strict
content.item("coin", { base = "minecraft:sunflower", name = "Coin", color = 0xFFD700, stack = 64 })
This adds a gold-coloured item called Coin, based on the sunflower, that stacks to 64.
Ids are named under your experience's namespace, so "coin" becomes coinrush:coin. You can write the namespace yourself, but it must be your own. See ItemDef for every option.
Using content in scripts
Game scripts can't add content, but they can use it. The @content module lists everything content.luau declares, and each block, item and block tag has an id:
local content = require("@content")
local COIN = content.items.coin.id
player.inventory:add(COIN)
Glowstone Studio builds @content from your content.luau as you edit, so a misspelt name is a type error.
Here, content is just a local variable holding the module. The content global used for declaring things only exists inside content.luau.
Vanilla blocks and items
Experiences don't include vanilla Minecraft blocks and items by default. To use them, add the minecraft pack in experience.toml:
uses = ["minecraft"]
Then get them from @pack/minecraft. Ids like minecraft:gold_block also work anywhere an id is expected.
local minecraft = require("@pack/minecraft")
local world = require("@ember/world")
world.setBlock(position, minecraft.blocks.gold_block.id)
content.luau can use minecraft: ids too, like the coin's base. You can't use content from another experience.
Blocks and mobs
Add blocks with content.block (see BlockDef) and mobs with content.mob (see MobDef).
A block's appearance comes from either a vanilla block state or a spare state from a Pool. Give it state properties with content.flag() (on or off), content.range(min, max) (a number) or content.oneOf(...) (one of a list).
content.itemTag("pickaxes", { "minecraft:iron_pickaxe", "minecraft:diamond_pickaxe" })
content.block("ruby_ore", {
visual = "pool:note_block",
properties = { lit = content.flag() },
hardness = 3,
tool = "pickaxes",
item = true,
drops = "self",
})
Vanilla tags like minecraft:pickaxes aren't available, so tool has to name a tag you've declared yourself. That's why the example declares pickaxes first.
Models and textures
Put models and textures in assets/:
assets/models/<path>.json
assets/textures/<path>.png
assets/items/<path>.json
| Limit | Maximum |
|---|---|
| One file | 1 MiB |
| The whole folder | 16 MiB and 4096 files |
| A texture | 1024 pixels on each side |
Glowstone Studio shows a 3D preview of models, item definitions and Blockbench .bbmodel files next to the editor.
Recipes and tags
content.itemTag("gems", { "ruby", "minecraft:emerald" })
content.shaped("ruby_block", {
pattern = { "rrr", "rrr", "rrr" },
key = { r = "ruby" },
result = "ruby_block",
})
To use a tag as an ingredient, put # in front of its name: "#gems".
Errors
Mistakes in your content are caught when it's built, not during a game. The error tells you the file and line of the call that caused it. That includes:
- tables with the wrong shape, unknown fields or duplicate ids
- missing assets
- references to things that don't exist
- going over a limit
content.luau can make up to 2048 declarations, 256 pool states and 512 models, and must finish within 5 seconds and 32 MiB of memory. The content reference has the full details.