Mack Shaks

Develop a mod that allows players to earn in-game currency by looking at and "disappearing" blocks they gaze upon, with each block assigned a specific value based on its type (e.g., diamonds are high value, dirt is low). Implement a side HUD displaying a monetary goal for a set time limit, with adjustable settings for both the goal amount and the countdown duration. Include a market menu showcasing the current values of each block, which updates every minute, and provide an end-of-challenge screen offering options to "Keep Playing" or "Start a New Challenge," the latter leading to the settings menu.

Kodari AI
KodariTue at 12:55 am 4
GazeMinerChallenge
A Minecraft Fabric mod where players earn currency by gazing at blocks to make them disappear, with each block type assigned a value. Features a side HUD showing a monetary goal and countdown timer, both adjustable via settings. Includes a market menu displaying current block values that refresh every minute, and an end-of-challenge screen with "Keep Playing" or "Start a New Challenge" options, the latter opening the settings menu.

[Generation stopped]

Mack Shaks

Develop a mod that allows players to earn in-game currency by looking at and "disappearing" blocks they gaze upon, with each block assigned a specific value based on its type (e.g., diamonds are high value, dirt is low). Implement a side HUD displaying a monetary goal for a set time limit, with adjustable settings for both the goal amount and the countdown duration. Include a market menu showcasing the current values of each block, which updates every minute, and provide an end-of-challenge screen offering options to "Keep Playing" or "Start a New Challenge," the latter leading to the settings menu. (Replace what you currently have)

Kodari AI
KodariTue at 1:01 am 14
  • I’ll make gaze removal server-authoritative, with block values refreshed every minute.

  • The HUD, market, challenge settings, and result screen will use shared challenge state.

Implemented the gaze challenge, market, HUD, settings, and result screen.

  • Press G to configure and start a challenge; press M to open the market.

  • While playing, look at blocks within five blocks to remove them and earn their current value. No new items are needed in survival.

  • Keep Playing continues earning without a timer.

Challenge progress is lost on disconnect. The market display refreshes each minute during an active or completed challenge, but not while idle before starting one.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
13 435
src/client/java/com/kodari/gazemarket/client/GazeClient.java
package com.kodari.gazemarket.client;

import com.kodari.gazemarket.Packets;
import com.mojang.blaze3d.platform.InputConstants;
import io.wispforest.owo.ui.component.LabelComponent;
import io.wispforest.owo.ui.component.UIComponents;
import io.wispforest.owo.ui.container.FlowLayout;
import io.wispforest.owo.ui.container.UIContainers;
import io.wispforest.owo.ui.core.Insets;
import io.wispforest.owo.ui.core.Positioning;
import io.wispforest.owo.ui.core.Sizing;
import io.wispforest.owo.ui.core.Surface;
import io.wispforest.owo.ui.hud.Hud;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;

public final class GazeClient implements ClientModInitializer {
    static Packets.State state = new Packets.State(0, 0, 1000, 0, 0);
    private static LabelComponent label;
    private static String shown = "";

    @Override public void onInitializeClient() {
        KeyMapping challenge = KeyMappingHelper.registerKeyMapping(new KeyMapping("key.gaze_market.challenge", InputConstants.Type.KEYBOARD, InputConstants.KEY_G, KeyMapping.Category.MISC));
        KeyMapping market = KeyMappingHelper.registerKeyMapping(new KeyMapping("key.gaze_market.market", InputConstants.Type.KEYBOARD, InputConstants.KEY_M, KeyMapping.Category.MISC));
        ClientPlayNetworking.registerGlobalReceiver(Packets.State.TYPE, (packet, context) -> {
            int oldMode = state.mode();
            state = packet;
            if (packet.mode() == 3 && oldMode != 3) context.client().gui.setScreen(new ResultScreen());
        });
        ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
            state = new Packets.State(0, 0, 1000, 0, 0);
            send(0, 0, 0);
        });
        ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> state = new Packets.State(0, 0, 1000, 0, 0));
        Hud.add(Identifier.fromNamespaceAndPath("gaze_market", "challenge"), () -> {
            label = UIComponents.label(Component.literal("G: Start challenge | M: Market"));
            FlowLayout panel = UIContainers.verticalFlow(Sizing.content(), Sizing.content());
            panel.child(label);
            panel.padding(Insets.of(5));
            panel.margins(Insets.of(5));
            panel.surface(Surface.DARK_PANEL);
            panel.positioning(Positioning.relative(100, 10));
            return panel;
        });
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (challenge.consumeClick()) {
                if (client.player != null) client.gui.setScreen(ChallengeSettings.create(client.gui.screen()));
            }
            while (market.consumeClick()) {
                if (client.player != null) client.gui.setScreen(new MarketScreen());
            }
            if (label != null) {
                String text = switch (state.mode()) {
                    case 1 -> "Gaze challenge\n$" + state.money() + " / $" + state.goal() + "\nTime: " + formatTime(state.seconds()) + "\nM: Market";
                    case 2 -> "Free play\n$" + state.money() + "\nG: New challenge | M: Market";
                    case 3 -> "Challenge ended\n$" + state.money() + " / $" + state.goal() + "\nG: New challenge | M: Market";
                    default -> "G: Start challenge\nM: Market";
                };
                if (!shown.equals(text)) { shown = text; label.text(Component.literal(text)); }
            }
        });
    }

    static String formatTime(int seconds) { return String.format(java.util.Locale.ROOT, "%d:%02d", seconds / 60, seconds % 60); }

    static void send(int action, int goal, int seconds) {
        if (ClientPlayNetworking.canSend(Packets.Action.TYPE)) ClientPlayNetworking.send(new Packets.Action(action, goal, seconds));
    }
}