Akshat Raj

Compile this zip into into an actual working mod ( jar )

Kodari AI
KodariNov 9 at 10:46 am 2

To build your mod JAR in Kodari:

  1. On desktop, click Compile in the top bar. On phone, tap ⋮ → Compile Project.

  2. Click Compile in the window.

  3. When it succeeds, click Download on the build or Download {name}.jar in the chat.

If it fails, click Auto-fix in the chat or Fix in the build window.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
README.md
settings.gradle
Code
11 491
src/main/java/com/bgsaver/BgSaverClient.java
package com.bgsaver;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BgSaverClient implements ClientModInitializer {
    public static final String MOD_ID = "bgsaver";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    private static final KeyBinding.Category CATEGORY =
            KeyBinding.Category.create(Identifier.of(MOD_ID, "main"));

    private static KeyBinding toggleKey;

    @Override
    public void onInitializeClient() {
        SaverConfig.load();

        // Unbound by default: set it in Options > Controls > Key Binds > Background Saver.
        toggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.bgsaver.toggle", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_UNKNOWN, CATEGORY));

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (toggleKey.wasPressed()) {
                SaverConfig.load(); // picks up any edits made to config/bgsaver.json
                boolean on = PowerState.toggleManual();
                if (client.player != null) {
                    String msg = on
                            ? "Low-power mode ON (" + SaverConfig.get().backgroundFps + " FPS)"
                            : "Low-power mode OFF";
                    client.player.sendMessage(Text.literal(msg), true);
                }
            }
        });

        LOGGER.info("Background Saver loaded ({})", PowerState.describePlatform());
    }
}