Basic Functionality - Swackyy/Ohmega GitHub Wiki
Using the API
Most of what you need can be achieved through the use of the api
package in the mod, however you may need to access other directories at times.
Accessory Functionality
Simple, working accessories can be created through the use of overriding various methods from the IAccessory
interface.
Here is a link to the 1.21 IAccessory
interface source code, containing useful JavaDocs
Method List
Here are those methods, with descriptions:
tick(Player, ItemStack)
-> Called every tick when the accessory is equippedonEquip(Player, ItemStack)
-> Called upon equipping the accessoryonUnequip(Player, ItemStack)
-> Called upon unequipping the accessorycanEquip(Player, ItemStack)
-> Called when equipping the accessory, if false, the accessory will not be equippedcanUnequip(Player, ItemStack)
-> Called when unequipping the accessory, if false, the accessory will not be unequippedcheckCompatibility(IAccessory)
-> denotes if an accessory (this) is compatible with another (parameter), if false, the accessory will not be equippedonUse(Player, ItemStack)
-> Called when a key-bind is pressed corresponding to the slot that the accessory is in, only works withUtility
andSpecial
type itemsautoSync(Player)
-> If true, the client will be synced with the server every tickaddDefaultAttributeModifiers(ModifierBuilder)
-> More complicated, see this section for more informationgetEquipSound()
(1.19.4+) -> Serves as a replacement to the pre 1.19.3 vanillagetEquipSound()
, plays a sound when equipped via right clicking it as a held item
Each of these can be overridden produce a variety of useful accessories
AccessoryHelper
utility class
Here is a link to the 1.21 AccessoryHelper
source code, containing useful JavaDocs
This utility class can be used to achieve more complicated functionality in an easy way.
Additional built-in functionality such as an "active state" can also be achieved using this, however it is instead covered here, as an advanced topic