Something went wrong. Try again.
Library for my mods and adding supporter perks
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172/* * 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. * * <p>Provides methods to create standard or child registries, making it easier to group registry * entries and integrate with Minecraft's built-in registries. * * <h2>Implementation note</h2> * * <p>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 <strong>child registry</strong> of the given parent {@link GuitaRegistry}. * * <p>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 <T> The type of entries stored in the registry. * @return A new {@link GuitaRegistry} instance representing the child registry. */ public static <T> GuitaRegistry<T> create(GuitaRegistry<T> parent) { return new GuitaRegistryChild<>(parent); }
/** * Creates a new {@link GuitaRegistry} for a given Minecraft {@link Registry}. * * <p>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 <T> The type of entries stored in the registry. * @return A new {@link GuitaRegistry} instance. */ public static <T> GuitaRegistry<T> create(Registry<T> registry, String id) { return CommonAbstraction.get().createGuitaRegistry(registry, id); }}