/* * 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 java.util.Collection; import java.util.function.Supplier; import java.util.stream.Stream; /** * Represents a generic registry for storing and managing objects of type {@code T}. * *
Registries can hold entries that are lazily initialized via {@link Supplier} and can be
* iterated over or streamed. This interface is designed to be used by mod frameworks and libraries
* to organize game objects, items, or other data types.
*
* @param This is typically used to identify the mod or library that owns the registry.
*
* @return The registry namespace.
*/
String namespace();
/**
* Registers a new entry in this registry.
*
* The entry is associated with the given {@code id} and lazily supplied via the provided
* {@link Supplier}.
*
* @param id The name for this entry (e.g., {@code "item_name"}).
* @param supplier A {@link Supplier} that provides the object when needed.
* @param The type of the entry, which must extend {@code T}.
* @return A {@link GuitaRegistryEntry} representing the newly registered entry.
*/
GuitaRegistryEntry register(String id, Supplier supplier);
/**
* Registers a new entry in this registry, returning a {@link GuitaHolderRegistryEntry}.
*
* The entry is associated with the given {@code id} and lazily supplied via the provided
* {@link Supplier}.
*
* @param id The name for this entry (e.g., {@code "item_name"}).
* @param supplier A {@link Supplier} that provides the object when needed.
* @return A {@link GuitaHolderRegistryEntry} representing the newly registered entry.
*/
GuitaHolderRegistryEntry This is a convenient method for functional operations on registry entries.
*
* @return A {@link Stream} of {@link GuitaRegistryEntry} objects.
*/
default Stream This is equivalent to mapping {@link GuitaRegistryEntry#get()} over the registry entries.
*
* @return A {@link Stream} of objects of type {@code T}.
*/
default Stream This method should be called after all entries are registered, and will register these items
* into Minecraft.
*/
void init();
}