MeepMeep

make it jar build it

Kodari AI
KodariNov 10 at 11:56 am 1
  1. Click Compile in the top bar.

  2. In the window that opens, click Compile.

  3. When it succeeds, click Download to get the JAR.

Kodari can make mistakes. Review important code before using.
Files
src
.gitignore
build.gradle
gradle.properties
README.md
settings.gradle
Code
12 554
src/client/java/com/thezone/TheZoneClient.java
package com.thezone;

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.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.entity.LivingEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

public class TheZoneClient implements ClientModInitializer {
    public static final String MOD_ID = "thezone";

    private static KeyBinding openConfigKey;
    private static KeyBinding toggleKey;

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

        KeyBinding.Category category = KeyBinding.Category.create(Identifier.of(MOD_ID, "main"));
        openConfigKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.thezone.open_config", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_Z, category));
        toggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.thezone.toggle", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V, category));

        ClientTickEvents.END_CLIENT_TICK.register(mc -> {
            while (toggleKey.wasPressed()) {
                ZoneConfig c = ZoneConfig.INSTANCE;
                c.enabled = !c.enabled;
                ZoneConfig.save();
                if (mc.player != null) {
                    mc.player.sendMessage(Text.literal("The Zone: " + (c.enabled ? "ON" : "OFF")), true);
                }
            }
            while (openConfigKey.wasPressed()) {
                if (mc.currentScreen == null) {
                    mc.setScreen(new ZoneConfigScreen(null));
                }
            }
            ZoneState.tick(mc);
        });

        // Landing a hit on anything alive drops you into the zone
        AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            if (world.isClient() && entity instanceof LivingEntity) {
                ZoneState.hitDealt();
            }
            return ActionResult.PASS;
        });

        // "The Zone" settings button in the pause menu and in Options
        ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
            if (screen instanceof GameMenuScreen || screen instanceof OptionsScreen) {
                Screens.getButtons(screen).add(
                        ButtonWidget.builder(Text.literal("The Zone"),
                                        b -> client.setScreen(new ZoneConfigScreen(screen)))
                                .dimensions(6, 6, 90, 20)
                                .build());
            }
        });

        // Draw under the chat so chat stays readable
        HudElementRegistry.attachElementBefore(
                VanillaHudElements.CHAT,
                Identifier.of(MOD_ID, "zone"),
                ZoneHud::render);
    }
}