Whoisyou

Make an auto tnt cart when u press v it places a rail then a tnt cart then it switches to crossbow or bow but it doesn't shoot you have to shoot manually

Kodari AI
KodariNov 5 at 4:30 pm 2
AutoTntCartLauncher
Creates an auto TNT cart system for Minecraft Fabric 1.21.1. Pressing V places a rail, spawns a TNT minecart on it, then automatically switches the player's held item to a crossbow or bow for manual shooting. The crossbow/bow is equipped but does not auto-fire; the player must aim and shoot manually to launch the TNT cart. Includes keybind registration, inventory item switching, and rail/minecart placement logic.
  • Add a client keybind on V.

  • On press, select and place a rail, then a TNT minecart, then switch to the first bow/crossbow without firing.

  • Create the Fabric entrypoint and metadata for Minecraft 1.21.11.

Added the client-side Auto TNT Cart mod. Press V while targeting the top of a block with a rail and TNT minecart in your hotbar: it places the rail, places the cart, then selects a crossbow (or a bow if no crossbow is in the hotbar). It won’t fire—the shot is manual.

Whoisyou

Let it have delay configurable and changeable keybind

Kodari AI
KodariNov 5 at 4:35 pm 2
  1. Make the placement delay configurable.

  2. Keep V changeable through Minecraft’s Controls keybind settings.

  • The rail-to-cart delay defaults to 4 ticks. After launching once, edit config/autotntcart.properties and set delayTicks to 0–200, then restart the game.

  • The keybind defaults to V and can be changed in Options → Controls → Key Binds → Misc → Place TNT Cart. It still only selects the bow or crossbow; you shoot manually.

Whoisyou

How to download this?

Kodari AI
KodariNov 5 at 4:35 pm 1
  1. Click Compile in the top bar (on phone: ⋮ → Compile Project).

  2. In the window, click Compile.

  3. When it succeeds, click Download on the build, or Download autotntcart.jar in the chat.

Whoisyou

Remame this to Skyboxes

Kodari AI
KodariNov 5 at 4:37 pm 1

Renamed the mod’s displayed name to Skyboxes and its build artifact to skyboxes.jar. The TNT-cart functionality is unchanged.

Whoisyou

It doesn't work

Kodari AI
KodariNov 5 at 5:03 pm 2

Fixed the activation check: V now places the rail on top of the block you’re pointing at, even if your crosshair hits its side rather than its top face. The configured delay, TNT cart placement, and manual shooting behavior are unchanged.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
7 258
src/client/java/com/kodari/autotntcart/AutoTntCartClient.java
package com.kodari.autotntcart;

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.option.KeyBinding;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.glfw.GLFW;

public class AutoTntCartClient implements ClientModInitializer {
    private static final KeyBinding ACTIVATE = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.autotntcart.activate", GLFW.GLFW_KEY_V, KeyBinding.Category.MISC)
    );
    private static BlockPos pendingRailPos;
    private static int pendingCartSlot;
    private static int pendingWeaponSlot;
    private static int ticksUntilCart;

    @Override
    public void onInitializeClient() {
        AutoTntCartConfig.load();
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (ACTIVATE.wasPressed() && pendingRailPos == null) {
                placeCartSequence(client);
            }
            tickCartSequence(client);
        });
    }

    private static void placeCartSequence(MinecraftClient client) {
        if (client.player == null || client.interactionManager == null
                || !(client.crosshairTarget instanceof BlockHitResult target)
                || target.getType() != HitResult.Type.BLOCK) {
            return;
        }

        PlayerInventory inventory = client.player.getInventory();
        int railSlot = findHotbarSlot(inventory, Items.RAIL);
        int cartSlot = findHotbarSlot(inventory, Items.TNT_MINECART);
        if (railSlot < 0 || cartSlot < 0) {
            return;
        }

        BlockPos supportPos = target.getBlockPos();
        BlockPos railPos = supportPos.up();
        BlockHitResult supportHit = new BlockHitResult(
                Vec3d.ofCenter(supportPos, 1.0),
                Direction.UP,
                supportPos,
                false
        );
        int weaponSlot = findHotbarSlot(inventory, Items.CROSSBOW);
        if (weaponSlot < 0) {
            weaponSlot = findHotbarSlot(inventory, Items.BOW);
        }

        inventory.setSelectedSlot(railSlot);
        client.interactionManager.interactBlock(client.player, Hand.MAIN_HAND, supportHit);

        pendingRailPos = railPos;
        pendingCartSlot = cartSlot;
        pendingWeaponSlot = weaponSlot;
        ticksUntilCart = AutoTntCartConfig.delayTicks();
    }

    private static void tickCartSequence(MinecraftClient client) {
        if (pendingRailPos == null) {
            return;
        }
        if (ticksUntilCart > 0) {
            ticksUntilCart--;
            return;
        }
        if (client.player == null || client.interactionManager == null) {
            clearPendingSequence();
            return;
        }

        PlayerInventory inventory = client.player.getInventory();
        inventory.setSelectedSlot(pendingCartSlot);
        BlockHitResult railHit = new BlockHitResult(
                Vec3d.ofCenter(pendingRailPos, 1.0),
                Direction.UP,
                pendingRailPos,
                false
        );
        client.interactionManager.interactBlock(client.player, Hand.MAIN_HAND, railHit);

        if (pendingWeaponSlot >= 0) {
            inventory.setSelectedSlot(pendingWeaponSlot);
        }
        clearPendingSequence();
    }

    private static void clearPendingSequence() {
        pendingRailPos = null;
        pendingCartSlot = 0;
        pendingWeaponSlot = -1;
        ticksUntilCart = 0;
    }

    private static int findHotbarSlot(PlayerInventory inventory, Item item) {
        for (int slot = 0; slot < 9; slot++) {
            if (inventory.getStack(slot).isOf(item)) {
                return slot;
            }
        }
        return -1;
    }
}