-
-
Notifications
You must be signed in to change notification settings - Fork 74
How to Use: Fabric Developers
Add the following to your build.gradle file:
repositories {
maven {
url = "https://maven.theillusivec4.top/"
}
}
dependencies {
modImplementation "top.theillusivec4.curios:curios-fabric:${version}"
modCompile "top.theillusivec4.curios:curios-fabric:${version}:api"
}
Replace ${version} with the version of Curios that you want to use.
Use the CuriosApi#enqueueSlotType(BuildScheme, SlotTypeInfo)
method to send the necessary information. Call the method in your mod's common onInitialize
method.
The first BuildScheme parameter has two types: REGISTER
and MODIFY
. REGISTER
will create a new slot type if it does not find one already. MODIFY
will only use the information you send to modify existing slot types and will never create a new one by itself.
The second parameter is a SlotTypeInfo object of the format new SlotTypeInfo.Builder(String).build()
, 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 SlotTypeInfo.Builder
object has several methods for controlling the attributes of the slot type to be registered:
-
icon(Identifier)
: Points the slot icon to be used to a particular resource location. -
priority(int)
: Determines the order, if applicable, for comparing slot types. Higher priorities are considered greater. -
size(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. -
lock()
: Locks the slot type so that players will not be given any slots related to this type by default. This does not guarantee that the player cannot unlock slots for this type later on. -
hide()
: Hides the slot type, used by the default Curios GUI to determine if it should show a particular slot type. -
cosmetic()
: Enables cosmetic slots next to the equipment slots.
Before you decide on a slot identifier, please first take a look at the Common Slot Types page for a list of suggested identifiers to use instead. In addition, before hardcoding your own unique identifier, please take a look at SlotTypePreset
to see if you can utilize one of the suggested presets. 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.
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.
Curios uses Cardinal Components API as an embedded library for attaching components to curio items using ICurio
and IRenderableCurio
(client-side only). This allows for additional functionality for items in curio slots, such as ticking behavior and attribute modifiers. Please go to the Cardinal Components API wiki for more information about components.
A simple example of registering a component to your item:
ItemComponentCallbackV2.event(/*your item*/).register(
((item, itemStack, componentContainer) -> componentContainer
.put(CuriosComponent.ITEM, new ICurio() {
//// Your implementation
})));
IRenderableCurio
is the component that needs to be attached to enable rendering for curios. Since this interface may access client-only classes and methods, make sure that you only attempt to initialize this on the client.
In CuriosApi#getSlotHelper
, 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. Please note that slot types are server-side only. This means that an instance of ISlotHelper
can only exist on a server and will return null if attempting to access on the client. The client does not have any knowledge of slot types, only its identifiers and associated stack holders.