-
Notifications
You must be signed in to change notification settings - Fork 74
Slot Modifiers
C4 edited this page Nov 30, 2021
·
3 revisions
This is a feature only in Curios 4.0.6.0+.
Slot modifiers are a way to dynamically add/remove slots from entities the same way modders could add/remove health or attack damage. In fact, it uses the exact same AttributeModifier
system to accomplish this.
The main method modders should use is ICuriosHelper#addSlotModifier(Multimap, String, UUID, double, AttributeModifier.Operation)
.
Parameters:
-
Multimap
- This is a multimap that normally contains theMultimap<Attribute, AttributeModifier
attribute map used for entities. Curios will add the slot modifiers to this map, wrapping the modifier in the appropriate logic to translate it into slots. -
String
- The identifier of the slot to add the modifier onto. -
UUID
- The UUID to use for the modifier. -
double
- The amount of the modifier. -
AttributeModifier.Operation
- The type of operation of the modifier. All operations are supported.
A very typical example of how a modder could override their ICurio#getAttributeModifiers(SlotContext, UUID)
implementation to incorporate a slot modifier that adds 6 ring slots when equipped in addition to its normal attribute modifier for movement speed.
@Override
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(SlotContext slotContext, UUID uuid) {
Multimap<Attribute, AttributeModifier> atts = LinkedHashMultimap.create();
atts.put(Attributes.MOVEMENT_SPEED, new AttributeModifier(uuid, "speed_bonus", 0.1, AttributeModifier.Operation.MULTIPLY_TOTAL));
CuriosApi.getCuriosHelper().addSlotModifier(atts, "ring", uuid, 6.0, AttributeModifier.Operation.ADDITION);
return atts;
}