Abdallah

Act as an expert Minecraft Mod Developer specializing in Fabric Client-Side mods. I need you to generate a fully compiled, error-free, and production-ready Client-Side ONLY mod for Minecraft version 1.21.4 using the Fabric API. The project must build flawlessly on the first try.

Mod Specifications ("VerticalMegaPocket"):

  1. Environment & Architecture:
  • Environment must be set strictly to "client".
  • The mod must be completely invisible to multiplayer servers (No custom server packets, no custom network registry). It operates entirely on the client's local memory and rendering system.
  1. Button Injection via Mixin:
  • Implement a Mixin targeting net.minecraft.client.gui.screen.ingame.InventoryScreen.
  • Injected Method: Tail inject into protected void init().
  • Logic: Instantiate a standard vanilla ButtonWidget.builder with dimensions exactly 14x14 pixels.
  • Button Content: Displays a lightweight vanilla text component containing the backpack emoji ("🎒").
  • Layout Coordinates: Position the button strictly at the bottom-right of the 2x2 Crafting Grid area. Use calculated dynamic offsets: int buttonX = this.x + 118; int buttonY = this.y + 62;.
  • Action: Clicking this button switches the client's screen to a new instance of MegaPocketScreen. This button is the only entry point; no stand-alone hotkeys should trigger this action.
  1. 9x500 Infinite Grid GUI Hierarchy:
  • Create a custom screen class MegaPocketScreen extending net.minecraft.client.gui.screen.Screen.
  • View Window: The visible portion of the screen must render a standard vanilla width of 9 columns and exactly 6 rows (54 visible slots) at any time to preserve clean scaling.
  • Total Capacity: The total indexed data registry backing this view must support up to 500 rows vertically (totaling 4,500 persistent virtual item slots).
  • Interactive Navigation: Implement a standard vertical scrollbar widget anchored on the right frame. Overwrite the mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) method. Scrolling the mouse wheel up or down shifts the scrollRow variable smoothly between 0 and 494.
  • Rendering Pipeline: All visual rendering must utilize modern 1.21.4 Yarn mapping syntax using the DrawContext object. Use context.fill for slot background drawing, context.drawItem for rendering the item graphics, and context.drawStackCount for stack quantities. Do not use legacy OpenGL render states or deprecated draw calls.
  • Search Functionality: Include a basic TextFieldWidget centered at the top of the interface. Typing dynamically matches the translation key names of the items stored in the virtual cache, hiding unmatched slots from the grid view.
  • Lifecycle: Closing this screen using the Escape key must redirect the player back to the parent InventoryScreen screen safely.
  1. Client-Side Flat-File Cache & Inventory Shifting:
  • Initialize a strict list memory registry holding 4,500 default empty item stacks (ItemStack.EMPTY).
  • Storage Persistence: Automatically read and write all 4,500 slots into a flat JSON data structure located strictly on the player's computer at config/vertical_mega_pocket.json. Saving triggers dynamically upon closing the custom screen.
  • Item Interfacing: While inside MegaPocketScreen, handle custom slot clicking. Clicking an item inside the player's standard vanilla survival inventory transfers the item stack directly into the first available slot in the mega JSON-cached grid. Conversely, clicking an active slot within the mega grid withdraws the item safely back into any open vanilla inventory slots.

Please structure and generate the complete set of required project files without truncation:

  1. Complete fabric.mod.json targeting Minecraft 1.21.4 environment constraints.
  2. Complete InventoryScreenMixin.java containing the precise button coordinates.
  3. Complete MegaPocketScreen.java with correct 1.21.4 DrawContext drawing commands and scroll logic.
  4. Main entry class VerticalMegaPocket.java managing the local file system serialization layer.
Kodari AI
KodariSep 16 at 7:52 am 2
VerticalMegaPocket
Client-side Fabric mod for Minecraft 1.21.4 that injects a backpack button into the vanilla inventory screen via Mixin. Opens a custom MegaPocketScreen with a 9x500 virtual grid (4,500 slots) rendered as a 9x6 visible window with smooth vertical scrolling and dynamic search filtering. Persists all items to a local JSON cache file at config/vertical_mega_pocket.json, automatically saving on screen close. Supports item transfer between vanilla inventory and mega grid through custom slot click handling, using modern DrawContext rendering with Yarn mappings.
  1. Set up the Fabric 1.21.4 client-only project metadata and build files.

  2. Implement the local JSON-backed 4,500-slot cache and client initialization.

  3. Add the inventory mixin button and the 9×6 virtual pocket screen with search, scrolling, and transfers.

  4. Add the required mixin/resource metadata and item-language support.

  1. Created the complete Fabric 1.21.4 client-only project configuration.

  2. Added VerticalMegaPocket with a 4,500-slot in-memory cache and JSON persistence at config/vertical_mega_pocket.json.

  3. Added InventoryScreenMixin with the exact 14×14 backpack button and required coordinates.

  4. Added MegaPocketScreen with:

    • 9×6 visible virtual grid

    • 500-row capacity

    • Search filtering

    • Scroll wheel and draggable scrollbar

    • Player inventory transfer support

    • Escape navigation back to InventoryScreen

    • DrawContext-based rendering

  5. Added Fabric mixin metadata and English localization resources.

Abdallah

كيف احمل المود

Kodari AI
KodariSep 16 at 7:54 am 1

لتحميل وتشغيل المود:

  1. نزّل ملفات المشروع كاملة بصيغة ZIP من واجهة المشروع إن كان خيار التنزيل متاحًا.

  2. تأكد من تثبيت:

    • Minecraft 1.21.4

    • Java 21

    • Fabric Loader 0.16.9 أو أحدث

    • Fabric API المتوافق مع 1.21.4

  3. داخل مجلد المشروع شغّل:

Windows:

Shell
gradlew.bat build

Linux / macOS:

Shell
./gradlew build
  1. ستجد ملف المود بعد نجاح البناء داخل:

Plain Text
build/libs/

اختر ملف .jar الأساسي، وليس الملف الذي ينتهي بـ -sources.jar.

  1. انسخ ملف الـ .jar إلى:

Plain Text
.minecraft/mods/
  1. شغّل Minecraft باستخدام ملف تعريف Fabric 1.21.4.

المود Client-Side فقط، لذلك لا تحتاج إلى تثبيته على الخادم. إذا لم يظهر لك خيار تنزيل ملفات المشروع، فلا يوجد حاليًا رابط JAR مباشر مرفق في المحادثة؛ يجب أولًا تنزيل ملفات المصدر وبناؤها بالأوامر أعلاه.

Abdallah

Please fix a syntax text omission in 'InventoryScreenMixin.java' inside the current session.

The generated code for the ButtonWidget builder currently contains an empty literal string due to a character encoding glitch. Please replace the entire content of 'src/main/java/com/kodari/verticalmegapocket/mixin/InventoryScreenMixin.java' with the following corrected and error-free code to ensure the backpack emoji ("🎒") renders perfectly on the button:

package com.kodari.verticalmegapocket.mixin;

import com.kodari.verticalmegapocket.gui.MegaPocketScreen; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.gui.widget.ButtonWidget; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InventoryScreen.class) public abstract class InventoryScreenMixin { @Shadow protected int x; @Shadow protected int y;

@Inject(method = "init", at = @At("TAIL")) private void verticalMegaPocket$addButton(CallbackInfo callbackInfo) { int buttonX = this.x + 118; int buttonY = this.y + 62;

ButtonWidget button = ButtonWidget.builder( net.minecraft.text.Text.literal("🎒"), clickedButton -> MinecraftClient.getInstance().setScreen( new MegaPocketScreen((InventoryScreen) (Object) this))) .dimensions(buttonX, buttonY, 14, 14) .build();

((InventoryScreen) (Object) this).addDrawableChild(button); } }

Apply this fix to the active session files, update the repository cache, and then compile the project to generate the finalized downloadable .jar file.

Kodari AI
KodariSep 16 at 7:57 am 1

تم استبدال محتوى الملف بالكامل بالكود المصحح، بما في ذلك:

  • النص 🎒 داخل Text.literal

  • الإحداثيات x + 118 وy + 62

  • أبعاد الزر 14x14

  • فتح MegaPocketScreen

تم تحديث ملف المستودع بنجاح. لا يوجد Gradle Wrapper أو أداة بناء متاحة داخل جلسة العمل الحالية، لذلك لم يتم إنشاء ملف .jar هنا. بعد تنزيل المشروع، شغّل:

Shell
./gradlew build

أو على Windows:

Shell
gradlew.bat build

وسيظهر الملف النهائي داخل:

Plain Text
build/libs/
Abdallah

اعضيني رابط تحميل

Kodari AI
KodariSep 16 at 7:58 am 1

لا يوجد حاليًا رابط تحميل مباشر؛ ملف .jar لم يتم رفعه إلى استضافة أو إرفاقه داخل المحادثة.

بعد تنزيل ملفات المشروع، أنشئ المود بالأمر:

Shell
./gradlew build

في Windows:

Shell
gradlew.bat build

ثم حمّل الملف من:

Plain Text
build/libs/

واختر ملف .jar الذي لا ينتهي بـ -sources.jar، ثم ضعه داخل:

Plain Text
.minecraft/mods/

إذا كانت واجهة الجلسة توفر زر Download project / تنزيل المشروع، استخدمه أولًا للحصول على ملفات المصدر.

Abdallah

انا استخدم الهاتف ليس لدي كمبيوتر

Kodari AI
KodariSep 16 at 7:59 am 1

يمكنك تشغيل المود من الهاتف، لكن تحتاج أولًا إلى ملف .jar. لا أستطيع إنشاء رابط تحميل عام أو استضافة الملف مباشرة من هذه المحادثة.

أسهل حل:

  1. ثبّت PojavLauncher على هاتفك.

  2. اطلب من شخص لديه كمبيوتر أن يبني المشروع بالأمر:

    Shell
    ./gradlew build
    
  3. سيجد ملف المود داخل:

    Plain Text
    build/libs/
    
  4. أرسل ملف .jar إلى هاتفك.

  5. في PojavLauncher اختر Minecraft 1.21.4 Fabric.

  6. ضع ملف المود وملف Fabric API 1.21.4 داخل مجلد:

    Plain Text
    .minecraft/mods/
    
  7. شغّل اللعبة. لا يحتاج المود إلى التثبيت على الخادم.

يمكن أيضًا بناء المشروع مباشرة من الهاتف باستخدام Termux، لكن ذلك أصعب ويحتاج مساحة وJava 21. إذا أردت، أستطيع إعطاؤك خطوات البناء من هاتف Android فقط.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
9 530
src/main/java/com/kodari/verticalmegapocket/VerticalMegaPocket.java
package com.kodari.verticalmegapocket;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

public final class VerticalMegaPocket implements ClientModInitializer {
    public static final String MOD_ID = "verticalmegapocket";
    public static final int SLOT_COUNT = 4_500;
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
    private static final Path CACHE_PATH = FabricLoader.getInstance().getConfigDir()
            .resolve("vertical_mega_pocket.json");
    private static final List<ItemStack> SLOTS = new ArrayList<>(SLOT_COUNT);

    @Override
    public void onInitializeClient() {
        loadCache();
    }

    public static ItemStack getSlot(int index) {
        return SLOTS.get(index);
    }

    public static void setSlot(int index, ItemStack stack) {
        SLOTS.set(index, stack.isEmpty() ? ItemStack.EMPTY : stack.copy());
    }

    public static int findEmptySlot() {
        for (int index = 0; index < SLOT_COUNT; index++) {
            if (SLOTS.get(index).isEmpty()) {
                return index;
            }
        }
        return -1;
    }

    public static void loadCache() {
        SLOTS.clear();
        for (int index = 0; index < SLOT_COUNT; index++) {
            SLOTS.add(ItemStack.EMPTY);
        }

        if (!Files.isRegularFile(CACHE_PATH)) {
            return;
        }

        try (Reader reader = Files.newBufferedReader(CACHE_PATH, StandardCharsets.UTF_8)) {
            JsonElement root = JsonParser.parseReader(reader);
            if (!root.isJsonArray()) {
                return;
            }

            JsonArray slots = root.getAsJsonArray();
            int limit = Math.min(slots.size(), SLOT_COUNT);
            for (int index = 0; index < limit; index++) {
                JsonElement element = slots.get(index);
                if (!element.isJsonObject()) {
                    continue;
                }

                JsonObject entry = element.getAsJsonObject();
                if (!entry.has("id") || !entry.has("count")) {
                    continue;
                }

                String id = entry.get("id").getAsString();
                int count = entry.get("count").getAsInt();
                if (count <= 0) {
                    continue;
                }

                Identifier identifier = Identifier.tryParse(id);
                if (identifier == null) {
                    continue;
                }

                Item item = Registries.ITEM.get(identifier);
                if (item != Items.AIR) {
                    SLOTS.set(index, new ItemStack(item, Math.min(count, item.getMaxCount())));
                }
            }
        } catch (Exception exception) {
            LOGGER.warn("Unable to load {}", CACHE_PATH, exception);
        }
    }

    public static void saveCache() {
        JsonArray slots = new JsonArray(SLOT_COUNT);
        for (ItemStack stack : SLOTS) {
            JsonObject entry = new JsonObject();
            if (stack.isEmpty()) {
                entry.addProperty("id", "minecraft:air");
                entry.addProperty("count", 0);
            } else {
                entry.addProperty("id", Registries.ITEM.getId(stack.getItem()).toString());
                entry.addProperty("count", stack.getCount());
            }
            slots.add(entry);
        }

        try {
            Files.createDirectories(CACHE_PATH.getParent());
            try (Writer writer = Files.newBufferedWriter(CACHE_PATH, StandardCharsets.UTF_8)) {
                GSON.toJson(slots, writer);
            }
        } catch (Exception exception) {
            LOGGER.error("Unable to save {}", CACHE_PATH, exception);
        }
    }
}