Repository navigation
API Materials
Lua API / Materials
Block materials are named constants. This page covers custom tool and armor materials.
On this page
Registers a reusable tool material and returns an opaque material handle accepted by tool declarations.
local alloy = betamoon.materials.tools:add {
key = "mymod:tool_material/alloy", harvestLevel = 2,
durability = 600, efficiency = 6, damage = 2
}| Field | Type | Requirement |
|---|---|---|
key |
string | Required material name. |
harvestLevel |
integer | Required harvest level. |
durability |
integer | Required maximum uses. |
efficiency |
number | Required mining efficiency. |
damage |
integer | Required attack-damage contribution. |
Registers a reusable armor material and returns an opaque material handle accepted by armor declarations.
local alloy = betamoon.materials.armor:add { key = "mymod:armor_material/alloy_armor", protection = 2 }| Field | Type | Requirement |
|---|---|---|
key |
string | Required material name. |
protection |
integer | Required nonnegative armor material value. |
Returns a material previously declared in this script environment, using case-insensitive, trimmed lookup. If not declared locally, returns the supplied key string so a native material name can be passed onward.
local iron = betamoon.materials.tools:get("iron")An unknown string is not validated by this lookup; a consuming tool declaration can reject it.
Returns the locally declared material handle or raises a Lua error if missing. It does not resolve undeclared native material names.
local alloy = betamoon.materials.tools:getRequired("ALLOY")Same local lookup/fallback-string behavior as tool material get, for armor materials.
local iron = betamoon.materials.armor:get("iron")Returns a locally declared armor material handle; missing declarations raise a Lua error.
local alloy = betamoon.materials.armor:getRequired("ALLOY_ARMOR")Native material identities are retained across reload. Redeclaring an existing material with different defining properties requires restart. Export/import handles when another script needs a custom material.
- Installation
- Install scripts
- Getting started
- VS Code and LuaLS
- Examples
- Reload and compatibility
- Troubleshooting
- Changelog
Scripts and shared values
- Script lifecycle
- Packaged Lua mods
- Modules
- References and stacks
- Queries
- Overrides
- Minecraft constants
- Chat and positions
- Structured data
- Script configuration
- Particles
Blocks and items
- Multiblocks
- Blocks
- Block state and placement
- Block shapes and rendering
- Block callbacks
- Block ticks and redstone
- Items
- Fluids
- Item callbacks
- Tools and armor
- Materials
- Textures
Entities
- Entities
- Entity access and movement
- Entity lifecycle and data
- Entity health and loot
- Entity inventories and relationships
- Projectiles and pickups
- Entity presentation and sounds
- Living entities and AI
- Entity parts and sensors
Assets and audio
- Assets
- Models and animations
- Built-in Minecraft models
- Model appearances
- Blockbench workflow
- Audio
- Texture-pack overrides
Events and world actions
World generation
World systems
Inventories and screens
Recipes