zema deinara

--- 📎 Attached 1 file(s):

File: MendingManaMod.java

java
package com.mendingmana;

import com.mendingmana.network.ManaNetworking;
import com.mendingmana.network.ManaServerBridge;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;

import java.util.*;

public class MendingManaMod implements ModInitializer {
    public static final String MOD_ID = "mendingmana";
    public static final int INTERVAL_TICKS = 20 * 60 * 2;
    public static final int EFFECT_DURATION_TICKS = 20 * 60 * 2;

    private final Map<UUID, Integer> timers = new HashMap<>();
    private final Map<UUID, List<ManaChoice>> pendingChoices = new HashMap<>();
    private final Random random = new Random();

    private static final List<ManaChoice> CHOICES = List.of(
            new ManaChoice("swift", "MANA CEPAT", "Lari dan bergerak lebih cepat", true, StatusEffects.SPEED, 1, EFFECT_DURATION_TICKS),
            new ManaChoice("iron", "MANA BESI", "Pertahanan tubuh meningkat", true, StatusEffects.RESISTANCE, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("vital", "MANA VITAL", "Regenerasi kesehatan", true, StatusEffects.REGENERATION, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("haste", "MANA CEPAT TANGAN", "Menambang lebih cepat", true, StatusEffects.HASTE, 1, EFFECT_DURATION_TICKS),
            new ManaChoice("weak", "MANA LEMAH", "Seranganmu menjadi lebih lemah", false, StatusEffects.WEAKNESS, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("slow", "MANA LAMBAT", "Gerakanmu menjadi lebih lambat", false, StatusEffects.SLOWNESS, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("heavy", "MANA BERAT", "Menambang menjadi lebih lambat", false, StatusEffects.MINING_FATIGUE, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("blind", "MANA GELAP", "Pandanganmu menjadi gelap", false, StatusEffects.BLINDNESS, 0, 20 * 10)
    );

    @Override
    public void onInitialize() {
        ManaServerBridge.set(this);
        ManaNetworking.registerCommon();
        ServerTickEvents.END_SERVER_TICK.register(this::tick);
        System.out.println("[Mending Mana] Loaded for Minecraft 1.21.9");
    }

    private void tick(MinecraftServer server) {
        Set<UUID> online = new HashSet<>();
        for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) {
            UUID id = player.getUuid();
            online.add(id);
            int elapsed = timers.getOrDefault(id, 0) + 1;

            if (elapsed % 20 == 0) {
                ManaNetworking.sendTimer(player, Math.max(0, (INTERVAL_TICKS - elapsed) / 20));
            }

            if (elapsed >= INTERVAL_TICKS) {
                elapsed = 0;
                openChoice(player);
                ManaNetworking.sendTimer(player, INTERVAL_TICKS / 20);
            }
            timers.put(id, elapsed);
        }
        timers.keySet().removeIf(id -> !online.contains(id));
        pendingChoices.keySet().removeIf(id -> !online.contains(id));
    }

    private void openChoice(ServerPlayerEntity player) {
        List<ManaChoice> shuffled = new ArrayList<>(CHOICES);
        Collections.shuffle(shuffled, random);
        List<ManaChoice> selected = List.copyOf(shuffled.subList(0, 3));
        pendingChoices.put(player.getUuid(), selected);
        ManaNetworking.openChoice(player, selected.get(0).id(), selected.get(1).id(), selected.get(2).id());
    }

    public boolean choose(ServerPlayerEntity player, int index) {
        List<ManaChoice> choices = pendingChoices.get(player.getUuid());
        if (choices == null || index < 0 || index >= choices.size()) return false;
        ManaChoice choice = choices.get(index);
        player.addStatusEffect(new StatusEffectInstance(choice.effect(), choice.duration(), choice.amplifier(), false, true, true));
        pendingChoices.remove(player.getUuid());
        player.sendMessage(Text.literal("Mana terpilih: " + choice.title()), true);
        return true;
    }

    public record ManaChoice(String id, String title, String description, boolean beneficial,
                             StatusEffect effect, int amplifier, int duration) { }
}
📎 1 file 4,392 chars
📄
MendingManaMod.java
java 87 lines
▶
package com.mendingmana;

import com.mendingmana.network.ManaNetworking;
import com.mendingmana.network.ManaServerBridge;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;

import java.util.*;

public class MendingManaMod implements ModInitializer {
    public static final String MOD_ID = "mendingmana";
    public static final int INTERVAL_TICKS = 20 * 60 * 2;
    public static final int EFFECT_DURATION_TICKS = 20 * 60 * 2;

    private final Map timers = new HashMap<>();
    private final Map> pendingChoices = new HashMap<>();
    private final Random random = new Random();

    private static final List CHOICES = List.of(
            new ManaChoice("swift", "MANA CEPAT", "Lari dan bergerak lebih cepat", true, StatusEffects.SPEED, 1, EFFECT_DURATION_TICKS),
            new ManaChoice("iron", "MANA BESI", "Pertahanan tubuh meningkat", true, StatusEffects.RESISTANCE, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("vital", "MANA VITAL", "Regenerasi kesehatan", true, StatusEffects.REGENERATION, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("haste", "MANA CEPAT TANGAN", "Menambang lebih cepat", true, StatusEffects.HASTE, 1, EFFECT_DURATION_TICKS),
            new ManaChoice("weak", "MANA LEMAH", "Seranganmu menjadi lebih lemah", false, StatusEffects.WEAKNESS, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("slow", "MANA LAMBAT", "Gerakanmu menjadi lebih lambat", false, StatusEffects.SLOWNESS, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("heavy", "MANA BERAT", "Menambang menjadi lebih lambat", false, StatusEffects.MINING_FATIGUE, 0, EFFECT_DURATION_TICKS),
            new ManaChoice("blind", "MANA GELAP", "Pandanganmu menjadi gelap", false, StatusEffects.BLINDNESS, 0, 20 * 10)
    );

    @Override
    public void onInitialize() {
        ManaServerBridge.set(this);
        ManaNetworking.registerCommon();
        ServerTickEvents.END_SERVER_TICK.register(this::tick);
        System.out.println("[Mending Mana] Loaded for Minecraft 1.21.9");
    }

    private void tick(MinecraftServer server) {
        Set online = new HashSet<>();
        for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) {
            UUID id = player.getUuid();
            online.add(id);
            int elapsed = timers.getOrDefault(id, 0) + 1;

            if (elapsed % 20 == 0) {
                ManaNetworking.sendTimer(player, Math.max(0, (INTERVAL_TICKS - elapsed) / 20));
            }

            if (elapsed >= INTERVAL_TICKS) {
                elapsed = 0;
                openChoice(player);
                ManaNetworking.sendTimer(player, INTERVAL_TICKS / 20);
            }
            timers.put(id, elapsed);
        }
        timers.keySet().removeIf(id -> !online.contains(id));
        pendingChoices.keySet().removeIf(id -> !online.contains(id));
    }

    private void openChoice(ServerPlayerEntity player) {
        List shuffled = new ArrayList<>(CHOICES);
        Collections.shuffle(shuffled, random);
        List selected = List.copyOf(shuffled.subList(0, 3));
        pendingChoices.put(player.getUuid(), selected);
        ManaNetworking.openChoice(player, selected.get(0).id(), selected.get(1).id(), selected.get(2).id());
    }

    public boolean choose(ServerPlayerEntity player, int index) {
        List choices = pendingChoices.get(player.getUuid());
        if (choices == null || index < 0 || index >= choices.size()) return false;
        ManaChoice choice = choices.get(index);
        player.addStatusEffect(new StatusEffectInstance(choice.effect(), choice.duration(), choice.amplifier(), false, true, true));
        pendingChoices.remove(player.getUuid());
        player.sendMessage(Text.literal("Mana terpilih: " + choice.title()), true);
        return true;
    }

    public record ManaChoice(String id, String title, String description, boolean beneficial,
                             StatusEffect effect, int amplifier, int duration) { }
}
Kodari AI
KodariSep 1 at 6:33 am 2
MendingManaGUI
A Bukkit plugin that recreates the Mending Mana mod as a GUI-based system. Every two minutes, players receive a chest inventory GUI presenting three randomly selected mana choices, each with beneficial or detrimental status effects. Players click a button to select their mana, which applies the corresponding potion effect. The plugin uses the custom inventory GUI framework with lazy initialization, button-based click handling, and centralized GUIManager for automatic event routing and memory cleanup.
  1. Create the Fabric 1.21.9 Gradle project and mod metadata.

  2. Add the server mana timer, choice generation, and effect application.

  3. Add typed Fabric networking payloads and the server bridge.

  4. Add the client choice screen and countdown HUD.

Created the complete Fabric 1.21.9 Mending Mana mod:

  • Gradle project configuration and Fabric metadata

  • Periodic mana timer and random effect choices

  • Server/client networking payloads

  • Server-side effect selection and validation

  • Client mana choice screen

  • Countdown HUD display

  • MIT license file

zema deinara

can you make the mod .jar?

Kodari AI
KodariSep 1 at 6:36 am 1

I can’t generate the .jar in this workspace because it has no Gradle wrapper or installed build tool—only the source files are available.

On a machine with Java 21 and Gradle installed, run from the project root:

Shell
gradle build

The compiled mod will be created at:

Plain Text
build/libs/mending-mana-1.0.0.jar

Use that JAR in the server’s mods folder.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
LICENSE
settings.gradle
Code
13 485
src/main/java/com/mendingmana/client/MendingManaClient.java
package com.mendingmana.client;

import com.mendingmana.network.ManaNetworking;
import com.mendingmana.network.ManaOpenPayload;
import com.mendingmana.network.ManaTimerPayload;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;

public class MendingManaClient implements ClientModInitializer {
    private static int timerSeconds = -1;

    @Override
    public void onInitializeClient() {
        ClientPlayNetworking.registerGlobalReceiver(ManaOpenPayload.ID, (payload, context) ->
                context.client().execute(() -> context.client().setScreen(
                        new ManaChoiceScreen(payload.firstId(), payload.secondId(), payload.thirdId()))));
        ClientPlayNetworking.registerGlobalReceiver(ManaTimerPayload.ID, (payload, context) ->
                context.client().execute(() -> timerSeconds = payload.seconds()));

        HudRenderCallback.EVENT.register((drawContext, tickCounter) -> {
            if (timerSeconds < 0 || MinecraftClient.getInstance().currentScreen instanceof ManaChoiceScreen) {
                return;
            }

            String timer = String.format("%02d:%02d", timerSeconds / 60, timerSeconds % 60);
            drawContext.drawTextWithShadow(
                    MinecraftClient.getInstance().textRenderer,
                    Text.literal("Mana berikutnya: " + timer),
                    8, 8, 0xFFFFFF);
        });
    }

    public static void sendChoice(int index) {
        ClientPlayNetworking.send(new com.mendingmana.network.ManaChoicePayload(index));
    }
}