cadepotato

i need a mod that displays a counter in the top left of your screen the number of potatoes you have harvested throw-out the world written in white in the base pixel minecraft font

Kodari AI
KodariJul 1 at 8:38 pm 4
PotatoCounter
A Fabric mod for Minecraft 1.20.1 that displays a persistent counter in the top-left corner of the screen showing how many potatoes have been harvested across the entire world. Uses the default Minecraft pixel font in white. Tracks harvests globally with data saved to the world file, synced to all players via networking. No configuration needed — install and play.</project_descriptionA Fabric mod that tracks every potato harvest and displays a persistent counter in the top-left HUD.
PotatoCounter
A Fabric mod for Minecraft that displays a white counter in the top-left corner of the screen showing how many potatoes you have harvested throughout the world. Uses the default Minecraft pixel font and persists data per-player across sessions. Lightweight, single-file data storage, compatible with Minecraft 1.20.4.

Potato counter mod — tracks global potato harvests and shows them in the HUD.

PotatoCounter
A Fabric mod that tracks every potato harvest and displays a persistent white counter in the top-left HUD using Minecraft's default pixel font. Counter syncs to all online players and persists to disk. Zero configuration required.
Kodari can make mistakes. Review important code before using.
Files
project
Code
8 272
project/src/main/java/com/example/potatocounter/PotatoCounterMod.java
package com.example.potatocounter;

import com.example.potatocounter.data.HarvestData;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PotatoCounterMod implements ModInitializer {
    public static final String MOD_ID = "potatocounter";
    public static final Identifier HARVEST_SYNC_ID = Identifier.of(MOD_ID, "harvest_sync");
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    @Override
    public void onInitialize() {
        ServerLifecycleEvents.SERVER_STARTED.register(server -> {
            HarvestData.getInstance().initialize(server);
        });

        ServerLifecycleEvents.SERVER_STOPPING.register(server -> {
            HarvestData.getInstance().save();
        });

        PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> {
            if (world.isClient) return;
            if (state.isOf(Blocks.POTATOES) && state.contains(CropBlock.AGE) && state.get(CropBlock.AGE) >= 7) {
                HarvestData data = HarvestData.getInstance();
                data.increment();
                data.save();
                broadcastCountToAll();
            }
        });

        ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
            sendCountToPlayer(handler.player);
        });
    }

    public static void broadcastCountToAll() {
        int count = HarvestData.getInstance().getCount();
        for (ServerPlayerEntity player : HarvestData.getInstance().getServer().getPlayerManager().getPlayerList()) {
            PacketByteBuf buf = PacketByteBufs.create();
            buf.writeInt(count);
            ServerPlayNetworking.send(player, HARVEST_SYNC_ID, buf);
        }
    }

    public static void sendCountToPlayer(ServerPlayerEntity player) {
        int count = HarvestData.getInstance().getCount();
        PacketByteBuf buf = PacketByteBufs.create();
        buf.writeInt(count);
        ServerPlayNetworking.send(player, HARVEST_SYNC_ID, buf);
    }
}