Files
MinecraftForge/src/main/java/net/minecraftforge/registries/ObjectHolder.java
T

51 lines
1.9 KiB
Java
Raw Normal View History

2018-09-06 04:39:01 -07:00
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
2018-09-06 04:39:01 -07:00
*/
2018-09-21 02:17:20 -07:00
2018-09-06 04:39:01 -07:00
package net.minecraftforge.registries;
2022-06-07 15:31:26 -05:00
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.common.Mod;
2018-09-06 04:39:01 -07:00
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* ObjectHolder can be used to automatically populate public static final fields with entries
* from the registry. These values can then be referred within mod code directly.
* @deprecated Use {@link DeferredRegister} or {@link RegistryObject} instead. Refer to the MDK for more detailed examples.
* <br>
* Example usage of alternatives:
* <pre>{@code
* // To register something
* public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
* public static final RegistryObject<Item> EXAMPLE_ITEM = ITEMS.register("example_item", () -> new Item(new Item.Properties()));
*
* // To get a RegistryObject that you didn't register yourself:
* public static final RegistryObject<Block> DIRT = RegistryObject.create(ResourceLocation.withDefaultNamespace("dirt"), ForgeRegistries.BLOCKS);
* }</pre>
2018-09-06 04:39:01 -07:00
*/
@Deprecated(since = "1.21.4", forRemoval = true)
2018-09-06 04:39:01 -07:00
@Retention(RetentionPolicy.RUNTIME)
2022-06-07 15:31:26 -05:00
@Target(ElementType.FIELD)
2018-09-06 04:39:01 -07:00
public @interface ObjectHolder
{
/**
2022-06-07 15:31:26 -05:00
* The name of the registry to load registry entries from.
* This string is parsed as a {@link ResourceLocation} and can contain a namespace.
*
* @return the registry name
*/
String registryName();
/**
* Represents a name in the form of a {@link ResourceLocation} which points to a registry object from the registry given by {@link #registryName()}.
* Must specify the modid if not inside a class annotated with {@link Mod}.
2018-09-06 04:39:01 -07:00
*
2022-06-07 15:31:26 -05:00
* @return a name in the form of a {@link ResourceLocation}
2018-09-06 04:39:01 -07:00
*/
String value();
}