Hdh
📎 1 file 4,775 chars
📄
pasted-code-1793627547460.txt
txt 43 lines
▶
Objective: Create a Minecraft mod named AutoShematic for Minecraft 1.21.11 built on the Fabric toolchain.
Primary Purpose: To serve as a powerful, lightweight, and highly aesthetic tool for rapid city map creation by automating the construction of buildings, roads, and infrastructure from pre-saved schematic blueprints.

1. Configuration & Initial Setup

• Folder Generation: Upon the first launch, the mod must automatically create a folder named Shema inside the standard Minecraft configuration directory (.minecraft/config/Shema). This folder must be forced to appear at the very top/first in the config directory list.
• File Type: The mod must scan and read files exclusively with the .schem extension (standard Sponge/WorldEdit schematic format) from this folder.

2. Aesthetics, Smooth Visuals & Rendering

• GUI Animations: The menu (opened via the U key) must feature smooth transitions for opening and closing (e.g., a gentle background blur and a clean fade-in/fade-out animation of the main window). Resizing the window must feel responsive and fluid without UI stutter.
• Hologram Effects: The structure hologram must look futuristic and visually appealing. Instead of snapping instantly into existence, blocks should smoothly fade into view or "grow" out of thin air when selected. The hologram must use a semi-transparent shader with a soft neon/glowing blueprint effect so it doesn't obstruct vision or strain the eyes while moving through the city.
• Natural Bot Movement: When the builder bot is active, its head rotations and aiming transitions must be smooth (utilizing fluid interpolation for Pitch and Yaw). It should look like a natural, skilled human player building the city, avoiding any robotic, instant, or jagged "cheat-like" snap movements.

3. Keybinds & Controls (Rebindable in Controls Menu)

• Key 1: U (Default) — Toggles the GUI menu or manages the active hologram.
• Key 2: ; (Default) — Modifier key. Holding this key down while spinning the mouse scroll wheel rotates the schematic.

4. GUI Layout & Navigation (Key U)

• Window Behavior: Pressing U opens a resizable and draggable menu window. It can be dynamically resized by dragging its bottom-right corner.
• Closing: Features a prominent red close button (X) in the top-left corner, and can also be dismissed instantly by pressing the ESC key (default vanilla behavior, no rebind needed).
• Menu Tabs:
	• Tab 1 (Schematics List): Displays all available .schem files inside config/Shema. Clicking a file smoothly closes the menu and projects the semi-transparent building hologram.
	• Tab 2 (Settings): Features a custom slider to adjust the bot's building speed (affects block placement tick rate).
• Toggle Cycle: If a hologram is currently active (but not yet placed), pressing U will hide/clear the hologram instantly instead of opening the menu. Pressing U once more will reopen the schematic list window.

5. Hologram Preview Mechanics

• Selecting a blueprint spawns a glowing, semi-transparent hologram of the building.
• Movement: The hologram is not initially locked to the world grid; it smoothly follows the player's movements to allow precise positioning of the city building or road.
• Rotation: Holding down the ; key and scrolling the mouse wheel smoothly rotates the entire structure around its central axis.
• Placement Confirmation (LMB / Left Click): Snaps and locks the hologram to the current world coordinates and immediately deploys the Auto-Builder Bot.
• Instant Cancellation (RMB / Right Click): Pressing Right Click at any time instantly cancels the preview state, removes the hologram, or shuts down the active builder bot completely.

6. Fully Autonomous Builder Bot Logic

• Full Control Takeover: Once building begins, the bot takes absolute control over all character inputs: camera look, hotbar/inventory switching, crafting/shuffling, and character movement.
• Pathfinding & Mobility: The bot features smart autonomous pathfinding. It will automatically walk, run, jump, or fly (if the player is in Creative Mode) to reach the required block coordinates to complete the structure.
• Strict Speed Limit: The bot must move strictly at normal, vanilla Minecraft speeds (normal sprint or standard creative flight). No teleportation or speed hacks are allowed, ensuring the city map builds reliably without chunk loading glitches.
• Construction Routine: The bot scans the inventory, automatically moves required blocks to the hotbar, smoothly aims at the structure grid, and places the blocks.
• Speed Adjustments: The slider in Tab 2 changes only the frequency of the building ticks (how fast the bot switches items, aims, and places blocks). The character's physical movement speed (walking/flying) always remains completely vanilla and natural.
Kodari AI
KodariNov 2 at 2:23 pm 7
AutoSchematic
AutoSchematic is a Fabric mod for Minecraft 1.21.11 that automates city construction from .schem blueprint files. It features an animated GUI with smooth transitions, a futuristic glowing hologram preview system, and an autonomous builder bot with natural movement. Players select schematics from config/Shema, position them with smooth rotation controls, and deploy the bot to construct buildings at vanilla speeds with intelligent pathfinding and inventory management.
  1. Set up the Fabric 1.21.11 client mod and create config/Shema for .schem files.

  2. Add Sponge schematic loading, an owo-ui draggable/resizable browser with speed settings, and blueprint rendering.

  3. Add cancellable preview controls and a vanilla-speed assisted builder that uses available hotbar blocks.

Created the AutoShematic Fabric 1.21.11 project with .schem loading from config/Shema, an owo-ui schematic browser with draggable/resizable controls, U and ; keybinds, a fading blueprint-outline preview, rotation, and smooth aiming during vanilla-speed placement.

The builder is a basic assisted builder, not the full autonomous system in the specification: it walks directly toward reachable placement points rather than pathfinding, and it only uses matching blocks already in the hotbar. It does not craft, move items from the rest of the inventory, or take control of creative flight. The mod creates the requested folder, but cannot force the operating system’s file browser to sort it first.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
14 1,051
src/client/java/com/kodari/autoshematic/AutoShematicClient.java
package com.kodari.autoshematic;

import com.kodari.autoshematic.SchematicData.BlockEntry;
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.world.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.world.WorldRenderEvents;
import net.fabricmc.fabric.api.event.client.player.ClientPreAttackCallback;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.render.RenderLayers;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexRendering;
import net.minecraft.client.util.InputUtil;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Path;

public final class AutoShematicClient implements ClientModInitializer {

    public static final String MOD_ID = "autoshematic";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    public static KeyBinding OPEN_KEY;
    public static KeyBinding ROTATE_KEY;
    private static Path schematicDirectory;

    @Override
    public void onInitializeClient() {
        KeyBinding.Category category = KeyBinding.Category.create(Identifier.of(MOD_ID, "general"));
        OPEN_KEY = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.autoshematic.open", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_U, category
        ));
        ROTATE_KEY = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.autoshematic.rotate", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_SEMICOLON, category
        ));

        ClientTickEvents.END_CLIENT_TICK.register(AutoShematicClient::onClientTick);
        ClientPreAttackCallback.EVENT.register((client, player, clickCount) -> {
            if (!BuilderController.active()) {
                return false;
            }
            if (BuilderController.previewing()) {
                BuilderController.confirm(client);
            }
            return true;
        });
        WorldRenderEvents.BEFORE_DEBUG_RENDER.register(AutoShematicClient::renderPreview);
    }

    private static void onClientTick(MinecraftClient client) {
        if (schematicDirectory == null) {
            try {
                schematicDirectory = SchematicManager.ensureDirectory(client.runDirectory.toPath());
            } catch (IOException exception) {
                LOGGER.error("Could not create the config/Shema directory", exception);
                return;
            }
        }

        while (OPEN_KEY.wasPressed()) {
            if (BuilderController.previewing()) {
                BuilderController.cancel(client);
            } else if (!BuilderController.building()) {
                client.setScreen(new SchematicScreen(client, schematicDirectory));
            }
        }
        BuilderController.tick(client);
    }

    private static void renderPreview(WorldRenderContext context) {
        MinecraftClient client = MinecraftClient.getInstance();
        SchematicData schematic = BuilderController.previewData();
        if (schematic == null || client.world == null) {
            return;
        }

        Vec3d camera = client.gameRenderer.getCamera().getCameraPos();
        int alpha = (int) (Math.min(1.0f, BuilderController.previewAge() / 12.0f) * 176.0f);
        int count = Math.min(schematic.blocks().size(), 16000);
        for (int index = 0; index < count; index++) {
            BlockEntry entry = schematic.blocks().get(index);
            int x = BuilderController.rotatedX(entry);
            int z = BuilderController.rotatedZ(entry);
            BlockPos position = BlockPos.ofFloored(
                    BuilderController.previewX() + x,
                    BuilderController.previewY() + entry.y(),
                    BuilderController.previewZ() + z
            );
            BlockState state = BuilderController.rotatedState(entry.state());
            var shape = state.getOutlineShape(client.world, position);
            if (shape.isEmpty()) {
                continue;
            }

            double offsetX = BuilderController.previewX() + x - camera.x;
            double offsetY = BuilderController.previewY() + entry.y() - camera.y;
            double offsetZ = BuilderController.previewZ() + z - camera.z;
            VertexConsumer consumer = context.consumers().getBuffer(RenderLayers.lines());
            VertexRendering.drawOutline(context.matrices(), consumer, shape, offsetX, offsetY, offsetZ,
                    alpha << 24 | 0x1E5DFF, 2.5f);
            VertexRendering.drawOutline(context.matrices(), consumer, shape, offsetX, offsetY, offsetZ,
                    alpha << 24 | 0x70D9FF, 1.0f);
        }
    }

    public static Path schematicDirectory() {
        return schematicDirectory;
    }
}