Dominik Csoka
📎 1 file 3,923 chars
📄
pasted-code-1793399416277.txt
txt 100 lines
▶
remember the two 10-bit counters, the wind-charge timing, and your calibrated angles. Let's put everything together.
1. What I understand about your machine
Your machine is a redstone-based coordinate system that uses TNT batches and player-view angles to control its operation.
The mod should be the brain that controls your view, while your existing redstone contraption does the physical work.
From what you've explained, the machine has several important parts:
TNT duper: Produces TNT batches for the machine.
X counter: A 10-bit counter representing one coordinate axis.
Z counter: Another 10-bit counter representing the other coordinate axis.
Redstone lamps: Show which bits are active.
Wind charges: Provide timing references.
Player's view: Your looking direction controls the machine through calibrated angles.
Each counter has ten bits:
Bit
Value
1
1
2
2
3
4
4
8
5
16
6
32
7
64
8
128
9
256
10
512
For example, if the active bits represent 1, 4, and 16, the counter's value is 21.
The maximum value is 1023.
However, I still need to understand precisely how your machine converts those values into TNT movement.
2. How I think the mod should work
I suggest separating the mod into six stages.
Stage 1 — Save the origin
You enter:
/origin  
The mod saves the coordinates you specify.
This gives the mod a reference point for calculating the displacement between the origin and the position you want to target.
Stage 2 — Start the machine
You enter:
/nuke start
The mod turns your view to your calibrated NUKE angle:
Yaw: -138.6
Pitch: 33.8
Your existing redstone machine handles whatever happens next.
Stage 3 — Record the target
You cast your fishing rod named nuke.
The mod records the player's X/Z position and looking direction at the appropriate moment.
Important: We need to establish whether the target is the player's position, the direction of the fishing hook, or a point calculated from the player's aim. Those are different measurements.
Stage 4 — Calculate the counters
The mod calculates the required X and Z values.
Each value is represented by ten bits, from 0 to 1023.
This is the part I don't want to guess about. We need to understand how your machine maps a target position to counter values.
Stage 5 — Control the counters
The mod moves your view to the calibrated angles associated with the relevant lamps.
For example, the X counter has its own set of ten calibrated angles, and the Z counter has another set.
The mod must know which bit it is processing, when to change the angle, and when the redstone machine has finished registering that input.
Your /windcharge start timing system may help synchronize these changes.
Stage 6 — Finish
Once both counters have completed their sequences, the mod moves your view to the final angle:
Yaw: -136.4
Pitch: 8.6
The machine then continues according to your existing redstone design.
This is a proposed workflow, not a confirmed implementation. We still need to establish the exact signals and ( make this as a working slint sided mod java 1.21.11)



Lamp 1: yaw:-120.0 pitch:34.4
Lamp 2: yaw:-110.8 pitch:33.6
Lamp 3: yaw:-105.6 pitch:34.0
Lamp 4: yaw:-100.6 pitch:37.1 
Lamp 5: yaw:-92 pitch:35.1
Lamp 6: yaw:-88.1 pitch: 35.1
Lamp 7: yaw:-80 pitch: 34.7
Lamp 8: yaw:-67.0 pitch: 31.1
Lamp 9: yaw:-58.8 pitch:31.4
Lamp 10: yaw:-54.9 pitch: 32.1
East (x counter)

Lamp 1: yaw:-32.2 pitch : 30.3
Lamp 2: yaw:-24.9 pitch: 31.6
Lamp 3: yaw:-19.3 pitch: 31.0
Lamp 4: yaw:-16.4 pitch:32.1
Lamp 5: yaw:-6.2 pitch: 34.2
Lamp 6: yaw:-1.3 pitch: 32.5
☐ Lamp 7: yaw:5.0 pitch :32.5
Lamp 8: yaw : 18.5 pitch :32.9
Lamp 9: yaw :24.1 pitch :31.6
Lamp 10: yaw :31.7 pitch :31.4
Lock : yaw: -40.5 pitch: 14.5
Nuke: yaw: -138.6 pitch: 33.8
Start the counter only snap to this wen the mod is done whit the lamps : yaw: -136.4 pitch : 8.6
This at the south
Kodari AI
KodariOct 30 at 10:38 pm 2
RedstoneNukeController
Client-side Minecraft Fabric mod for controlling a redstone TNT coordinate machine. Manages 10-bit X/Z counters through calibrated player view angles. Features origin saving, nuke sequence activation, fishing rod target recording, automated lamp angle sequencing for both counters, wind charge timing synchronization, and final angle positioning. Converts target coordinates to binary counter values and executes precise yaw/pitch rotations for each active bit lamp, enabling automated TNT batch targeting without manual input.
  1. Set up a Fabric 1.21.11 client-only mod and its client commands.

  2. Implement origin saving, named-rod target capture, calibrated lamp angles, and wind-charge-timed sequencing.

  3. Keep the counter mapping explicit and bounded because the machine’s exact coordinate conversion wasn’t provided.

Created a client-side Fabric 1.21.11 mod with the calibrated camera angles and command-driven sequence.

  • Set and save your origin with /origin <x> <z>.

  • Run /windcharge start to enable timing; set the dwell with /windcharge interval <ticks> (default: 10).

  • Run /nuke start, then cast a fishing rod renamed nuke in an anvil. The mod records your block X/Z position, processes the active X-counter lamps followed by active Z-counter lamps, then turns to the final angle.

  • Use /nuke lock for the calibrated lock angle, /nuke status to check state, and /nuke stop to cancel. /windcharge stop pauses timing.

The machine’s coordinate conversion wasn’t specified, so this version uses the floored block displacement from the origin directly, clamped to 0–1023 for each counter. The second angle set is treated as the Z counter. The mod controls your view only; it does not operate the redstone machine.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 384
src/client/java/com/kodari/coordinatebrain/CoordinateBrainClient.java
package com.kodari.coordinatebrain;

import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class CoordinateBrainClient implements ClientModInitializer {
    private static final Angle[] X_LAMPS = {
            new Angle(-120.0f, 34.4f),
            new Angle(-110.8f, 33.6f),
            new Angle(-105.6f, 34.0f),
            new Angle(-100.6f, 37.1f),
            new Angle(-92.0f, 35.1f),
            new Angle(-88.1f, 35.1f),
            new Angle(-80.0f, 34.7f),
            new Angle(-67.0f, 31.1f),
            new Angle(-58.8f, 31.4f),
            new Angle(-54.9f, 32.1f)
    };

    private static final Angle[] Z_LAMPS = {
            new Angle(-32.2f, 30.3f),
            new Angle(-24.9f, 31.6f),
            new Angle(-19.3f, 31.0f),
            new Angle(-16.4f, 32.1f),
            new Angle(-6.2f, 34.2f),
            new Angle(-1.3f, 32.5f),
            new Angle(5.0f, 32.5f),
            new Angle(18.5f, 32.9f),
            new Angle(24.1f, 31.6f),
            new Angle(31.7f, 31.4f)
    };

    private static final Angle LOCK_ANGLE = new Angle(-40.5f, 14.5f);
    private static final Angle NUKE_ANGLE = new Angle(-138.6f, 33.8f);
    private static final Angle FINISH_ANGLE = new Angle(-136.4f, 8.6f);

    private static final List<Angle> lampSequence = new ArrayList<>();

    private static MinecraftClient client;
    private static boolean originLoaded;
    private static boolean originSet;
    private static int originX;
    private static int originZ;
    private static boolean armed;
    private static boolean targetCaptured;
    private static boolean timingActive;
    private static boolean sequenceRunning;
    private static int intervalTicks = 10;
    private static int ticksUntilNextLamp;
    private static int sequenceIndex;
    private static int xCounter;
    private static int zCounter;
    private static long timingTicks;

    @Override
    public void onInitializeClient() {
        ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
            dispatcher.register(ClientCommandManager.literal("origin")
                    .then(ClientCommandManager.argument("x", IntegerArgumentType.integer())
                            .then(ClientCommandManager.argument("z", IntegerArgumentType.integer())
                                    .executes(context -> {
                                        originX = IntegerArgumentType.getInteger(context, "x");
                                        originZ = IntegerArgumentType.getInteger(context, "z");
                                        originSet = true;
                                        try {
                                            saveOrigin();
                                            context.getSource().sendFeedback(Text.literal(
                                                    "Origin saved at X " + originX + ", Z " + originZ + "."));
                                        } catch (IOException exception) {
                                            context.getSource().sendFeedback(Text.literal(
                                                    "Origin set for this session, but could not be saved: "
                                                            + exception.getMessage()));
                                        }
                                        return 1;
                                    }))));

            dispatcher.register(ClientCommandManager.literal("nuke")
                    .then(ClientCommandManager.literal("start").executes(context -> {
                        if (!originSet) {
                            context.getSource().sendFeedback(Text.literal(
                                    "Set an origin first with /origin <x> <z>."));
                            return 0;
                        }
                        if (client == null || client.player == null) {
                            context.getSource().sendFeedback(Text.literal("You must be in a world to start."));
                            return 0;
                        }
                        armed = true;
                        targetCaptured = false;
                        sequenceRunning = false;
                        lampSequence.clear();
                        setView(NUKE_ANGLE);
                        context.getSource().sendFeedback(Text.literal(
                                "NUKE mode armed. Cast the fishing rod named nuke to record your position."));
                        return 1;
                    }))
                    .then(ClientCommandManager.literal("lock").executes(context -> {
                        setView(LOCK_ANGLE);
                        context.getSource().sendFeedback(Text.literal("View set to the calibrated lock angle."));
                        return 1;
                    }))
                    .then(ClientCommandManager.literal("stop").executes(context -> {
                        armed = false;
                        targetCaptured = false;
                        sequenceRunning = false;
                        lampSequence.clear();
                        context.getSource().sendFeedback(Text.literal("NUKE sequence stopped."));
                        return 1;
                    }))
                    .then(ClientCommandManager.literal("status").executes(context -> {
                        String status = "origin=" + (originSet ? originX + "," + originZ : "unset")
                                + ", armed=" + armed
                                + ", timing=" + timingActive
                                + ", interval=" + intervalTicks + " ticks"
                                + ", counters X/Z=" + xCounter + "/" + zCounter;
                        context.getSource().sendFeedback(Text.literal(status));
                        return 1;
                    })));

            dispatcher.register(ClientCommandManager.literal("windcharge")
                    .then(ClientCommandManager.literal("start").executes(context -> {
                        timingActive = true;
                        timingTicks = 0;
                        if (targetCaptured && !sequenceRunning) {
                            beginLampSequence();
                        }
                        context.getSource().sendFeedback(Text.literal(
                                "Wind-charge timing started; each active lamp is held for "
                                        + intervalTicks + " ticks."));
                        return 1;
                    }))
                    .then(ClientCommandManager.literal("stop").executes(context -> {
                        timingActive = false;
                        context.getSource().sendFeedback(Text.literal(
                                "Wind-charge timing paused after " + timingTicks + " ticks."));
                        return 1;
                    }))
                    .then(ClientCommandManager.literal("interval")
                            .then(ClientCommandManager.argument("ticks", IntegerArgumentType.integer(1, 1200))
                                    .executes(context -> {
                                        intervalTicks = IntegerArgumentType.getInteger(context, "ticks");
                                        if (sequenceRunning) {
                                            ticksUntilNextLamp = intervalTicks;
                                        }
                                        context.getSource().sendFeedback(Text.literal(
                                                "Lamp interval set to " + intervalTicks + " ticks."));
                                        return 1;
                                    }))));
        });

        ClientTickEvents.END_CLIENT_TICK.register(tickClient -> {
            client = tickClient;
            if (!originLoaded) {
                loadOrigin();
                originLoaded = true;
            }
            if (timingActive) {
                timingTicks++;
            }
            if (sequenceRunning && timingActive) {
                ticksUntilNextLamp--;
                if (ticksUntilNextLamp <= 0) {
                    advanceLampSequence();
                }
            }
        });

        UseItemCallback.EVENT.register((player, world, hand) -> {
            ItemStack stack = player.getStackInHand(hand);
            if (world.isClient() && armed && isNamedNukeRod(stack)) {
                recordTarget(player.getX(), player.getZ());
            }
            return ActionResult.PASS;
        });
    }

    private static boolean isNamedNukeRod(ItemStack stack) {
        return stack.getName().getString().trim().equalsIgnoreCase("nuke");
    }

    private static void recordTarget(double playerX, double playerZ) {
        long targetX = (long) Math.floor(playerX);
        long targetZ = (long) Math.floor(playerZ);