AFNAN VAI

can you make a fabric 16.3 crosshair mod for me?

Create a client-side Fabric mod for Minecraft that implements a fully customizable crosshair. The mod must include a custom GUI configuration screen where players can change the crosshair's shape, size, thickness, and color. By default, the crosshair color should be black, but it must use negative/inverted blending logic (ONE_MINUS_DST_COLOR) so that when it goes over black textures or dark backgrounds, the crosshair dynamically turns white. Additionally, the vanilla attack cooldown indicator must be relocated to render directly beneath this custom crosshair instead of its default position.

Kodari AI
KodariOct 27 at 8:21 am 3
DynamicCrosshairMod
Client-side Fabric mod for Minecraft 1.6.3 that replaces the default crosshair with a fully customizable one. Features a GUI configuration screen allowing players to adjust crosshair shape, size, thickness, and color. The default color is black but uses ONE_MINUS_DST_COLOR blending for dynamic inversion, turning white over dark backgrounds. The vanilla attack cooldown indicator is relocated to render directly beneath the custom crosshair, maintaining combat feedback while preserving the enhanced visual customization.
  1. Set up the Fabric 26.3 client-only project and persistent crosshair settings.

  2. Add an owo-ui configuration screen for shape, size, thickness, and color.

  3. Replace vanilla crosshair rendering with an inverted-blend crosshair and position the attack cooldown indicator beneath it.

Created Custom Crosshair for Minecraft/Fabric 26.3 (assuming “16.3” meant “26.3”). It includes a ModMenu settings screen for crosshair shape, size, thickness, and color; the default is black. Inverted blending makes it appear white over black backgrounds. The vanilla crosshair-mode attack cooldown indicator is moved beneath the custom crosshair.

Open the settings through the mod’s Configure button in the Mods menu. Configuration is saved in config/customcrosshair.properties.

AFNAN VAI

i cant compile this, fix plz

Kodari AI
KodariOct 27 at 8:40 am 3
  1. Rebuild the empty project as a Fabric 26.3 client mod.

  2. Verify the HUD/render and owo-ui APIs against the mounted sources/docs.

  3. Add the configurable screen, inverted-blend crosshair, and repositioned cooldown indicator.

Rebuilt the empty workspace as a Fabric 26.3 client mod, including the Gradle setup, owo-ui configuration screen, and ModMenu integration. The custom crosshair defaults to black and uses GUI_INVERT blending; the crosshair-mode attack indicator renders beneath it.

Open Mods → Custom Crosshair → Configure to change its shape, size, thickness, and color. Configuration saves to config/customcrosshair.properties.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
11 452
src/client/java/com/kodari/customcrosshair/mixin/HudMixin.java
package com.kodari.customcrosshair.mixin;

import com.kodari.customcrosshair.CrosshairConfig;
import net.minecraft.client.AttackIndicatorStatus;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.debug.DebugScreenEntries;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.component.AttackRange;
import net.minecraft.world.phys.HitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(targets = "net.minecraft.client.gui.Hud")
public abstract class HudMixin {

    private static final Identifier ATTACK_INDICATOR_FULL = Identifier.withDefaultNamespace("hud/crosshair_attack_indicator_full");
    private static final Identifier ATTACK_INDICATOR_BACKGROUND = Identifier.withDefaultNamespace("hud/crosshair_attack_indicator_background");
    private static final Identifier ATTACK_INDICATOR_PROGRESS = Identifier.withDefaultNamespace("hud/crosshair_attack_indicator_progress");

    @Inject(
            method = "extractCrosshair(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
            at = @At("HEAD"),
            cancellable = true
    )
    private void customcrosshair$render(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker, CallbackInfo ci) {
        Minecraft minecraft = Minecraft.getInstance();
        if (minecraft.player == null
                || !minecraft.options.getCameraType().isFirstPerson()
                || minecraft.debugEntries.isCurrentlyEnabled(DebugScreenEntries.THREE_DIMENSIONAL_CROSSHAIR)) {
            return;
        }

        ci.cancel();
        graphics.nextStratum();

        int centerX = graphics.guiWidth() / 2;
        int centerY = graphics.guiHeight() / 2;
        int size = Math.clamp(CrosshairConfig.size, 1, 20);
        int thickness = Math.clamp(CrosshairConfig.thickness, 1, 10);
        int color = CrosshairConfig.color;

        switch (CrosshairConfig.shape) {
            case CROSS -> drawCrosshairCross(graphics, centerX, centerY, size, thickness, color);
            case DOT -> drawDot(graphics, centerX, centerY, size, thickness, color);
            case CIRCLE -> drawCircle(graphics, centerX, centerY, size, thickness, color);
        }

        if (minecraft.options.attackIndicator().get() == AttackIndicatorStatus.CROSSHAIR) {
            drawAttackIndicator(graphics, minecraft, centerY + size + thickness + 2);
        }
    }

    private static void drawCrosshairCross(GuiGraphicsExtractor graphics, int centerX, int centerY, int size, int thickness, int color) {
        int gap = thickness + 1;
        int halfThickness = thickness / 2;
        drawRect(graphics, centerX - halfThickness, centerY - gap - size, thickness, size, color);
        drawRect(graphics, centerX - halfThickness, centerY + gap, thickness, size, color);
        drawRect(graphics, centerX - gap - size, centerY - halfThickness, size, thickness, color);
        drawRect(graphics, centerX + gap, centerY - halfThickness, size, thickness, color);
    }

    private static void drawDot(GuiGraphicsExtractor graphics, int centerX, int centerY, int size, int thickness, int color) {
        int diameter = Math.max(1, Math.min(size, thickness * 2));
        drawRect(graphics, centerX - diameter / 2, centerY - diameter / 2, diameter, diameter, color);
    }

    private static void drawCircle(GuiGraphicsExtractor graphics, int centerX, int centerY, int radius, int thickness, int color) {
        int innerRadius = Math.max(0, radius - thickness);
        int outerSquared = radius * radius;
        int innerSquared = innerRadius * innerRadius;

        for (int y = -radius; y <= radius; y++) {
            int outerX = (int) Math.floor(Math.sqrt(outerSquared - y * y));
            if (innerRadius == 0 || y * y > innerSquared) {
                drawRect(graphics, centerX - outerX, centerY + y, outerX * 2 + 1, 1, color);
            } else {
                int innerX = (int) Math.floor(Math.sqrt(innerSquared - y * y));
                int sideWidth = outerX - innerX;
                if (sideWidth > 0) {
                    drawRect(graphics, centerX - outerX, centerY + y, sideWidth, 1, color);
                    drawRect(graphics, centerX + innerX + 1, centerY + y, sideWidth, 1, color);
                }
            }
        }
    }

    private static void drawRect(GuiGraphicsExtractor graphics, int x, int y, int width, int height, int color) {
        if ((color & 0x00FFFFFF) == 0) {
            graphics.fill(RenderPipelines.GUI_INVERT, x, y, x + width, y + height, 0xFFFFFFFF);
        } else {
            graphics.fill(x, y, x + width, y + height, color);
        }
    }

    private static void drawAttackIndicator(GuiGraphicsExtractor graphics, Minecraft minecraft, int y) {
        float attackStrength = minecraft.player.getAttackStrengthScale(0.0F);
        boolean renderFullIndicator = false;

        if (minecraft.crosshairPickEntity instanceof LivingEntity target && attackStrength >= 1.0F) {
            renderFullIndicator = minecraft.player.getCurrentItemAttackStrengthDelay() > 5.0F;
            renderFullIndicator &= target.isAlive();
            AttackRange attackRange = minecraft.player.getActiveItem().get(DataComponents.ATTACK_RANGE);
            HitResult hitResult = minecraft.hitResult;
            renderFullIndicator &= attackRange == null || hitResult != null && attackRange.isInRange(minecraft.player, hitResult.getLocation());
        }

        int x = graphics.guiWidth() / 2 - 8;
        if (renderFullIndicator) {
            graphics.blitSprite(RenderPipelines.CROSSHAIR, ATTACK_INDICATOR_FULL, x, y, 16, 16);
        } else if (attackStrength < 1.0F) {
            int progress = (int) (attackStrength * 17.0F);
            graphics.blitSprite(RenderPipelines.CROSSHAIR, ATTACK_INDICATOR_BACKGROUND, x, y, 16, 4);
            graphics.blitSprite(RenderPipelines.CROSSHAIR, ATTACK_INDICATOR_PROGRESS, 16, 4, 0, 0, x, y, progress, 4);
        }
    }
}