JeiCategory
Link to jeicategory
Identifies a custom recipe category shown in JEI when querying a specific ingredient.
A JEI category is identified by four major components: an id, a name, an icon, and a series of catalysts.
The ID is a unique name that is used by JEI to identify the category, in the form of a ResourceLocation. With JeiTweaker, you have control only on the path
portion of the location, whereas the ID is fixed to the one that represents the JeiTweaker mod.
The name is a Component which identifies the category. It can be considered the human-friendly version of the category ID. More than one category can have the same name, although this is discouraged as a matter of clarity towards the player.
The icon is a JeiDrawable that is used as a graphic counterpart to the name, following the same rules. The icon is rendered on the top section of the JEI user interface. An example icon could be the crafting table for the minecraft:crafting
category, or the furnace for the minecraft:furnace
category.
Last but not least, the catalysts are a series of JeiIngredients that indicate where the recipe can be crafted. They appear on the left side of the JEI user interface, in a recessed rectangle. An example set of catalysts for the minecraft:crafting
category could be all crafting tables, modded or otherwise. The set of catalysts might or might not contain the icon.
Moreover, each JeiTweaker category additionally specifies a background, which is used to provide a default background for recipes.For mod developers looking to create additional categories: each category is automatically discovered and registered by JeiTweaker as long as it extends JeiCategory
and is annotated with both invalid and invalid. To be correctly registered, the class must not be abstract
(preferably, it should be final
) and it must have a constructor with the following signature: public ClassName(ResourceLocation, MCTextComponent, JeiDrawable, RawJeiIngredient...)
. Any other class is not going to be registered. Due to these requirements, mod developers are strongly encouraged not to implement this interface directly, but rather extend SimpleJeiCategory instead.
导入类
Link to 导入类
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
ZenScript Copyimport mods.jei.category.JeiCategory;
Static Methods
Link to static-methods
Name: create
Creates a new category of the specified type, with the given parameters, configuring it to defaults.
Returns: The newly created category.
Return Type: JeiCategory
ZenScript CopyJeiCategory.create<T : JeiCategory>(id as string, name as Component, icon as JeiDrawable, catalysts as JeiIngredient[]) as JeiCategory
参数 | 类型 | 描述 |
---|---|---|
参数 id | 类型 string | 描述 The ID of the category to create. |
参数 name(名称) | 类型 Component | 描述 A Component representing the name of the category. |
参数 icon | 类型 JeiDrawable | 描述 A JeiDrawable that acts as the icon for the category. |
参数 catalysts | 类型 JeiIngredient[] | 描述 An array of JeiIngredient acting as catalysts for the category. It must not be empty. |
参数 T | 类型 JeiCategory | 描述 The type of the category to create. It must extend JeiCategory. |
Name: create
Creates a new category of the specified type, with the given parameters, and with the given function as a
configurator.
Returns: The newly created category.
Return Type: JeiCategory
ZenScript CopyJeiCategory.create<T : JeiCategory>(id as string, name as Component, icon as JeiDrawable, catalysts as JeiIngredient[], configurator as Consumer<T>) as JeiCategory
参数 | 类型 | 描述 |
---|---|---|
参数 id | 类型 string | 描述 The ID of the category to create. |
参数 name(名称) | 类型 Component | 描述 A Component representing the name of the category. |
参数 icon | 类型 JeiDrawable | 描述 A JeiDrawable that acts as the icon for the category. |
参数 catalysts | 类型 JeiIngredient[] | 描述 An array of JeiIngredient acting as catalysts for the category. It must not be empty. |
参数 configurator | 类型 Consumer<T> | 描述 A Consumer<T> allowing configuration of the category as it gets built. |
参数 T | 类型 JeiCategory | 描述 The type of the category to create. It must extend JeiCategory. |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 background | 类型 JeiDrawable | 可获得 true | 可设置 false | 描述 Gets the JeiDrawable that serves as the background for recipes of this category. |
名称 catalysts | 类型 JeiIngredient[] | 可获得 true | 可设置 false | 描述 Gets the lists of catalysts currently registered to this category. |
名称 icon | 类型 JeiDrawable | 可获得 true | 可设置 false | 描述 Gets the JeiDrawable that acts as the icon for this category. |
名称 id | 类型 资源位置 | 可获得 true | 可设置 false | 描述 Gets the ID of the category. |
名称 name(名称) | 类型 Component | 可获得 true | 可设置 false | 描述 Gets the name of the category. |