NotReflex4rll

سويلي مود يخلي اللاعب يسوي ستان سلام او اول ما يكتشف انو العدو الي مأيم عليه اللاعب ماسك الشيلد يمسك الـأكس و يكسر الشيلد ثم يضرب بالميس تلقائيا يعني لما تركبو في اللعبة وتروح لمود المينيو و تشوف اعدادات المود والي هي تخليه enabled ولا disabeled و تختار اي ميس يلاقيها في الهوتبار يعني الي فيها density ولا الي فيها breach ولا الي ما عليها تطويرة

Kodari AI
KodariSep 28 at 10:57 pm 2
ShieldBreakerAI
Adds a Minecraft mod that gives players an automatic combat AI toggleable from a mod menu. When enabled, the player automatically switches to an axe upon detecting an enemy holding a shield, breaks the shield, then instantly switches to a sword to attack. The mod menu allows enabling/disabling the feature and selecting which sword to use from the hotbar, prioritizing swords with Density or Breach enchantments, or any unenchanted sword.
  1. أبني مود Fabric بإعدادات داخل Mod Menu لتفعيل كسر الدرع التلقائي واختيار فئة الـMace: Density أو Breach أو بدون تطويرة.

  2. أضيف تسلسل الاستهداف: يضرب بالـAxe عند صدّ الخصم بالدرع، ثم يحوّل إلى الـMace المحدد ويهاجم.

[Generation stopped]

NotReflex4rll

ايش صار

Kodari AI
KodariSep 28 at 11:05 pm 2
  1. تجهيز مشروع Fabric 1.21.11 وإعدادات YACL/Mod Menu.

  2. تنفيذ منطق كشف الدرع والتبديل بين الفأس والـMace المناسب من الهوتبار.

  3. إضافة ملفات المود والـmanifest المطلوبة.

الرد السابق وقف بعد ما ولّد اسم المود ووصفه؛ ما أنشأ ملفات المشروع. هسه جهزت ملفات مشروع Fabric 1.21.11، وفيه إعدادات من Mod Menu لتفعيل المود واختيار الـMace حسب التطويرة الموجودة بالهوتبار: Density أو Breach أو بدون تطويرة.

لما تصوّب على كائن يصدّ بالدرع، المود يبدّل للفأس ويهاجمه، وبعد ما يتعطّل صدّ الدرع يبدّل للـMace المختار ويهاجم مرة. ملاحظة: الفأس عادةً يعطّل الدرع مؤقتًا، مو يدمّره كغرض.

NotReflex4rll

اتمنى انك لما قلتلك الميس يعني بعد ما يكسر الشيلد يضرب بالميس المحدد تطويرتها في الاعدادات

Kodari AI
KodariOct 19 at 6:42 pm 1

إي نعم، هذا المقصود بالضبط: يهاجم بالفأس أولًا، وبعد ما يتعطّل صدّ الدرع يبدّل للـMace المطابق لاختيارك بالإعدادات — Density أو Breach أو بدون تطويرة — ويضرب به. يبحث عن الـMace في الهوتبار.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
6 310
src/client/java/com/kodari/shieldbreakerai/ShieldBreaker.java
package com.kodari.shieldbreakerai;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.YetAnotherConfigLib;
import dev.isxander.yacl3.api.controller.EnumControllerBuilder;
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;

import java.nio.file.Path;
import java.util.UUID;

public class ShieldBreaker implements ClientModInitializer, ModMenuApi {
    private static final String MOD_ID = "shieldbreakerai";
    private static final ConfigClassHandler<ShieldBreaker> HANDLER = ConfigClassHandler.createBuilder(ShieldBreaker.class)
        .id(Identifier.of(MOD_ID, "config"))
        .serializer(config -> GsonConfigSerializerBuilder.create(config)
            .setPath(Path.of("config", MOD_ID + ".json"))
            .build())
        .build();

    @SerialEntry
    public boolean enabled = true;

    @SerialEntry
    public MaceChoice maceChoice = MaceChoice.DENSITY;

    private static UUID activeTarget;
    private static int axeSlot = -1;
    private static int maceSlot = -1;
    private static boolean shieldDisabled;
    private static boolean maceAttackDone;
    private static int ticksSinceAxeAttack;

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

    @Override
    public ConfigScreenFactory<?> getModConfigScreenFactory() {
        return ShieldBreaker::createConfigScreen;
    }

    private static Screen createConfigScreen(Screen parent) {
        return YetAnotherConfigLib.createBuilder()
            .title(Text.literal("Shield Breaker AI"))
            .save(HANDLER::save)
            .category(ConfigCategory.createBuilder()
                .name(Text.literal("إعدادات القتال"))
                .option(Option.<Boolean>createBuilder()
                    .name(Text.literal("تفعيل المود"))
                    .description(dev.isxander.yacl3.api.OptionDescription.of(
                        Text.literal("يبدّل إلى الفأس ضد الدرع ثم يهاجم بالـMace المختار.")))
                    .binding(true, () -> HANDLER.instance().enabled, value -> HANDLER.instance().enabled = value)
                    .controller(TickBoxControllerBuilder::create)
                    .build())
                .option(Option.<MaceChoice>createBuilder()
                    .name(Text.literal("الـMace المستخدم"))
                    .description(dev.isxander.yacl3.api.OptionDescription.of(
                        Text.literal("اختر نوع الـMace الذي يبحث عنه المود في الهوتبار.")))
                    .binding(MaceChoice.DENSITY, () -> HANDLER.instance().maceChoice,
                        value -> HANDLER.instance().maceChoice = value)
                    .controller(option -> EnumControllerBuilder.create(option).enumClass(MaceChoice.class))
                    .build())
                .build())
            .build()
            .generateScreen(parent);
    }

    private static void onEndClientTick(MinecraftClient client) {
        if (!HANDLER.instance().enabled || client.player == null || client.world == null || client.interactionManager == null
            || client.crosshairTarget == null || client.crosshairTarget.getType() != HitResult.Type.ENTITY
            || !(client.crosshairTarget instanceof EntityHitResult hit)
            || !(hit.getEntity() instanceof LivingEntity target)
            || target == client.player) {
            resetSequence();
            return;
        }

        if (activeTarget == null || !activeTarget.equals(target.getUuid())) {
            resetSequence();
            if (!isShieldBlocking(target)) {
                return;
            }

            axeSlot = findAxeSlot(client.player.getInventory());
            maceSlot = findMaceSlot(client, HANDLER.instance().maceChoice);
            if (axeSlot < 0 || maceSlot < 0) {
                resetSequence();
                return;
            }
            activeTarget = target.getUuid();
            ticksSinceAxeAttack = 9;
        }

        if (!shieldDisabled) {
            if (!isShieldBlocking(target)) {
                shieldDisabled = true;
            } else {
                ticksSinceAxeAttack++;
                if (ticksSinceAxeAttack >= 10 && client.player.getAttackCooldownProgress(0.5F) >= 1.0F) {
                    client.player.getInventory().setSelectedSlot(axeSlot);
                    client.interactionManager.attackEntity(client.player, target);
                    client.player.swingHand(Hand.MAIN_HAND);
                    ticksSinceAxeAttack = 0;
                }
                return;
            }
        }

        if (!maceAttackDone && client.player.getAttackCooldownProgress(0.5F) >= 1.0F) {
            client.player.getInventory().setSelectedSlot(maceSlot);
            client.interactionManager.attackEntity(client.player, target);
            client.player.swingHand(Hand.MAIN_HAND);
            maceAttackDone = true;
        }
    }

    private static boolean isShieldBlocking(LivingEntity target) {
        return target.isBlocking() && target.getActiveItem().isOf(Items.SHIELD);
    }

    private static int findAxeSlot(PlayerInventory inventory) {
        for (int slot = 0; slot < PlayerInventory.HOTBAR_SIZE; slot++) {
            if (inventory.getStack(slot).getItem() instanceof AxeItem) {
                return slot;
            }
        }
        return -1;
    }

    private static int findMaceSlot(MinecraftClient client, MaceChoice choice) {
        Registry<Enchantment> enchantments = client.world.getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT);
        RegistryEntry<Enchantment> density = enchantments.getOptional(Enchantments.DENSITY).orElse(null);
        RegistryEntry<Enchantment> breach = enchantments.getOptional(Enchantments.BREACH).orElse(null);

        for (int slot = 0; slot < PlayerInventory.HOTBAR_SIZE; slot++) {
            ItemStack stack = client.player.getInventory().getStack(slot);
            if (!stack.isOf(Items.MACE)) {
                continue;
            }

            boolean matches = switch (choice) {
                case DENSITY -> density != null && EnchantmentHelper.getLevel(density, stack) > 0;
                case BREACH -> breach != null && EnchantmentHelper.getLevel(breach, stack) > 0;
                case UNENCHANTED -> !stack.hasEnchantments();
            };
            if (matches) {
                return slot;
            }
        }
        return -1;
    }

    private static void resetSequence() {
        activeTarget = null;
        axeSlot = -1;
        maceSlot = -1;
        shieldDisabled = false;
        maceAttackDone = false;
        ticksSinceAxeAttack = 0;
    }

    public enum MaceChoice {
        DENSITY,
        BREACH,
        UNENCHANTED;

        @Override
        public String toString() {
            return switch (this) {
                case DENSITY -> "Density";
                case BREACH -> "Breach";
                case UNENCHANTED -> "بدون تطويرة";