tech65pro

I want to create a Client-side Minecraft Mod for Fabric version 1.21.11 using Java.

Mod Idea:

Whenever a LivingEntity (Mob or Player) enters the player's hit range / crosshair target, that entity should automatically get a full highlight/outline effect (Glowing effect: setGlowing(true)). As soon as the entity leaves the hit range or crosshair, the glowing highlight should instantly disappear.

Requirements:

Use Fabric API and client-side tick events (ClientTickEvents.END_CLIENT_TICK).

Ensure memory efficiency so it doesn't cause lag by creating redundant objects or leaving old entities highlighted (previousTarget management).

Provide the full project structure, fabric.mod.json, build.gradle, and the complete Java code with proper imports for Fabric 1.21.11.

Keep it purely client-side."

Kodari AI
KodariOct 9 at 11:13 am 1
CrosshairGlowTargeting
A client-side Fabric mod for Minecraft 1.21.11 that automatically applies a glowing highlight effect to any living entity currently under the player's crosshair. Uses ClientTickEvents.END_CLIENT_TICK for efficient per-frame updates, tracks the previous targeted entity to instantly remove the glow when the target changes, and minimizes object allocation to prevent performance issues. Purely client-side with no server interaction required.
  1. Verify the 1.21.11 tick-event, client crosshair, hit-result, and entity glowing signatures.

  2. Create the client-only Fabric project files and implement target transitions, restoring any pre-existing glow when the target changes.

Created the client-only Fabric 1.21.11 project.

  • The client tick checks Minecraft’s current crosshair hit. Living entities are highlighted while targeted; the prior target’s original glow state is restored immediately when the target changes or disappears.

  • Client code is in src/client/java, and fabric.mod.json is client-only.

  • Project files include build.gradle, settings.gradle, gradle.properties, and fabric.mod.json.

tech65pro

make it both client or both it is not working why add customization button

Kodari AI
KodariOct 9 at 1:38 pm 2
  1. Find why the highlight isn’t working and make targeting reliable.

  2. Add a customization button with settings for the highlight behavior.

  1. Root cause: Entity.setGlowing(true) changes synchronized entity state, which the server can overwrite. I’m switching the outline to a client render decision, with the tick event only tracking the current target.

  2. After that, I’ll add the customization button and its settings.

Fixed the highlight by changing the client renderer’s outline decision instead of calling setGlowing(true). That avoids the server overwriting the glow flag; the outline now appears only for your current crosshair target and clears when you look away. It remains client-only and doesn’t require a server mod.

Added a Configure button through Mod Menu with saved toggles for highlighting players, mobs, and enabling the feature. Open Mods → Crosshair Glow → Configure.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
10 265
src/client/java/dev/kodari/crosshairglow/CrosshairGlowClient.java
package dev.kodari.crosshairglow;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
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.util.hit.EntityHitResult;

public final class CrosshairGlowClient implements ClientModInitializer {
    private static LivingEntity currentTarget;

    @Override
    public void onInitializeClient() {
        CrosshairGlowConfig.load();
        ClientTickEvents.END_CLIENT_TICK.register(CrosshairGlowClient::onEndClientTick);
    }

    private static void onEndClientTick(MinecraftClient client) {
        currentTarget = getLivingCrosshairTarget(client);
    }

    public static boolean isCurrentTarget(Entity entity) {
        return entity == currentTarget;
    }

    private static LivingEntity getLivingCrosshairTarget(MinecraftClient client) {
        if (!CrosshairGlowConfig.get().enabled || client.player == null || !(client.crosshairTarget instanceof EntityHitResult hitResult)) {
            return null;
        }

        Entity entity = hitResult.getEntity();
        if (entity instanceof PlayerEntity player && CrosshairGlowConfig.get().highlightPlayers) {
            return player;
        }
        if (entity instanceof MobEntity mob && CrosshairGlowConfig.get().highlightMobs) {
            return mob;
        }
        return null;
    }
}