Registration and ids
These types register a mod’s blocks, items, entities, and other entries the same way on every
loader, and name entries in ways that survive Minecraft renames. Start with one Registrar
per mod; use Ids and RegistryLookups for entries other mods register.
At a glance
Section titled “At a glance”| Type | Summary | Status | Since | Side | Thread |
|---|---|---|---|---|---|
BoatKind |
A boat or a chest boat. | Experimental | 2.1.0 | both | any |
BoatSet |
A mod’s boats and chest boats: one entity type each, shared by all of the mod’s woods. | Experimental | 2.1.0 | both | setup |
BoatWood |
One wood of a BoatSet: its boat and chest boat items, textures, and planks. |
Experimental | 2.1.0 | both | any |
CreativeTabIcons |
Creative tab icons from textures. | Experimental | 2.2.0 | client | setup |
Ids |
Namespaced IDs (namespace:path). |
Experimental | 2.0.0 | both | any |
Registered |
A handle to a registered entry: its ID at once, its value once the loader has registered it. | Experimental | 2.1.0 | both | any |
Registrar |
Registers one mod’s entries in vanilla’s registries. | Experimental | 2.1.0 | both | setup |
RegistryLookups |
Registry lookups by ID. | Experimental | 2.0.0 | both | any |
Stope |
Constants that identify Stope. | Stable | 1.0.0 | both | any |
VanillaBlocks |
Vanilla blocks under names that stay the same across Minecraft versions. | Experimental | 1.0.0 | both | any |
Quick start
Section titled “Quick start”In a class your mod’s initializer loads, so the fields run during initialization:
static final Registrar REGISTRAR = Registrar.of("mymod");static final Registered<Block> MAPLE_PLANKS = REGISTRAR.block("maple_planks", () -> new Block(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)));static final Registered<BlockItem> MAPLE_PLANKS_ITEM = REGISTRAR.item("maple_planks", () -> new BlockItem(MAPLE_PLANKS.get(), new Item.Properties()));Registrar
Section titled “Registrar”Experimental · Since 2.1.0 · Side: both · Thread: setup
Registrar registers a mod’s blocks, items, entity types, wood types, and other entries the
same way on Fabric and Forge; create one per mod. A wood’s signs, hanging signs, and fence gate
take its wood type, which takes its block set type. With REGISTRAR from the
quick start:
static final BlockSetType MAPLE_SET = REGISTRAR.blockSetType("maple");static final WoodType MAPLE_WOOD = REGISTRAR.woodType("maple", MAPLE_SET);static final Registered<FenceGateBlock> MAPLE_FENCE_GATE = REGISTRAR.block("maple_fence_gate", () -> new FenceGateBlock(BlockBehaviour.Properties.copy(Blocks.OAK_FENCE_GATE), MAPLE_WOOD));- Stope adds each wood type’s sign materials during client setup, so a mod registers no sign rendering of its own.
CreativeTabIcons
Section titled “CreativeTabIcons”Experimental · Since 2.2.0 · Side: client · Thread: setup
With MAIN_TAB, the tab’s handle from Registrar#creativeTab:
// Client initialization:CreativeTabIcons.texture(MAIN_TAB, id("icon.png"));- Vanilla still draws the icon item’s count and durability bar over the texture, so give the tab an icon item with neither: a single, undamaged stack.
Edge cases
Section titled “Edge cases”- A
Registeredhandle whose tab is not registered throwsIllegalStateExceptionthe first time the creative inventory draws a tab. - A supplier that gives null throws
NullPointerExceptionat that first draw, naming its texture. - Tabs are read on that first draw because they do not exist yet during client initialization.
BoatSet and BoatWood
Section titled “BoatSet and BoatWood”BoatKind: Experimental · Since 2.1.0 · Side: both · Thread: any
BoatSet: Experimental · Since 2.1.0 · Side: both · Thread: setup
BoatWood: Experimental · Since 2.1.0 · Side: both · Thread: any
Registrar#boats registers the mod’s boat and chest boat entity types once, and each
BoatSet#wood adds a wood with its two items. With REGISTRAR and MAPLE_PLANKS from the
quick start:
static final BoatSet BOATS = REGISTRAR.boats();static final BoatWood MAPLE_BOATS = BOATS.wood("maple", MAPLE_PLANKS);- A wood’s boat items stack to 1, as vanilla boats do.
- A boat saves its wood under the NBT key
stopeWood. - Pick block on a boat gives its own item.
- Stope registers the renderers and the model layers
<modId>:boat#mainand<modId>:chest_boat#main(vanilla’s boat and chest boat models) on every loader. - The mod supplies the names (
entity.<modId>.boat,entity.<modId>.chest_boat, and the item keys in its lang file), the recipes, and theminecraft:boatsandminecraft:chest_boatsitem tags.
See also
Section titled “See also”- Block behavior and rendering: what to call after registering blocks and items.
- Worldgen and loot.
- Add a wood type with boats: a guide that builds a wood step by step.