批注接口 ObjectHolder


@Deprecated(since="1.21.4", forRemoval=true) @Retention(RUNTIME) @Target(FIELD) public @interface ObjectHolder
已过时, 待删除: 此 API 元素将从以后的版本中删除。
Use DeferredRegister or RegistryObject instead. Refer to the MDK for more detailed examples.
Example usage of alternatives:

 // 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);
 
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.
  • 必需元素概要

    所需元素
    修饰符和类型
    必需的元素
    说明
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    The name of the registry to load registry entries from.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Represents a name in the form of a ResourceLocation which points to a registry object from the registry given by registryName().
  • 元素详细资料

    • registryName

      String registryName
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      The name of the registry to load registry entries from. This string is parsed as a ResourceLocation and can contain a namespace.
      返回:
      the registry name
    • value

      String value
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Represents a name in the form of a ResourceLocation which points to a registry object from the registry given by registryName(). Must specify the modid if not inside a class annotated with Mod.
      返回:
      a name in the form of a ResourceLocation