how to export Fabric 1.20 mod correctly

84 Views Asked by At

TREE OF THE FOLDER

I dont know how to export this mod for fabric 1.20. This mod is supposed to send in chat a number when inventory is full.

Can someone tell me step by step how should i export if from Intellij IDEA?

TutorialModClient: package net.yi.tutorialmod;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;

@Environment(net.fabricmc.api.EnvType.CLIENT)
public class TutorialModClient implements ClientModInitializer {

    private boolean wasInventoryFull = false;
    
    @Override
    public void onInitializeClient() {
        System.out.println("InventoryFullNotifier Mod Initialized!");
    
        ClientTickEvents.END_CLIENT_TICK.register(clientTick -> {
            boolean isInventoryFull = isInventoryFull();
    
            if (isInventoryFull && !wasInventoryFull) {
                sendChatMessage();
            }
    
            wasInventoryFull = isInventoryFull;
        });
    }
    
    private boolean isInventoryFull() {
        ClientPlayerEntity player = getClientPlayer();
        return player != null && player.getInventory().main.stream().noneMatch(ItemStack::isEmpty);
    }
    
    private void sendChatMessage() {
        MinecraftClient client = MinecraftClient.getInstance();
        ClientPlayerEntity player = getClientPlayer();
    
        if (client.inGameHud != null && player != null) {
            // Create a Text object from the message
            Text chatMessage = Text.Serializer.fromLenientJson("77765");
    
            // Use the ChatHud to add the message
            client.inGameHud.getChatHud().addMessage(chatMessage);
        }
    }
    
    private ClientPlayerEntity getClientPlayer() {
        return MinecraftClient.getInstance().player;
    }

}

fabric.mod.json

{
"schemaVersion": 1,
"id": "tutorialmod",
"version": "${version}",
"name": "Tutorial Mod",
"description": "This is an example description! Tell everyone what your mod is about!",
"authors": \[
"Me!"
\],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
},
"license": "MIT",
"icon": "assets/tutorialmod/icon.png",
"environment": "\*",
"entrypoints": {
"main": \[
"net.yi.tutorialmod.TutorialMod"
\],
"client": \[
"net.yi.tutorialmod.TutorialModClient"
\],
"fabric-datagen": \[
"net.yi.tutorialmod.TutorialModDataGenerator"
\]
},
"mixins": \[
"tutorialmod.mixins.json"
\],
"depends": {
"fabricloader": "\>=0.14.25",
"minecraft": "\~1.20",
"java": "\>=17"

    },
    "suggests": {
        "another-mod": "*"
    }

}

Please, help me

I expected that exporting it and putting the mod in the mod folder it could run well, but it doesnt.

0

There are 0 best solutions below