Skip to content

Registries API - #77

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

Registries API#77
SpaceWalkerRS wants to merge 5 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
@SpaceWalkerRS
SpaceWalkerRS force-pushed the registry-sync branch 2 times, most recently from a97ef09 to 19f3365 Compare July 18, 2026 10:01
… in 0.20

They were introduced in 0.20 for the Blocks and Items API, but both of
those now make use of the new Registries API instead, so the classes
introduced in 0.20 are no longer used by OSL and should no longer be used by third party mods
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