Jerricks

make a toggleable aimbot for me that works from 10 blocks away from the nearest player/mob for 1.21.11

Kodari AI
KodariNov 15 at 9:32 pm 2
TargetAssist
TargetAssist is a Fabric mod for Minecraft 1.21.11 that provides a toggleable aimbot feature. When enabled, the mod automatically aims the player's crosshair at the nearest player or mob within a 10-block radius. The mod includes a keybind to toggle the aimbot on and off, with a visual indicator showing the current state. It respects game rules and configurable targeting preferences, ensuring smooth and accurate aiming assistance.

Plan:

  1. Add the Fabric 1.21.11 project scaffold and client entrypoint.

  2. Register a toggle key and, while enabled, aim at the nearest player or mob within 10 blocks.

  3. Add the keybind’s English label and category.

Added the client-side Fabric 1.21.11 mod. Press R to toggle aiming at the nearest player or mob within 10 blocks; an on-screen message shows whether it’s enabled. You can change the key in Options → Controls → Range Aim.

Jerricks

make it look at a random part of its hit boxe the closest part to wear im already looking and i must already be looking in their general direction

Kodari AI
KodariNov 15 at 9:37 pm 1

Plan:

  1. Inspect the current toggle/targeting logic.

  2. Verify the exact 1.21.11 Yarn APIs needed for hitbox aiming and direction checks.

  3. Update targeting to choose a random point in the hitbox, biased toward the point closest to the player’s current view, and require the target to be generally in view.

Updated the aimbot: it now only targets players or mobs within 10 blocks and within roughly 60° of your current view. For each target, it picks a random hitbox point near your existing aim and keeps that point while tracking the target.

Jerricks

so it picks a random point of the hitbox and not the same point each time?

Kodari AI
KodariNov 15 at 9:39 pm 1

Yes. It picks a random point when it starts tracking a target, then keeps aiming at that point while tracking. It doesn’t choose a new point every tick.

Jerricks

choose a new point every few ticks randomly

Kodari AI
KodariNov 15 at 9:43 pm 1

Plan:

  1. Read the current targeting code.

  2. Verify the hitbox and player-look APIs it uses.

  3. Change the random aim point on a randomized tick interval while preserving the current direction check.

It now picks a fresh random hitbox point every 3–8 ticks while tracking a target. The 10-block range and “already looking generally toward them” requirement are unchanged.

Jerricks

make it only work when im holding a charged spear with right click

Kodari AI
KodariNov 15 at 9:56 pm 1

The aim now needs to be actively using one of the vanilla spears; releasing right-click or switching items stops it and resets the tracked target.

Aiming now only runs while the mod is enabled and you’re actively right-clicking with a vanilla spear. Releasing right-click or switching away from the spear stops aiming and resets the tracked target; all seven spear materials are supported.

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

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.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypeFilter;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;

import java.util.Comparator;
import java.util.concurrent.ThreadLocalRandom;

public class RangeAimClient implements ClientModInitializer {
    private static final String MOD_ID = "rangeaim";
    private static final KeyBinding TOGGLE_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.rangeaim.toggle", 82, KeyBinding.Category.create(Identifier.of(MOD_ID, "aiming")))
    );

    private boolean enabled;
    private LivingEntity aimedTarget;
    private double aimPointX;
    private double aimPointY;
    private double aimPointZ;
    private int ticksUntilNextAimPoint;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (TOGGLE_KEY.wasPressed()) {
                enabled = !enabled;
                if (client.player != null) {
                    client.inGameHud.setOverlayMessage(
                            Text.translatable(enabled ? "message.rangeaim.enabled" : "message.rangeaim.disabled"),
                            false
                    );
                }
            }

            if (!enabled || client.player == null || client.world == null) {
                return;
            }

            var player = client.player;
            if (!player.isUsingItem() || !isSpear(player.getStackInHand(player.getActiveHand()))) {
                aimedTarget = null;
                return;
            }

            Vec3d lookDirection = player.getRotationVec(1.0f).normalize();
            LivingEntity target = client.world.getEntitiesByType(
                            TypeFilter.instanceOf(LivingEntity.class),
                            player.getBoundingBox().expand(10.0),
                            entity -> entity != player
                                    && (entity instanceof PlayerEntity || entity instanceof MobEntity)
                                    && player.squaredDistanceTo(entity) <= 100.0
                                    && isInGeneralDirection(player, entity, lookDirection)
                    )
                    .stream()
                    .min(Comparator.comparingDouble(player::squaredDistanceTo))
                    .orElse(null);

            if (target == null) {
                aimedTarget = null;
                return;
            }

            if (target != aimedTarget || --ticksUntilNextAimPoint <= 0) {
                chooseAimPoint(player, target, lookDirection);
                ticksUntilNextAimPoint = ThreadLocalRandom.current().nextInt(3, 9);
            }

            Box targetBox = target.getBoundingBox();
            Vec3d eyePosition = player.getEyePos();
            double dx = targetBox.minX + (targetBox.maxX - targetBox.minX) * aimPointX - eyePosition.x;
            double dy = targetBox.minY + (targetBox.maxY - targetBox.minY) * aimPointY - eyePosition.y;
            double dz = targetBox.minZ + (targetBox.maxZ - targetBox.minZ) * aimPointZ - eyePosition.z;
            double horizontalDistance = Math.sqrt(dx * dx + dz * dz);

            player.setYaw((float) (Math.toDegrees(Math.atan2(dz, dx)) - 90.0));
            player.setPitch((float) -Math.toDegrees(Math.atan2(dy, horizontalDistance)));
        });
    }

    private static boolean isSpear(ItemStack stack) {
        return stack.isOf(Items.WOODEN_SPEAR)
                || stack.isOf(Items.STONE_SPEAR)
                || stack.isOf(Items.COPPER_SPEAR)
                || stack.isOf(Items.IRON_SPEAR)
                || stack.isOf(Items.GOLDEN_SPEAR)
                || stack.isOf(Items.DIAMOND_SPEAR)
                || stack.isOf(Items.NETHERITE_SPEAR);
    }

    private static boolean isInGeneralDirection(PlayerEntity player, LivingEntity target, Vec3d lookDirection) {
        Vec3d eyePosition = player.getEyePos();
        Vec3d targetCenter = target.getBoundingBox().getCenter();
        double dx = targetCenter.x - eyePosition.x;
        double dy = targetCenter.y - eyePosition.y;
        double dz = targetCenter.z - eyePosition.z;
        double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
        return distance == 0.0 || (dx * lookDirection.x + dy * lookDirection.y + dz * lookDirection.z) / distance >= 0.5;
    }

    private void chooseAimPoint(PlayerEntity player, LivingEntity target, Vec3d lookDirection) {
        Box box = target.getBoundingBox();
        Vec3d eyePosition = player.getEyePos();
        Vec3d center = box.getCenter();
        double alongLook = Math.max(0.0,
                (center.x - eyePosition.x) * lookDirection.x
                        + (center.y - eyePosition.y) * lookDirection.y
                        + (center.z - eyePosition.z) * lookDirection.z);
        double anchorX = clamp(eyePosition.x + lookDirection.x * alongLook, box.minX, box.maxX);
        double anchorY = clamp(eyePosition.y + lookDirection.y * alongLook, box.minY, box.maxY);
        double anchorZ = clamp(eyePosition.z + lookDirection.z * alongLook, box.minZ, box.maxZ);
        ThreadLocalRandom random = ThreadLocalRandom.current();
        double pointX = clamp(anchorX + random.nextDouble(-0.25, 0.25) * (box.maxX - box.minX), box.minX, box.maxX);
        double pointY = clamp(anchorY + random.nextDouble(-0.25, 0.25) * (box.maxY - box.minY), box.minY, box.maxY);
        double pointZ = clamp(anchorZ + random.nextDouble(-0.25, 0.25) * (box.maxZ - box.minZ), box.minZ, box.maxZ);

        aimPointX = (pointX - box.minX) / (box.maxX - box.minX);
        aimPointY = (pointY - box.minY) / (box.maxY - box.minY);
        aimPointZ = (pointZ - box.minZ) / (box.maxZ - box.minZ);
        aimedTarget = target;
    }

    private static double clamp(double value, double min, double max) {
        return Math.max(min, Math.min(max, value));
    }
}