Skip to content

Registries API#77

Open
SpaceWalkerRS wants to merge 8 commits into
gen2from
registry-sync
Open

Registries API#77
SpaceWalkerRS wants to merge 8 commits into
gen2from
registry-sync

Conversation

@SpaceWalkerRS

@SpaceWalkerRS SpaceWalkerRS commented Jul 14, 2026

Copy link
Copy Markdown
Member

Minecraft did'nt have registries until 1.4, and the implementation changed a few times. This API provides an alternative with a more modern feature set that's available for all Minecraft versions.

Events

The BOOTSTRAP_REGISTRIES event is fired on game start-up, during bootstrapping. All registries should be loaded before this or in a listener to this event. Bootstrapping registries may happen before this, but will be forced right after this event anyway.

API Overview

public final class ExampleRegistries {

	public static final ResourceKey<Registry<CookieIngredient>> COOKIE_INGREDIENT_REGISTRY = RegistryKeys.from(NamespacedIdentifiers.from("example", "cookie_ingredient"));
	public static final ResourceKey<Registry<CookieRecipe>> COOKIE_RECIPE_REGISTRY = RegistryKeys.from(NamespacedIdentifiers.from("example", "cookie_recipe"));

	public static final Registry<CookieRecipe> COOKIE_INGREDIENT = Registries.registerSimple(COOKIE_INGREDIENT_RECIPES, CookieIngredients::init);
	public static final Registry<CookieRecipe> COOKIE_RECIPE = Registries.registerDefaulted(COOKIE_RECIPE_RECIPES, NamespacedIdentifiers.from("example", "chocolate_chip"), CookieRecipes::init);

	public static void init() {
		SyncedRegistries.register(COOKIE_INGREDIENT_REGISTRY);
		SyncedRegistries.register(COOKIE_RECIPE_REGISTRY);
	}
}
public final class CookieIngredients {

	public static final CookieIngredient EGGS = Registry.register(ExampleRegistries.COOKIE_INGREDIENT, NamespacedIdentifiers.from("example", "eggs"), new EggsIngredient());
	public static final CookieIngredient SUGAR = Registry.register(ExampleRegistries.COOKIE_INGREDIENT, NamespacedIdentifiers.from("example", "sugar"), new SugarIngredient());

	public static void init() {
	}
}
public final class CookieRecipes {

	public static final CookieRecipe CHOCOLATE_CHIP = Registry.register(ExampleRegistries.COOKIE_RECIPE, NamespacedIdentifiers.from("example", "chocolate_chip"), new ChocolateChipCookieRecipe());

	public static void init() {
	}
}

@SpaceWalkerRS SpaceWalkerRS added the enhancement New feature or request label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant