-
-
Notifications
You must be signed in to change notification settings - Fork 74
Pre 1.16 How to Use: Developers
Registering new curio types will always happen through InterModComms (IMC). Use the InterModComms#sendTo(String, String, Supplier)
method to send the necessary information. Send the message during the InterModEnqueueEvent
phase.
The first String parameter is the modid for Curios ("curios").
The second String parameter is a valid method type for IMC processing. The valid types can be found in CuriosAPI.IMC
. Currently there are only two, REGISTER_TYPE
for type registrations and MODIFY_TYPE
for modifications of types. (Note: There is also REGISTER_ICON
for icon registrations, but that is discussed later.)
The third parameter is a supplier of the format () -> new CurioIMCMessage(String)
, with the inner String parameter being a unique identifier for the curio type. Note that duplicate identifiers across multiple mods will be merged together. It is recommended to use identifiers that are as common and generic as possible for your particular use-case to avoid redundancies.
The CurioIMCMessage
object has several methods for controlling the attributes of the curio type to be registered:
-
setSize(int)
: The default number of slots for this curio type. Note that the size can only be added, not subtracted. So if multiple mods try to register different amounts for the same curio type, the higher one will always be accepted. In addition, this is only used to determine the default amount. Each individual player has a separate slot count that can be manipulated. -
setEnabled(boolean)
: Determines if the curio type is enabled by default. Disabling this will still trigger registration, but players will not be given any slots related to this type at the beginning. This does not guarantee that the player cannot enable slots for this type later on. -
setHidden(boolean)
: Determines if the slots for this curio type will show up in the default Curios GUI.
Before you decide on a slot identifier, please first take a look at the Frequently Used Slots page for a list of suggested identifiers to use instead. This will make integrating with other mods that use the same basic slot types much smoother. If you're a developer and your mod implements one of these slot types and it's not on the list, or you would like to suggest a new frequently used slot type, please send me a message.
The default Curio GUI has hovered tooltips that identify the slots using lang file entries. The key format is curios.identifier.<name>
. If you want your curio slot to use the default GUI and you are not using one of the common curio identifiers included in Curios, you will want to make sure that you have the appropriate language key entry in your lang files in order to format the tooltip correctly.
By default, all curio types except for certain commonly used ones (see here) will have generic slot icons. In order to register a unique slot icon, send an IMC message as explained above with the Curios type registrations. The difference is that instead of sending a CurioIMCMessage instance, you will send something like () -> new Tuple<>(String, ResourceLocation)
The first parameter is the unique identifier of the curio type and the second parameter is the resource location for the slot icon. If multiple mods try to register an icon for the same identifier, only one will be chosen (preventing redundancies).
Curio item classification relies on the vanilla tag system. Read more about tags here. You just need to add an appropriate json file to your resources folder. Make sure you are using item tags, and not block tags or any others.
In addition, make sure you use the curios
namespace. So your file's path will look like data/curios/tags/items
. If you use your own mod's namespace, the tag will not be recognized by the curio registry. The tag itself must be the same as the identifier of the curio type you want to classify it to. For instance, ring.json
if the identifier is ring.
In CuriosAPI.class
, you'll find several helper methods to manipulate player curio slots in a variety of ways. This includes enabling/disabling types and adding/removing slots for particular types.
For additional functionality for curio items, there's the ICurio
interface available in the API. Simply implement this interface as a capability on your item(s).