Download Accessory API — Minecraft Mods — MetaMods
Accessory API

Accessory API

Active

Downloads

10

Last update

9 months ago

Versions

b1.7.3
Client and server
Fabric
Game mechanics

Accessory API

Note:

The modification Aether for Station API uses this mod!

This mod for Minecraft version b1.7.3, running on the Babric platform, provides developers with tools to create additional slots for various items. The functionality resembles Trinkets API and Baubles API, while the visual design is inspired by the style of Aether from the same game version.

Inventory Preview

For Developers

If you want to master mod creation for b1.7.3 in the Babric environment, join the developer community! This toolkit is very similar to Fabric and Fabric API, but specifically adapted for b1.7.3.

Workspace Setup

Add Accessory API to your build.gradle file:

repositories {
    maven {
        name = "Jitpack"
        url "https://jitpack.io/"
    }
}

dependencies {
    modImplementation('com.github.matthewperiut:accessory-api:0.5.1') {
        transitive false
    }
}

Learning Recommendations

For quick familiarization with API usage, it's recommended to clone the repository (preferably in an IDE) and study the code in the src/test/java/com/matthewperiut/testmod folder. It's also useful to review the API documentation and javadocs.

Practical Implementation

Implement the "Accessory" interface in your item class (compatible with STAPI and other APIs/mixins):

public class ExampleRing extends TemplateItemBase implements Accessory
{
    public Pendant(Identifier identifier)
    {
        super(identifier);
    }

    // To define slot types where the item can be placed:
    @Override
    public String[] getAccessoryTypes(ItemInstance item)
    {
        return new String[]{ "ring" };
        // return new String[0]; // returns no slots
        // return new String[]{ "ring", "cape" }; // can be placed in multiple slot types
        // return new String[]{ "all" }; // can be placed in any accessory slot
    }

    // other methods that can be used with @Override
    // void tickWhileWorn(PlayerBase player, ItemInstance accessory)
    // void onAccessoryAdded(PlayerBase player, ItemInstance accessory)
    // void onAccessoryRemoved(PlayerBase player, ItemInstance accessory)

    // Rendering
    private YourCustomRenderer renderer;
    @Override
    public Optional<AccessoryRenderer> getRenderer()
    {
        return Optional.ofNullable(renderer);
    }
}

Available standard accessory types:
"pendant"
"cape"
"shield"
"ring"
"gloves"
"misc"
"all"
or you can create your own custom accessory type

Accessory Functions: Detailed Description

This method is called when clicking on an accessory slot with an item, the item is passed to the function.
It provides slot information to check compatibility.
String[] getAccessoryTypes(ItemInstance item)

Called in the update function of the associated player, passing the item being updated and the player.
void tickWhileWorn(PlayerBase player, ItemInstance item)

Called when an item is added/removed from the inventory related to the accessory.
The function provides information about which player added/removed the accessory, as well as the item itself.
void onAccessoryAdded(PlayerBase player, ItemInstance accessory)
void onAccessoryRemoved(PlayerBase player, ItemInstance accessory)

Providing rendering functions through getRenderer:
public AccessoryRenderer getRenderer()

Creating Accessory Renderer

Example:

public class CustomRenderer implements AccessoryRenderer {
    void renderThirdPerson(PlayerBase player, PlayerRenderer renderer, ItemInstance itemInstance, double x, double y, double z, float h, float v)
    {
        // entity rendering magic
    }

   void renderFirstPerson(PlayerBase player, PlayerRenderer renderer, ItemInstance itemInstance)
   {
       // first-person rendering magic
   }
}

Usage similar to EntityRenderers

Built-in AccessoryRenderers:
CapeRenderer
GloveRenderer
NecklaceRenderer
ConfigurableRenderer

Project members
Slainlight

Slainlight

Developer

KydZombie

KydZombie

Developer

Created: 18 Oct 2023

ID: 13311