MonitoringMinecraft MonitoringMinecraft

Food API

Мод NeoForge

Гибкий API системы питания для NeoForge в Майнкрафт: настраиваемая вместимость голода, динамическая полоска еды с поддержкой нескольких рядов и заменой иконок.

158 скачиваний 2 подписчика
Оцените первым

🍖 Food API

A flexible hunger system library for NeoForge

MODRINTH GITHUB

📖 About

Food API is a developer-focused library that removes the hardcoded limitations of Minecraft's vanilla hunger system. It exposes hunger capacity and drain speed as proper entity attributes, adds multi-row food bar rendering, and provides a clean provider-based system for replacing food icons — all with optional compatibility for popular HUD mods.

✨ Features

Dynamic hunger capacity — max hunger is now an attribute, supports up to 2 rows (40 units).

Configurable drain speed — control how fast hunger depletes via a multiplier attribute.

Multi-row food bar — second row renders seamlessly above the first, fully synced with vanilla shake animation.

Icon provider system — replace any food icon (empty, half, full, hunger, overlay, saturation) per-player, per-row, per-slot with a simple registration API.

Optional mod compat — native support for Overflowing Bars and AppleSkin when present.

🖼️ Screenshots

Vanilla rendering — single row, standard icons



With Overflowing Bars — row counter, overlay icons stacked on top

📦 New Attributes

Two new player attributes are registered automatically when Food API is loaded:

Attribute ID Default Range Description
Max Hunger food_api:max_hunger 20 1 – 40 Maximum hunger capacity. 20 = one row, 40 = two rows.
Hunger Rate food_api:hunger_rate 1.0 0.0 – 10.0 Hunger drain speed multiplier. 0 = no drain, 2 = twice as fast.

Both attributes are synced to the client and can be modified via commands, other mods, or directly in code:

// Example: give a player double hunger capacity
player.getAttribute(AttributeRegistries.MAX_HUNGER)
      .setBaseValue(40);

// Example: slow hunger drain to half speed
player.getAttribute(AttributeRegistries.HUNGER_RATE)
      .setBaseValue(0.5);

🔧 API Usage

Replacing food icons

Register a provider with an ID and priority. Higher priority wins. Return null to fall through to the next provider.

FoodIconRegistry.register(
    ResourceLocation.fromNamespaceAndPath("mymod", "my_provider"),
    10, // priority — higher = checked first (vanilla = 0)
    (player, iconIndex, row, type) -> {
        // iconIndex: 0 = rightmost icon, 9 = leftmost
        // row: 0 = bottom row, 1 = top row
        return switch (type) {
            case FULL  -> ResourceLocation.fromNamespaceAndPath("mymod", "hud/my_food_full");
            case HALF  -> ResourceLocation.fromNamespaceAndPath("mymod", "hud/my_food_half");
            case EMPTY -> ResourceLocation.fromNamespaceAndPath("mymod", "hud/my_food_empty");
            default    -> null; // let other providers or vanilla handle the rest
        };
    }
);

Icon types

Type Description
EMPTY Background (empty slot)
HALF Half-filled icon
FULL Fully filled icon
EMPTY_HUNGER Background during Hunger effect
HALF_HUNGER Half icon during Hunger effect
FULL_HUNGER Full icon during Hunger effect
HALF_OVERLAY Half icon on top row (Overflowing Bars only)
FULL_OVERLAY Full icon on top row (Overflowing Bars only)
SATURATION Saturation overlay texture (AppleSkin only)

Registering at the right time

Call FoodIconRegistry.register(...) during FMLClientSetupEvent or earlier:

@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
    FoodIconRegistry.register(...);
}

🔗 Optional Dependencies

Food API works standalone. These mods unlock extra features when present:

  • Overflowing Bars — enables row counter display and overlay icon rendering on the top row
  • AppleSkin — enables saturation overlay icon replacement via FoodIconType.SATURATION

Made with 🩷 by ArimoV2

Смотри также

Похожие подборки моды — по версиям Майнкрафта, загрузчикам и жанрам.

Сервера Майнкрафт

Играть интереснее на сервере — выбирай в рейтинге серверов Майнкрафт и заходи прямо сейчас.

SkyBars
SkyBars Java + BE
1053 онлайн
1.8 — 26.2 версия
🎮 ВЫЖИВАНИЕ ⚔️ АНАРХИЯ 🚗 ГТА РП 🎤 ГОЛОСОВОЙ ЧАТ 🎁 БЕСПЛАТНЫЙ ДОНАТ 🌟 СМП 💻 ПК+ТЕЛЕФОН
MigosMc
MigosMc Java + BE
868 онлайн
1.8 — 26.2 версия
🌿 MigosMc.net | Гриферский сервер с войс-чатом | Награды за онлайн ⭐ ВЫЖИВАНИЕ⭐ ОДИНБЛОК⭐ МИНИ-ИГРЫ
CLOUDWORLD
0 онлайн
1.16.5 — 1.21.11 версия
Пвп, Арены, Дуэли, Кейсы, донаты, /free, приваты, спавн,
Battle Mine
Battle Mine Java + BE
0 онлайн
1.21.4 — 26.2 версия
ОТКРЫТИЕ! 20 + различных ивентов, 10+ различных боссов, много интересных механник
MineLauncher
Лаунчер Майнкрафт без лицензии — все версии
Бесплатный лаунчер для ПК и Андроид — все версии 26.2, 1.21.11, 26.1.2, 1.21.8. Fabric, NeoForge, Forge, шейдеры, моды и скины в один клик.
Без лицензии Fabric, NeoForge, Forge Моды, шейдеры, скины Все версии Майнкрафта ПК и Андроид Для слабых ПК Сервера в лаунчере
Скачать бесплатно
Windows и Андроид · Бесплатно · Без лицензии
Наш чат