Download Equipment API — Minecraft Mods — MetaMods

Equipment API

Active

Downloads

0

Last update

9 years ago
Client
Utils

Equipment API

A powerful API that enables mod developers to create custom equipment slots for their modifications. Building upon the baubles concept, this system allows registration of dedicated slots tailored for specific item types.

To access the equipment interface, press the R key or click the pickaxe icon in the corner of the player inventory screen.

Accessing Equipment Interface

The equipment screen displays all registered slots. Navigation arrows appear when more than 8 slots exist, allowing you to switch between pages.

First Slot Page

Second Slot Page

Note: All displayed slots are for demonstration purposes only and are not included in the base modification.

API Usage Guide

The API is straightforward to implement, primarily focusing on registering EquipmentType instances that handle slot compatibility, visual appearance, and change callbacks.

EquipmentApi.registerEquipment(YOUR_EQUIPMENT_ID, new EquipmentType() {

    ResourceLocation overlay = new ResourceLocation(YOURMODID, "textures/YOUR_SLOT_OVERLAY.png");

    @Override
    / Texture to overlay on the slot (displays beneath the item) /
    public ResourceLocation getSlotOverlay(ItemStack stack) {
        return overlay;
        // alternatively use return stack == null ? null : overlay;
        // this makes the background image disappear when an item occupies the slot
    }

    @Override
    / Whether player can remove specified stack from slot /
    public boolean canRemoveStack(ItemStack stack, EntityPlayer player) {
        return true;
    }

    @Override
    / Whether player can place specified stack in slot /
    public boolean canPlaceStack(ItemStack stack) {
        return stack != null && stack.getItem() != null && stack.getItem() == Items.arrow;
    }

    @Override
    / Maximum stack size for this slot /
    public int getStackLimit() {
        return 64;
    }

    @Override
    / Hover text description, supports line breaks /
    public String getSlotDescription(EntityPlayer player) {
        return "Arrows";
    }

    @Override
    / Called whenever slot content changes /
    public void onChange(ItemStack from, ItemStack to, EntityPlayer player) {

    }
});
Project members
thecodewarrior1

thecodewarrior1

Created: 26 Nov 2015

ID: 80294