/* * 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.attachment; import java.util.function.Consumer; import java.util.function.Supplier; import net.minecraft.resources.Identifier; import com.mojang.serialization.Codec; import com.macuguita.lib.impl.platform.CommonAbstraction; /** * Class used to create and register {@link GuitaAttachmentType}s, mirroring Fabric's data * attachment API. * *
To quickly create attachment types, use one of the various {@code createXXX} methods: * *
On Fabric this delegates to Fabric API's {@code AttachmentRegistry}, which auto-registers the
* type. On NeoForge attachment types must be registered to a registry, so this uses a
* {@code DeferredRegister} attached to macu Lib's own mod event bus. Because the bus is resolved
* independently of the active mod container, attachment types may be created from a {@code yumi:init}
* initializer on NeoForge (including Fabric mods loaded through Sinytra Connector), just like on
* Fabric.
*
* @see GuitaAttachmentType
* @see GuitaAttachmentTarget
*/
public final class GuitaAttachmentRegistry {
private GuitaAttachmentRegistry() {}
/**
* Creates and registers an attachment using a {@linkplain GuitaAttachmentBuilder builder}.
*
* @param id the identifier of this attachment
* @param consumer a lambda that configures a {@link GuitaAttachmentBuilder} for this attachment
* type
* @param the type of attached data
* @return the registered {@link GuitaAttachmentType} instance
*/
public static GuitaAttachmentType create(Identifier id, Consumer