/* * Copyright 2026 macuguita * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * * https://joinup.ec.europa.eu/software/page/eupl * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. */ package com.macuguita.lib.api.reg; import net.minecraft.core.Registry; import com.macuguita.lib.impl.platform.CommonAbstraction; import com.macuguita.lib.impl.reg.GuitaRegistryChild; /** * Utility class for creating and managing {@link GuitaRegistry} instances. * *

Provides methods to create standard or child registries, making it easier to group registry * entries and integrate with Minecraft's built-in registries. * *

Implementation note

* *

Registration is wrapped behind {@link CommonAbstraction} so each platform can handle the * details internally while exposing a single consistent API. On NeoForge this defers to a * {@code DeferredRegister} attached to macu Lib's own mod event bus, which is resolved independently * of the active mod container. This allows registries to be created from a mod initializer provided * by Yumi on NeoForge (including Fabric mods loaded through Sinytra Connector), just like on Fabric. */ public final class GuitaRegistries { private GuitaRegistries() {} /** * Creates a child registry of the given parent {@link GuitaRegistry}. * *

Entries added to this child registry are automatically added to the parent, which is useful * for logically grouping registry entries without duplicating code. * * @param parent The parent {@link GuitaRegistry} to which this child will belong. * @param The type of entries stored in the registry. * @return A new {@link GuitaRegistry} instance representing the child registry. */ public static GuitaRegistry create(GuitaRegistry parent) { return new GuitaRegistryChild<>(parent); } /** * Creates a new {@link GuitaRegistry} for a given Minecraft {@link Registry}. * *

This allows mod-specific registries to be created that integrate with Minecraft's built-in * registries while keeping entries namespaced to the mod. * * @param registry The Minecraft {@link Registry} to wrap, e.g., from {@link * net.minecraft.core.registries.BuiltInRegistries}. * @param id The namespace of the mod creating this registry. * @param The type of entries stored in the registry. * @return A new {@link GuitaRegistry} instance. */ public static GuitaRegistry create(Registry registry, String id) { return CommonAbstraction.get().createGuitaRegistry(registry, id); } }