PrevailShadow
📎 1 file 1,344 chars
📄
pasted-code-1793234041267.txt
txt 23 lines
▶
Build a Fabric mod for Minecraft 1.21.1 (Java 21) that acts as a DonutSMP base finder.

Goal: While I fly with elytra, the mod scans nearby chunks and flags likely player bases,
stashes, and spawners, logging exact X/Y/Z coordinates to chat.

Core modules:
1. Base ESP — highlight player-placed blocks (stone bricks, planks, glass, wool,
   concrete, obsidian, etc.) through terrain, with a bright overlay.
2. Storage ESP — render chests, shulkers, and barrels through walls in a distinct color.
3. Spawner detect — detect skeleton spawners (active and inactive) and outline them.
4. Chunk finder — flag newly loaded or "suspicious" chunks (unusual block density,
   large player-placed block clusters).
5. Cluster detect — identify unnatural block groupings (e.g. a wall of cobblestone,
   a flat floor, a tunnel entrance) that suggest a hidden base.

Implementation details:
- Use Fabric Loader + Fabric API.
- Scan chunks within a configurable radius (default 16 chunks) every few ticks.
- For each block, check if it is player-placed vs. naturally generated by comparing
  against known natural block sets; flag anything not in the natural set.
- Render overlays using the standard ESP/outline rendering (similar to existing
  Minecraft ESP mods).
- Log every detection to chat with format: [Type] X:  Y:  Z:    
Kodari AI
KodariOct 29 at 12:51 am 5
DonutSMPBaseFinder
Fabric mod for Minecraft 1.21.1 that scans chunks while flying with elytra to locate player bases, stashes, and spawners. Features include Base ESP highlighting player-placed blocks through terrain with bright overlays, Storage ESP rendering chests/shulkers/barrels in distinct colors, spawner detection with outlines, chunk finder flagging suspicious areas with unusual block density, and cluster detection identifying unnatural block groupings like walls or tunnel entrances. Scans configurable radius (default 16 chunks) every few ticks, compares blocks against natural sets, logs detections to chat with coordinates in format [Type] X: x Y: y Z: z.
  1. Set the project up as a Fabric 1.21.4 client mod, since that is the mounted source/toolchain version.

  2. Implement loaded-chunk scanning, detection logging, and through-wall overlays using verified Yarn/Fabric signatures.

  3. Add the minimal mod metadata and Gradle files needed to build it.

Created the Fabric client mod for the project’s Minecraft 1.21.4 toolchain; the attached brief specified 1.21.1.

It scans loaded chunks incrementally within a configurable radius (config/basefinder.properties, default 16 chunks), logs detections with coordinates, and draws through-wall outlines for heuristic base blocks, storage, clusters, suspicious chunks, and skeleton spawners.

Limits: Minecraft doesn’t record whether a block was player-placed, so base detection is based on block types and grouping and can produce false positives. The client can only scan chunks it has already loaded; it cannot reveal data from unloaded chunks.

PrevailShadow

is it for minecraft 26.2?

Kodari AI
KodariOct 29 at 12:53 am 1

No. It targets Minecraft 1.21.4, not 26.2.

PrevailShadow

can you make it 26.2?

Kodari AI
KodariOct 29 at 12:55 am 1

I can port it, but the available source and project setup target Minecraft 1.21.4 only. This mod uses version-sensitive rendering and Fabric event APIs, so changing just the version numbers wouldn’t be a reliable 26.2 port. I’d need the Minecraft 26.2 Yarn and Fabric API source available to verify the replacements before updating it.

PrevailShadow

how do i do that?

Kodari AI
KodariOct 29 at 12:55 am 1

You don’t need to fetch the sources yourself—I should’ve been clearer. This chat’s project environment only has Minecraft 1.21.4 source available, and I can’t switch that library from here.

If Kodari offers a Minecraft 26.2 Fabric project template or version selector, create/open a project with that target and ask me to port the mod there. If it doesn’t offer 26.2, there isn’t a chat setting I can change to enable it; changing the Gradle version numbers alone wouldn’t make the port reliable.

Kodari can make mistakes. Review important code before using.
Files
Base finder
src
build.gradle
gradle.properties
settings.gradle
Code
6 403
src/main/java/com/kodari/basefinder/BaseFinderClient.java
package com.kodari.basefinder;

import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.MobSpawnerBlockEntity;
import net.minecraft.block.spawner.MobSpawnerLogic;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.VertexRendering;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.WorldChunk;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public final class BaseFinderClient implements ClientModInitializer {
    private static final Path CONFIG_FILE = Path.of("config", "basefinder.properties");
    private static final int DEFAULT_RADIUS_CHUNKS = 16;
    private static final int MIN_RADIUS_CHUNKS = 1;
    private static final int MAX_RADIUS_CHUNKS = 32;
    private static final int CHUNKS_PER_TICK = 1;
    private static final int MAX_RENDERED_DETECTIONS = 2048;
    private static final int CLUSTER_THRESHOLD = 8;
    private static final int SUSPICIOUS_CHUNK_THRESHOLD = 48;
    private static final int BASE_COLOR = 0x5CFF52;
    private static final int STORAGE_COLOR = 0x28D8FF;
    private static final int SPAWNER_COLOR = 0xFF4545;
    private static final int CLUSTER_COLOR = 0xFFD447;
    private static final int CHUNK_COLOR = 0xC56BFF;
    private static final Set<String> EXPLICIT_BUILD_BLOCKS = Set.of(
            "minecraft:glass",
            "minecraft:obsidian",
            "minecraft:cobblestone",
            "minecraft:mossy_cobblestone",
            "minecraft:stone_bricks",
            "minecraft:cracked_stone_bricks",
            "minecraft:mossy_stone_bricks",
            "minecraft:chiseled_stone_bricks",
            "minecraft:bricks",
            "minecraft:quartz_block",
            "minecraft:polished_deepslate",
            "minecraft:deepslate_bricks",
            "minecraft:deepslate_tiles",
            "minecraft:nether_bricks",
            "minecraft:red_nether_bricks",
            "minecraft:purpur_block"
    );
    private static final RenderLayer XRAY_LINES = new RenderLayer(
            "basefinder_xray_lines",
            VertexFormats.LINES,
            VertexFormat.DrawMode.LINES,
            1536,
            false,
            false,
            () -> {
                RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
                RenderSystem.disableDepthTest();
            },
            RenderSystem::enableDepthTest
    ) {
    };

    private static final Set<Long> scannedChunks = new HashSet<>();
    private static final Map<Long, List<Detection>> detectionsByChunk = new HashMap<>();
    private static final ArrayDeque<Detection> chatQueue = new ArrayDeque<>();

    private static ClientWorld scannedWorld;
    private static int radiusChunks = DEFAULT_RADIUS_CHUNKS;

    @Override
    public void onInitializeClient() {
        loadConfig();
        ClientTickEvents.END_CLIENT_TICK.register(BaseFinderClient::onClientTick);
        WorldRenderEvents.AFTER_ENTITIES.register(BaseFinderClient::renderDetections);
    }

    private static void loadConfig() {
        Properties properties = new Properties();
        try {
            Files.createDirectories(CONFIG_FILE.getParent());
            if (Files.notExists(CONFIG_FILE)) {
                properties.setProperty("radius_chunks", Integer.toString(DEFAULT_RADIUS_CHUNKS));
                try (var writer = Files.newBufferedWriter(CONFIG_FILE)) {
                    properties.store(writer, "Base Finder settings");
                }
            } else {
                try (var reader = Files.newBufferedReader(CONFIG_FILE)) {
                    properties.load(reader);
                }
            }
            radiusChunks = Math.max(MIN_RADIUS_CHUNKS, Math.min(MAX_RADIUS_CHUNKS,
                    Integer.parseInt(properties.getProperty("radius_chunks", Integer.toString(DEFAULT_RADIUS_CHUNKS)).trim())));
        } catch (IOException | NumberFormatException exception) {
            radiusChunks = DEFAULT_RADIUS_CHUNKS;
        }
    }

    private static void onClientTick(MinecraftClient client) {
        ClientPlayerEntity player = client.player;
        ClientWorld world = client.world;
        if (player == null || world == null) {
            clearScanState();
            scannedWorld = null;
            return;
        }

        if (scannedWorld != world) {
            clearScanState();
            scannedWorld = world;
        }

        BlockPos playerPos = player.getBlockPos();
        int centerChunkX = playerPos.getX() >> 4;
        int centerChunkZ = playerPos.getZ() >> 4;
        scannedChunks.removeIf(key -> !isWithinRadius(key, centerChunkX, centerChunkZ));
        detectionsByChunk.keySet().removeIf(key -> !isWithinRadius(key, centerChunkX, centerChunkZ));

        int chunksScanned = 0;
        for (int offsetX = -radiusChunks; offsetX <= radiusChunks && chunksScanned < CHUNKS_PER_TICK; offsetX++) {
            for (int offsetZ = -radiusChunks; offsetZ <= radiusChunks && chunksScanned < CHUNKS_PER_TICK; offsetZ++) {
                int chunkX = centerChunkX + offsetX;
                int chunkZ = centerChunkZ + offsetZ;
                long key = chunkKey(chunkX, chunkZ);
                if (scannedChunks.contains(key)) {
                    continue;
                }

                WorldChunk chunk = world.getChunkManager().getChunk(chunkX, chunkZ, ChunkStatus.FULL, false);
                if (chunk == null) {
                    continue;
                }

                scannedChunks.add(key);
                List<Detection> found = scanChunk(world, chunk, chunkX, chunkZ);
                detectionsByChunk.put(key, found);
                chatQueue.addAll(found);
                chunksScanned++;
            }
        }

        Detection detection = chatQueue.pollFirst();
        if (detection != null) {
            BlockPos pos = detection.pos();
            player.sendMessage(Text.literal("[" + detection.type() + "] X: " + pos.getX()
                    + " Y: " + pos.getY() + " Z: " + pos.getZ()), false);
        }
    }

    private static List<Detection> scanChunk(ClientWorld world, WorldChunk chunk, int chunkX, int chunkZ) {
        List<Detection> detections = new ArrayList<>();
        Map<ClusterKey, ClusterAccumulator> clusters = new HashMap<>();
        BlockPos.Mutable cursor = new BlockPos.Mutable();
        int buildBlockCount = 0;
        BlockPos firstBuildBlock = null;
        int startX = chunkX << 4;
        int startZ = chunkZ << 4;

        for (int x = startX; x < startX + 16; x++) {
            for (int z = startZ; z < startZ + 16; z++) {
                for (int y = world.getBottomY(); y <= world.getTopYInclusive(); y++) {
                    cursor.set(x, y, z);
                    BlockState state = chunk.getBlockState(cursor);
                    if (state.isAir()) {
                        continue;
                    }

                    String blockId = Registries.BLOCK.getId(state.getBlock()).toString();
                    if (isStorage(blockId)) {
                        detections.add(new Detection("Storage", new BlockPos(x, y, z), STORAGE_COLOR));
                    } else if ("minecraft:spawner".equals(blockId)) {
                        BlockEntity blockEntity = chunk.getBlockEntity(cursor);
                        if (blockEntity instanceof MobSpawnerBlockEntity spawner) {