Дэнзи
📎 1 file 5,872 chars
📄
pasted-code-1795005733364.txt
txt 29 lines
▶
FastTeleportMacro — Client-Side Macro Mod for Minecraft 1.21.11 (Fabric)
Important: You do not need to type anything in the chat manually to trigger the macro, and the mod simply memorizes the return command /tppos [your coordinates] at the start without sending it — it will only type it into the chat at the very end.
The mod has no activation command that the player enters manually. To make everything work, you simply aim your crosshair at the target player and press a hotkey (default X). At that exact moment, the mod silently captures your current coordinates, saves the ready-made return command /tppos [your coordinates] in its memory for later, and starts sending all four commands to the chat so that the entire cycle from start to finish takes exactly 600 milliseconds (0.6 seconds).
This timing is based on each command taking exactly 200 milliseconds before moving to the next one, ensuring a strict execution order on the server without losing speed.
Detailed Workflow & Execution Steps
As soon as you aim at a player and press the hotkey, the client runs an automated sequence that completes in exactly 600 milliseconds:
1. Capturing, Building, and Memorizing the Final /tppos [coordinates] Command (Without Sending)
You do not need to open the chat, check your coordinates, or type any numbers manually. In the exact millisecond you aim at a player and press the X key (customizable in standard Minecraft Controls), the mod performs a strict preparation procedure for the final command:
• Capturing Exact Player Coordinates: The client-side mod directly reads your character's current position in the world and grabs three numerical axis values (for example: X = 100.45, Y = 50.00, Z = -200.12).
• Number Formatting (Cleaning Extra Digits): To prevent the command from becoming overly long with endless decimal places, the mod neatly rounds each number to two decimal places (or to a whole number if there is no fraction), using a standard dot as the decimal separator.
• Assembling the Ready-Made String: The mod takes the base text template /tppos  (including the trailing space after the command) and inserts the three captured values in order, separated by a single space: /tppos X Y Z.
• Saving to Memory Buffer (Without Sending): The result is a complete, ready-to-send string — for example, /tppos 100.45 50.0 -200.12. The mod stores this finished string in its memory. At this stage, it does not send it anywhere or open the chat — it simply holds it ready until the 600th millisecond.
2. Scanning the Target Under the Crosshair
At the same time as memorizing your coordinates, the mod checks the player you are aiming at when pressing the key and reads their unique identifier (UUID). If there is no player under your crosshair, the macro simply will not trigger and will not send anything to the chat.
3. Automated Command Dispatch (Each Command Takes 200 ms, Entire Cycle — Exactly 600 ms)
Once the return command is built and stored in memory and the target's UUID is captured, the mod starts a precise 600-millisecond timer. Each dispatch stage takes exactly 200 milliseconds (0.2 seconds) before triggering the next step — three steps of 200 ms each total exactly 600 ms (200 + 200 + 200 = 600 ms):
• Step 1 (0 ms — Sending the 1st Command, Takes 200 ms): The mod immediately sends /tppos 1744.42 3.02 3530.5. Exactly 200 ms is allocated for sending it and having the server register your move to the specified base coordinates.
• Step 2 (200 ms — Sending the 2nd Command, Takes 200 ms): As soon as the first 200 ms has passed, the mod sends /fly [Player UUID] false. The next 200 ms is dedicated to this step, forcibly disabling the target player's flight mode before they are moved.
• Step 3 (400 ms — Sending the 3rd Command, Takes 200 ms): Once 400 ms has elapsed from the start, the mod sends /tphere [Player UUID]. Another 200 ms covers summoning and teleporting the target player directly to you at the base coordinates (now unable to fly).
• Step 4 (600 ms — Inserting and Sending the 4th Command, End of Cycle): At the exact 600th millisecond, once the previous three commands of 200 ms each have fully executed, the mod retrieves the pre-assembled /tppos [your coordinates] string from its memory and sends it directly into the chat (for example, /tppos 100.45 50.0 -200.12). You are instantly returned to the exact same block and height from which you pressed the key, completing the 600-millisecond cycle.
Step-by-Step In-Game Chat Example
Imagine you are standing in a mine at coordinates X: 100.45, Y: 50.0, Z: -200.12, aiming your crosshair at a player named Grigori (UUID: 12345678-abcd-ef01-2345-6789abcdef01), and you simply press the X key without opening the chat.
The moment you press the key, the mod reads your axes, combines them into /tppos 100.45 50.0 -200.12, stores it in memory, and in exactly 600 milliseconds (allocating 200 ms per command) sends 4 lines to the chat:
1. [0 ms] /tppos 1744.42 3.02 3530.5 — you teleport to the base coordinates (stage takes 200 ms).
2. [200 ms] /fly 12345678-abcd-ef01-2345-6789abcdef01 false — Grigori's flight is disabled (stage takes 200 ms).
3. [400 ms] /tphere 12345678-abcd-ef01-2345-6789abcdef01 — Grigori is teleported to you at the base (stage takes 200 ms).
4. [600 ms] /tppos 100.45 50.0 -200.12 — at the exact 600th millisecond, the mod pulls the stored command with your coordinates from memory, sends it to the chat, and returns you back to the mine.
Overwriting Coordinates on Repeated Use
The mod's memory updates every time it triggers. If a minute later you move to another spot at coordinates -450.5 64.0 1200.8, aim at another player, and press X again, the old string in memory is overwritten. The mod reads your new X, Y, and Z axes, assembles the new /tppos -450.5 64.0 1200.8 command, and sends it to the chat at the 600th millisecond of the new cycle.
Kodari AI
KodariWed at 12:46 pm 3
TeleportPunisher
A client-side Fabric macro mod for Minecraft 1.21.11. When the player aims at a target and presses a hotkey (default X), the mod captures current coordinates, builds a return /tppos command, and stores it in memory without sending. It then executes a precise 600ms automated sequence: sends /tppos to base coordinates (0ms), disables target's flight via /fly UUID false (200ms), teleports target via /tphere UUID (400ms), and finally sends the stored return command (600ms). Each command takes exactly 200ms. Coordinates are rounded to two decimals. The stored command overwrites on each use.
  • Capture the target and return position when X is pressed.

  • Dispatch the four commands in order, cancelling pending steps after a disconnect.

Created the client-side macro with X as the default, rebindable key. It ignores presses while a sequence is running.

Commands are scheduled 200 ms apart, but exact timing and server execution order can’t be guaranteed. The server must provide the commands and grant you permission to use them.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 165
src/client/java/com/kodari/fastteleportmacro/FastTeleportMacroClient.java
package com.kodari.fastteleportmacro;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
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.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.EntityHitResult;
import org.lwjgl.glfw.GLFW;

public final class FastTeleportMacroClient implements ClientModInitializer {
    private final ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(task -> {
        Thread thread = new Thread(task, "fast-teleport-macro");
        thread.setDaemon(true);
        return thread;
    });
    private boolean active;

    @Override
    public void onInitializeClient() {
        KeyBinding.Category category = KeyBinding.Category.create(Identifier.of("fastteleportmacro", "controls"));
        KeyBinding key = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.fastteleportmacro.activate", GLFW.GLFW_KEY_X, category));
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (key.wasPressed()) {
                if (client.currentScreen == null) {
                    activate(client);
                }
            }
        });
    }

    private void activate(MinecraftClient client) {
        ClientPlayerEntity player = client.player;
        ClientPlayNetworkHandler handler = client.getNetworkHandler();
        if (active || player == null || handler == null
                || !(client.crosshairTarget instanceof EntityHitResult hit)
                || !(hit.getEntity() instanceof PlayerEntity target)) {
            return;
        }

        String uuid = target.getUuid().toString();
        String returnCommand = "tppos " + coordinate(player.getX()) + " "
                + coordinate(player.getY()) + " " + coordinate(player.getZ());
        active = true;
        handler.sendChatCommand("tppos 1744.42 3.02 3530.5");
        schedule(client, player, handler, "fly " + uuid + " false", 200, false);
        schedule(client, player, handler, "tphere " + uuid, 400, false);
        schedule(client, player, handler, returnCommand, 600, true);
    }

    private void schedule(MinecraftClient client, ClientPlayerEntity player,
                          ClientPlayNetworkHandler handler, String command, long delay, boolean last) {
        timer.schedule(() -> client.execute(() -> {
            try {
                if (client.player == player && client.getNetworkHandler() == handler) {
                    handler.sendChatCommand(command);
                }
            } finally {
                if (last) {
                    active = false;
                }
            }
        }), delay, TimeUnit.MILLISECONDS);
    }

    private static String coordinate(double value) {
        return BigDecimal.valueOf(value).setScale(2, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
    }
}