Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Часть функционала AutoCart | Rich 1.21.11

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
12 Фев 2024
Сообщения
18
Реакции
0
Выберите загрузчик игры
  1. Fabric
Всем привет!
сливаю функцию которую нигде не видел, а именно AutoCart, предназначена для пвп вида "cart" -- вагонетки с тнт. Суть в том что ты ставишь рельсу, на нее вагонетку с тнт и стреляешь луком на воспламенение взрывая вагонетку.

Режимы работы
Pre-rale -- ставит рельсу, стреляет на нее, и до падения стрелы ставит вагонетку с тнт
Insta-cart -- сначала стреляет из лука, после рассчитывая траекторию падения стрелы ставит рельсу и на нее вагонетку
Сайлет -- ваша камера не будет дергаться во время выполнения функции

SS -- Не думаю что сс нужен, посмотрите что такое cart pvp.


TNTMinecraft:
Expand Collapse Copy
package rich.modules.impl.combat;

import antidaunleak.api.annotation.Native;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.util.InputUtil;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import org.lwjgl.glfw.GLFW;
import rich.events.api.EventHandler;
import rich.events.api.types.EventType;
import rich.events.impl.KeyEvent;
import rich.events.impl.RotationUpdateEvent;
import rich.events.impl.TickEvent;
import rich.modules.impl.combat.aura.Angle;
import rich.modules.impl.combat.aura.AngleConfig;
import rich.modules.impl.combat.aura.AngleConnection;
import rich.modules.impl.combat.aura.impl.LinearConstructor;
import rich.modules.module.ModuleStructure;
import rich.modules.module.category.ModuleCategory;
import rich.modules.module.setting.implement.BindSetting;
import rich.modules.module.setting.implement.BooleanSetting;
import rich.modules.module.setting.implement.SelectSetting;
import rich.screens.clickgui.impl.settingsrender.BindComponent;
import rich.util.inventory.InventoryUtils;
import rich.util.math.TaskPriority;

@Getter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class TNTMinecart extends ModuleStructure {

    final BindSetting activateKey = new BindSetting("Активация", "Клавиша для активации");
    final SelectSetting modeSetting = new SelectSetting("Режим", "Режим работы")
            .value("Pre-Rail", "Insta-Cart")
            .selected("Pre-Rail");
    final BooleanSetting silentRotation = new BooleanSetting("Сайлент", "Сайлент ротация (камера не дергается)").setValue(false);

    enum State {
        IDLE,
        PLACING_RAIL,
        DRAWING_BOW,
        SHOOTING,
        PLACING_MINECART,
        INSTA_DRAWING_BOW,
        INSTA_SHOOTING,
        INSTA_PLACING_RAIL,
        INSTA_PLACING_MINECART,
        DONE
    }

    State currentState = State.IDLE;
    int actionTimer = 0;
    int originalSlot = 0;
    int railSlot = -1;
    int bowSlot = -1;
    int tntMinecartSlot = -1;
    BlockHitResult targetHit = null;
    BlockPos arrowLandPos = null;
    boolean bowStarted = false;
    float originalPitch = 0;
    float originalYaw = 0;

    public TNTMinecart() {
        super("Auto Cart", "Auto Cart", ModuleCategory.LEGIT);
        settings(activateKey, modeSetting, silentRotation);
    }

    @Override
    public void deactivate() {
        reset();
        AngleConnection.INSTANCE.startReturning();
    }

    @EventHandler
    public void onRotationUpdate(RotationUpdateEvent e) {
        if (mc.player == null || mc.world == null) return;
        if (currentState == State.IDLE) return;
        
        if (e.getType() == EventType.PRE && silentRotation.isValue()) {
            float targetPitch = originalPitch - 12.0f;
            
            boolean shouldRotate = false;
            if (modeSetting.isSelected("Pre-Rail")) {
                shouldRotate = (currentState == State.SHOOTING && actionTimer >= 4);
            } else {
                shouldRotate = (currentState == State.INSTA_SHOOTING && actionTimer >= 4);
            }
            
            if (shouldRotate) {
                Angle targetAngle = new Angle(mc.player.getYaw(), targetPitch);
                AngleConfig config = new AngleConfig(new LinearConstructor(), true, true);
                
                AngleConnection.INSTANCE.rotateTo(
                    targetAngle,
                    1,
                    config,
                    TaskPriority.HIGH_IMPORTANCE_1,
                    this
                );
            }
        }
    }

    @EventHandler
    @Native(type = Native.Type.VMProtectBeginMutation)
    public void onKey(KeyEvent e) {
        if (mc.player == null || mc.world == null) return;
        if (mc.currentScreen != null) return;
        if (currentState != State.IDLE) return;
        if (e.action() != 1) return;

        int bindKey = activateKey.getKey();
        int bindType = activateKey.getType();

        if (bindKey == GLFW.GLFW_KEY_UNKNOWN || bindKey == -1) return;

        boolean matches = false;

        if (bindType == 2) {
            if (bindKey == BindComponent.MIDDLE_MOUSE_BIND
                    && e.type() == InputUtil.Type.MOUSE
                    && e.key() == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) {
                matches = true;
            }
        } else if (bindType == 0 && e.type() == InputUtil.Type.MOUSE) {
            matches = e.key() == bindKey;
        } else if (bindType == 1 && e.type() == InputUtil.Type.KEYSYM) {
            matches = e.key() == bindKey;
        }

        if (matches) {
            execute();
        }
    }

    @EventHandler
    @Native(type = Native.Type.VMProtectBeginUltra)
    public void onTick(TickEvent e) {
        if (mc.player == null || mc.world == null) return;

        if (currentState != State.IDLE) {
            processTick();
        }
    }

    @Native(type = Native.Type.VMProtectBeginMutation)
    private void execute() {
        PlayerInventory inventory = mc.player.getInventory();

        tntMinecartSlot = findTNTMinecart(inventory);
        railSlot = findRail(inventory);
        bowSlot = findFlameBow(inventory);

        if (tntMinecartSlot == -1 || railSlot == -1 || bowSlot == -1) {
            return;
        }

        HitResult hit = mc.crosshairTarget;
        if (hit == null || hit.getType() != HitResult.Type.BLOCK) {
            return;
        }

        targetHit = (BlockHitResult) hit;
        originalSlot = inventory.getSelectedSlot();
        originalPitch = mc.player.getPitch();
        originalYaw = mc.player.getYaw();
        actionTimer = 0;
        bowStarted = false;

        if (modeSetting.isSelected("Pre-Rail")) {
            currentState = State.PLACING_RAIL;
        } else {
            currentState = State.INSTA_DRAWING_BOW;
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processTick() {
        if (mc.player == null || mc.interactionManager == null || mc.world == null) {
            reset();
            return;
        }

        PlayerInventory inventory = mc.player.getInventory();
        actionTimer++;

        try {
            if (modeSetting.isSelected("Pre-Rail")) {
                processPreRailMode();
            } else {
                processInstaCartMode();
            }
        } catch (Exception ex) {
            reset();
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processPreRailMode() {
        switch (currentState) {
            case PLACING_RAIL:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(railSlot);
                    mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, targetHit);
                    currentState = State.DRAWING_BOW;
                    actionTimer = 0;
                }
                break;

            case DRAWING_BOW:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(bowSlot);
                    mc.options.useKey.setPressed(true);
                    bowStarted = true;
                    currentState = State.SHOOTING;
                    actionTimer = 0;
                }
                break;

            case SHOOTING:
                if (actionTimer == 5) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(mc.player.getPitch() - 12.0f);
                    }
                } else if (actionTimer == 6) {
                    if (bowStarted) {
                        mc.options.useKey.setPressed(false);
                        bowStarted = false;
                    }
                } else if (actionTimer >= 7) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(originalPitch);
                        mc.player.setYaw(originalYaw);
                    }
                    currentState = State.PLACING_MINECART;
                    actionTimer = 0;
                }
                break;

            case PLACING_MINECART:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(tntMinecartSlot);
                    mc.options.useKey.setPressed(true);
                } else if (actionTimer == 2) {
                    mc.options.useKey.setPressed(false);
                    currentState = State.DONE;
                    actionTimer = 0;
                }
                break;

            case DONE:
                if (actionTimer >= 1) {
                    InventoryUtils.selectSlot(originalSlot);
                    reset();
                }
                break;
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processInstaCartMode() {
        switch (currentState) {
            case INSTA_DRAWING_BOW:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(bowSlot);
                    mc.options.useKey.setPressed(true);
                    bowStarted = true;
                    currentState = State.INSTA_SHOOTING;
                    actionTimer = 0;
                }
                break;

            case INSTA_SHOOTING:
                if (actionTimer == 5) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(mc.player.getPitch() - 12.0f);
                    }
                } else if (actionTimer == 6) {
                    if (bowStarted) {
                        mc.options.useKey.setPressed(false);
                        bowStarted = false;
                    }
                } else if (actionTimer >= 7) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(originalPitch);
                        mc.player.setYaw(originalYaw);
                    }
                    currentState = State.INSTA_PLACING_RAIL;
                    actionTimer = 0;
                }
                break;

            case INSTA_PLACING_RAIL:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(railSlot);
                    mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, targetHit);
                    currentState = State.INSTA_PLACING_MINECART;
                    actionTimer = 0;
                }
                break;

            case INSTA_PLACING_MINECART:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(tntMinecartSlot);
                    mc.options.useKey.setPressed(true);
                } else if (actionTimer == 2) {
                    mc.options.useKey.setPressed(false);
                    currentState = State.DONE;
                    actionTimer = 0;
                }
                break;

            case DONE:
                if (actionTimer >= 1) {
                    InventoryUtils.selectSlot(originalSlot);
                    reset();
                }
                break;
        }
    }

    private void reset() {
        if (bowStarted && mc.options != null) {
            mc.options.useKey.setPressed(false);
        }
        currentState = State.IDLE;
        actionTimer = 0;
        bowStarted = false;
        targetHit = null;
        arrowLandPos = null;
        originalPitch = 0;
        originalYaw = 0;
    }

    private int findTNTMinecart(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            if (stack.getItem() == Items.TNT_MINECART) {
                return i;
            }
        }
        return -1;
    }

    private int findRail(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            String itemId = Registries.ITEM.getId(stack.getItem()).toString();
            if (itemId.contains("rail")) {
                return i;
            }
        }
        return -1;
    }

    private int findFlameBow(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            if (stack.getItem() == Items.BOW) {
                ItemEnchantmentsComponent enchantments = stack.getOrDefault(
                        DataComponentTypes.ENCHANTMENTS,
                        ItemEnchantmentsComponent.DEFAULT
                );

                if (!enchantments.isEmpty()) {
                    var enchantmentRegistry = mc.world.getRegistryManager()
                            .getOrThrow(RegistryKeys.ENCHANTMENT);
                    var flame = enchantmentRegistry.get(Enchantments.FLAME);

                    if (flame != null) {
                        var flameEntry = enchantmentRegistry.getEntry(flame);
                        if (enchantments.getLevel(flameEntry) > 0) {
                            return i;
                        }
                    }
                }
            }
        }
        return -1;
    }
}
 
Всем привет!
сливаю функцию которую нигде не видел, а именно AutoCart, предназначена для пвп вида "cart" -- вагонетки с тнт. Суть в том что ты ставишь рельсу, на нее вагонетку с тнт и стреляешь луком на воспламенение взрывая вагонетку.

Режимы работы
Pre-rale -- ставит рельсу, стреляет на нее, и до падения стрелы ставит вагонетку с тнт
Insta-cart -- сначала стреляет из лука, после рассчитывая траекторию падения стрелы ставит рельсу и на нее вагонетку
Сайлет -- ваша камера не будет дергаться во время выполнения функции

SS -- Не думаю что сс нужен, посмотрите что такое cart pvp.


TNTMinecraft:
Expand Collapse Copy
package rich.modules.impl.combat;

import antidaunleak.api.annotation.Native;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.util.InputUtil;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import org.lwjgl.glfw.GLFW;
import rich.events.api.EventHandler;
import rich.events.api.types.EventType;
import rich.events.impl.KeyEvent;
import rich.events.impl.RotationUpdateEvent;
import rich.events.impl.TickEvent;
import rich.modules.impl.combat.aura.Angle;
import rich.modules.impl.combat.aura.AngleConfig;
import rich.modules.impl.combat.aura.AngleConnection;
import rich.modules.impl.combat.aura.impl.LinearConstructor;
import rich.modules.module.ModuleStructure;
import rich.modules.module.category.ModuleCategory;
import rich.modules.module.setting.implement.BindSetting;
import rich.modules.module.setting.implement.BooleanSetting;
import rich.modules.module.setting.implement.SelectSetting;
import rich.screens.clickgui.impl.settingsrender.BindComponent;
import rich.util.inventory.InventoryUtils;
import rich.util.math.TaskPriority;

@Getter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class TNTMinecart extends ModuleStructure {

    final BindSetting activateKey = new BindSetting("Активация", "Клавиша для активации");
    final SelectSetting modeSetting = new SelectSetting("Режим", "Режим работы")
            .value("Pre-Rail", "Insta-Cart")
            .selected("Pre-Rail");
    final BooleanSetting silentRotation = new BooleanSetting("Сайлент", "Сайлент ротация (камера не дергается)").setValue(false);

    enum State {
        IDLE,
        PLACING_RAIL,
        DRAWING_BOW,
        SHOOTING,
        PLACING_MINECART,
        INSTA_DRAWING_BOW,
        INSTA_SHOOTING,
        INSTA_PLACING_RAIL,
        INSTA_PLACING_MINECART,
        DONE
    }

    State currentState = State.IDLE;
    int actionTimer = 0;
    int originalSlot = 0;
    int railSlot = -1;
    int bowSlot = -1;
    int tntMinecartSlot = -1;
    BlockHitResult targetHit = null;
    BlockPos arrowLandPos = null;
    boolean bowStarted = false;
    float originalPitch = 0;
    float originalYaw = 0;

    public TNTMinecart() {
        super("Auto Cart", "Auto Cart", ModuleCategory.LEGIT);
        settings(activateKey, modeSetting, silentRotation);
    }

    @Override
    public void deactivate() {
        reset();
        AngleConnection.INSTANCE.startReturning();
    }

    @EventHandler
    public void onRotationUpdate(RotationUpdateEvent e) {
        if (mc.player == null || mc.world == null) return;
        if (currentState == State.IDLE) return;
       
        if (e.getType() == EventType.PRE && silentRotation.isValue()) {
            float targetPitch = originalPitch - 12.0f;
           
            boolean shouldRotate = false;
            if (modeSetting.isSelected("Pre-Rail")) {
                shouldRotate = (currentState == State.SHOOTING && actionTimer >= 4);
            } else {
                shouldRotate = (currentState == State.INSTA_SHOOTING && actionTimer >= 4);
            }
           
            if (shouldRotate) {
                Angle targetAngle = new Angle(mc.player.getYaw(), targetPitch);
                AngleConfig config = new AngleConfig(new LinearConstructor(), true, true);
               
                AngleConnection.INSTANCE.rotateTo(
                    targetAngle,
                    1,
                    config,
                    TaskPriority.HIGH_IMPORTANCE_1,
                    this
                );
            }
        }
    }

    @EventHandler
    @Native(type = Native.Type.VMProtectBeginMutation)
    public void onKey(KeyEvent e) {
        if (mc.player == null || mc.world == null) return;
        if (mc.currentScreen != null) return;
        if (currentState != State.IDLE) return;
        if (e.action() != 1) return;

        int bindKey = activateKey.getKey();
        int bindType = activateKey.getType();

        if (bindKey == GLFW.GLFW_KEY_UNKNOWN || bindKey == -1) return;

        boolean matches = false;

        if (bindType == 2) {
            if (bindKey == BindComponent.MIDDLE_MOUSE_BIND
                    && e.type() == InputUtil.Type.MOUSE
                    && e.key() == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) {
                matches = true;
            }
        } else if (bindType == 0 && e.type() == InputUtil.Type.MOUSE) {
            matches = e.key() == bindKey;
        } else if (bindType == 1 && e.type() == InputUtil.Type.KEYSYM) {
            matches = e.key() == bindKey;
        }

        if (matches) {
            execute();
        }
    }

    @EventHandler
    @Native(type = Native.Type.VMProtectBeginUltra)
    public void onTick(TickEvent e) {
        if (mc.player == null || mc.world == null) return;

        if (currentState != State.IDLE) {
            processTick();
        }
    }

    @Native(type = Native.Type.VMProtectBeginMutation)
    private void execute() {
        PlayerInventory inventory = mc.player.getInventory();

        tntMinecartSlot = findTNTMinecart(inventory);
        railSlot = findRail(inventory);
        bowSlot = findFlameBow(inventory);

        if (tntMinecartSlot == -1 || railSlot == -1 || bowSlot == -1) {
            return;
        }

        HitResult hit = mc.crosshairTarget;
        if (hit == null || hit.getType() != HitResult.Type.BLOCK) {
            return;
        }

        targetHit = (BlockHitResult) hit;
        originalSlot = inventory.getSelectedSlot();
        originalPitch = mc.player.getPitch();
        originalYaw = mc.player.getYaw();
        actionTimer = 0;
        bowStarted = false;

        if (modeSetting.isSelected("Pre-Rail")) {
            currentState = State.PLACING_RAIL;
        } else {
            currentState = State.INSTA_DRAWING_BOW;
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processTick() {
        if (mc.player == null || mc.interactionManager == null || mc.world == null) {
            reset();
            return;
        }

        PlayerInventory inventory = mc.player.getInventory();
        actionTimer++;

        try {
            if (modeSetting.isSelected("Pre-Rail")) {
                processPreRailMode();
            } else {
                processInstaCartMode();
            }
        } catch (Exception ex) {
            reset();
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processPreRailMode() {
        switch (currentState) {
            case PLACING_RAIL:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(railSlot);
                    mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, targetHit);
                    currentState = State.DRAWING_BOW;
                    actionTimer = 0;
                }
                break;

            case DRAWING_BOW:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(bowSlot);
                    mc.options.useKey.setPressed(true);
                    bowStarted = true;
                    currentState = State.SHOOTING;
                    actionTimer = 0;
                }
                break;

            case SHOOTING:
                if (actionTimer == 5) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(mc.player.getPitch() - 12.0f);
                    }
                } else if (actionTimer == 6) {
                    if (bowStarted) {
                        mc.options.useKey.setPressed(false);
                        bowStarted = false;
                    }
                } else if (actionTimer >= 7) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(originalPitch);
                        mc.player.setYaw(originalYaw);
                    }
                    currentState = State.PLACING_MINECART;
                    actionTimer = 0;
                }
                break;

            case PLACING_MINECART:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(tntMinecartSlot);
                    mc.options.useKey.setPressed(true);
                } else if (actionTimer == 2) {
                    mc.options.useKey.setPressed(false);
                    currentState = State.DONE;
                    actionTimer = 0;
                }
                break;

            case DONE:
                if (actionTimer >= 1) {
                    InventoryUtils.selectSlot(originalSlot);
                    reset();
                }
                break;
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processInstaCartMode() {
        switch (currentState) {
            case INSTA_DRAWING_BOW:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(bowSlot);
                    mc.options.useKey.setPressed(true);
                    bowStarted = true;
                    currentState = State.INSTA_SHOOTING;
                    actionTimer = 0;
                }
                break;

            case INSTA_SHOOTING:
                if (actionTimer == 5) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(mc.player.getPitch() - 12.0f);
                    }
                } else if (actionTimer == 6) {
                    if (bowStarted) {
                        mc.options.useKey.setPressed(false);
                        bowStarted = false;
                    }
                } else if (actionTimer >= 7) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(originalPitch);
                        mc.player.setYaw(originalYaw);
                    }
                    currentState = State.INSTA_PLACING_RAIL;
                    actionTimer = 0;
                }
                break;

            case INSTA_PLACING_RAIL:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(railSlot);
                    mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, targetHit);
                    currentState = State.INSTA_PLACING_MINECART;
                    actionTimer = 0;
                }
                break;

            case INSTA_PLACING_MINECART:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(tntMinecartSlot);
                    mc.options.useKey.setPressed(true);
                } else if (actionTimer == 2) {
                    mc.options.useKey.setPressed(false);
                    currentState = State.DONE;
                    actionTimer = 0;
                }
                break;

            case DONE:
                if (actionTimer >= 1) {
                    InventoryUtils.selectSlot(originalSlot);
                    reset();
                }
                break;
        }
    }

    private void reset() {
        if (bowStarted && mc.options != null) {
            mc.options.useKey.setPressed(false);
        }
        currentState = State.IDLE;
        actionTimer = 0;
        bowStarted = false;
        targetHit = null;
        arrowLandPos = null;
        originalPitch = 0;
        originalYaw = 0;
    }

    private int findTNTMinecart(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            if (stack.getItem() == Items.TNT_MINECART) {
                return i;
            }
        }
        return -1;
    }

    private int findRail(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            String itemId = Registries.ITEM.getId(stack.getItem()).toString();
            if (itemId.contains("rail")) {
                return i;
            }
        }
        return -1;
    }

    private int findFlameBow(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            if (stack.getItem() == Items.BOW) {
                ItemEnchantmentsComponent enchantments = stack.getOrDefault(
                        DataComponentTypes.ENCHANTMENTS,
                        ItemEnchantmentsComponent.DEFAULT
                );

                if (!enchantments.isEmpty()) {
                    var enchantmentRegistry = mc.world.getRegistryManager()
                            .getOrThrow(RegistryKeys.ENCHANTMENT);
                    var flame = enchantmentRegistry.get(Enchantments.FLAME);

                    if (flame != null) {
                        var flameEntry = enchantmentRegistry.getEntry(flame);
                        if (enchantments.getLevel(flameEntry) > 0) {
                            return i;
                        }
                    }
                }
            }
        }
        return -1;
    }
}
var это для защиты
 
Всем привет!
сливаю функцию которую нигде не видел, а именно AutoCart, предназначена для пвп вида "cart" -- вагонетки с тнт. Суть в том что ты ставишь рельсу, на нее вагонетку с тнт и стреляешь луком на воспламенение взрывая вагонетку.

Режимы работы
Pre-rale -- ставит рельсу, стреляет на нее, и до падения стрелы ставит вагонетку с тнт
Insta-cart -- сначала стреляет из лука, после рассчитывая траекторию падения стрелы ставит рельсу и на нее вагонетку
Сайлет -- ваша камера не будет дергаться во время выполнения функции

SS -- Не думаю что сс нужен, посмотрите что такое cart pvp.


TNTMinecraft:
Expand Collapse Copy
package rich.modules.impl.combat;

import antidaunleak.api.annotation.Native;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.util.InputUtil;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import org.lwjgl.glfw.GLFW;
import rich.events.api.EventHandler;
import rich.events.api.types.EventType;
import rich.events.impl.KeyEvent;
import rich.events.impl.RotationUpdateEvent;
import rich.events.impl.TickEvent;
import rich.modules.impl.combat.aura.Angle;
import rich.modules.impl.combat.aura.AngleConfig;
import rich.modules.impl.combat.aura.AngleConnection;
import rich.modules.impl.combat.aura.impl.LinearConstructor;
import rich.modules.module.ModuleStructure;
import rich.modules.module.category.ModuleCategory;
import rich.modules.module.setting.implement.BindSetting;
import rich.modules.module.setting.implement.BooleanSetting;
import rich.modules.module.setting.implement.SelectSetting;
import rich.screens.clickgui.impl.settingsrender.BindComponent;
import rich.util.inventory.InventoryUtils;
import rich.util.math.TaskPriority;

@Getter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class TNTMinecart extends ModuleStructure {

    final BindSetting activateKey = new BindSetting("Активация", "Клавиша для активации");
    final SelectSetting modeSetting = new SelectSetting("Режим", "Режим работы")
            .value("Pre-Rail", "Insta-Cart")
            .selected("Pre-Rail");
    final BooleanSetting silentRotation = new BooleanSetting("Сайлент", "Сайлент ротация (камера не дергается)").setValue(false);

    enum State {
        IDLE,
        PLACING_RAIL,
        DRAWING_BOW,
        SHOOTING,
        PLACING_MINECART,
        INSTA_DRAWING_BOW,
        INSTA_SHOOTING,
        INSTA_PLACING_RAIL,
        INSTA_PLACING_MINECART,
        DONE
    }

    State currentState = State.IDLE;
    int actionTimer = 0;
    int originalSlot = 0;
    int railSlot = -1;
    int bowSlot = -1;
    int tntMinecartSlot = -1;
    BlockHitResult targetHit = null;
    BlockPos arrowLandPos = null;
    boolean bowStarted = false;
    float originalPitch = 0;
    float originalYaw = 0;

    public TNTMinecart() {
        super("Auto Cart", "Auto Cart", ModuleCategory.LEGIT);
        settings(activateKey, modeSetting, silentRotation);
    }

    @Override
    public void deactivate() {
        reset();
        AngleConnection.INSTANCE.startReturning();
    }

    @EventHandler
    public void onRotationUpdate(RotationUpdateEvent e) {
        if (mc.player == null || mc.world == null) return;
        if (currentState == State.IDLE) return;
       
        if (e.getType() == EventType.PRE && silentRotation.isValue()) {
            float targetPitch = originalPitch - 12.0f;
           
            boolean shouldRotate = false;
            if (modeSetting.isSelected("Pre-Rail")) {
                shouldRotate = (currentState == State.SHOOTING && actionTimer >= 4);
            } else {
                shouldRotate = (currentState == State.INSTA_SHOOTING && actionTimer >= 4);
            }
           
            if (shouldRotate) {
                Angle targetAngle = new Angle(mc.player.getYaw(), targetPitch);
                AngleConfig config = new AngleConfig(new LinearConstructor(), true, true);
               
                AngleConnection.INSTANCE.rotateTo(
                    targetAngle,
                    1,
                    config,
                    TaskPriority.HIGH_IMPORTANCE_1,
                    this
                );
            }
        }
    }

    @EventHandler
    @Native(type = Native.Type.VMProtectBeginMutation)
    public void onKey(KeyEvent e) {
        if (mc.player == null || mc.world == null) return;
        if (mc.currentScreen != null) return;
        if (currentState != State.IDLE) return;
        if (e.action() != 1) return;

        int bindKey = activateKey.getKey();
        int bindType = activateKey.getType();

        if (bindKey == GLFW.GLFW_KEY_UNKNOWN || bindKey == -1) return;

        boolean matches = false;

        if (bindType == 2) {
            if (bindKey == BindComponent.MIDDLE_MOUSE_BIND
                    && e.type() == InputUtil.Type.MOUSE
                    && e.key() == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) {
                matches = true;
            }
        } else if (bindType == 0 && e.type() == InputUtil.Type.MOUSE) {
            matches = e.key() == bindKey;
        } else if (bindType == 1 && e.type() == InputUtil.Type.KEYSYM) {
            matches = e.key() == bindKey;
        }

        if (matches) {
            execute();
        }
    }

    @EventHandler
    @Native(type = Native.Type.VMProtectBeginUltra)
    public void onTick(TickEvent e) {
        if (mc.player == null || mc.world == null) return;

        if (currentState != State.IDLE) {
            processTick();
        }
    }

    @Native(type = Native.Type.VMProtectBeginMutation)
    private void execute() {
        PlayerInventory inventory = mc.player.getInventory();

        tntMinecartSlot = findTNTMinecart(inventory);
        railSlot = findRail(inventory);
        bowSlot = findFlameBow(inventory);

        if (tntMinecartSlot == -1 || railSlot == -1 || bowSlot == -1) {
            return;
        }

        HitResult hit = mc.crosshairTarget;
        if (hit == null || hit.getType() != HitResult.Type.BLOCK) {
            return;
        }

        targetHit = (BlockHitResult) hit;
        originalSlot = inventory.getSelectedSlot();
        originalPitch = mc.player.getPitch();
        originalYaw = mc.player.getYaw();
        actionTimer = 0;
        bowStarted = false;

        if (modeSetting.isSelected("Pre-Rail")) {
            currentState = State.PLACING_RAIL;
        } else {
            currentState = State.INSTA_DRAWING_BOW;
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processTick() {
        if (mc.player == null || mc.interactionManager == null || mc.world == null) {
            reset();
            return;
        }

        PlayerInventory inventory = mc.player.getInventory();
        actionTimer++;

        try {
            if (modeSetting.isSelected("Pre-Rail")) {
                processPreRailMode();
            } else {
                processInstaCartMode();
            }
        } catch (Exception ex) {
            reset();
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processPreRailMode() {
        switch (currentState) {
            case PLACING_RAIL:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(railSlot);
                    mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, targetHit);
                    currentState = State.DRAWING_BOW;
                    actionTimer = 0;
                }
                break;

            case DRAWING_BOW:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(bowSlot);
                    mc.options.useKey.setPressed(true);
                    bowStarted = true;
                    currentState = State.SHOOTING;
                    actionTimer = 0;
                }
                break;

            case SHOOTING:
                if (actionTimer == 5) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(mc.player.getPitch() - 12.0f);
                    }
                } else if (actionTimer == 6) {
                    if (bowStarted) {
                        mc.options.useKey.setPressed(false);
                        bowStarted = false;
                    }
                } else if (actionTimer >= 7) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(originalPitch);
                        mc.player.setYaw(originalYaw);
                    }
                    currentState = State.PLACING_MINECART;
                    actionTimer = 0;
                }
                break;

            case PLACING_MINECART:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(tntMinecartSlot);
                    mc.options.useKey.setPressed(true);
                } else if (actionTimer == 2) {
                    mc.options.useKey.setPressed(false);
                    currentState = State.DONE;
                    actionTimer = 0;
                }
                break;

            case DONE:
                if (actionTimer >= 1) {
                    InventoryUtils.selectSlot(originalSlot);
                    reset();
                }
                break;
        }
    }

    @Native(type = Native.Type.VMProtectBeginUltra)
    private void processInstaCartMode() {
        switch (currentState) {
            case INSTA_DRAWING_BOW:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(bowSlot);
                    mc.options.useKey.setPressed(true);
                    bowStarted = true;
                    currentState = State.INSTA_SHOOTING;
                    actionTimer = 0;
                }
                break;

            case INSTA_SHOOTING:
                if (actionTimer == 5) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(mc.player.getPitch() - 12.0f);
                    }
                } else if (actionTimer == 6) {
                    if (bowStarted) {
                        mc.options.useKey.setPressed(false);
                        bowStarted = false;
                    }
                } else if (actionTimer >= 7) {
                    if (!silentRotation.isValue()) {
                        mc.player.setPitch(originalPitch);
                        mc.player.setYaw(originalYaw);
                    }
                    currentState = State.INSTA_PLACING_RAIL;
                    actionTimer = 0;
                }
                break;

            case INSTA_PLACING_RAIL:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(railSlot);
                    mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, targetHit);
                    currentState = State.INSTA_PLACING_MINECART;
                    actionTimer = 0;
                }
                break;

            case INSTA_PLACING_MINECART:
                if (actionTimer == 1) {
                    InventoryUtils.selectSlot(tntMinecartSlot);
                    mc.options.useKey.setPressed(true);
                } else if (actionTimer == 2) {
                    mc.options.useKey.setPressed(false);
                    currentState = State.DONE;
                    actionTimer = 0;
                }
                break;

            case DONE:
                if (actionTimer >= 1) {
                    InventoryUtils.selectSlot(originalSlot);
                    reset();
                }
                break;
        }
    }

    private void reset() {
        if (bowStarted && mc.options != null) {
            mc.options.useKey.setPressed(false);
        }
        currentState = State.IDLE;
        actionTimer = 0;
        bowStarted = false;
        targetHit = null;
        arrowLandPos = null;
        originalPitch = 0;
        originalYaw = 0;
    }

    private int findTNTMinecart(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            if (stack.getItem() == Items.TNT_MINECART) {
                return i;
            }
        }
        return -1;
    }

    private int findRail(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            String itemId = Registries.ITEM.getId(stack.getItem()).toString();
            if (itemId.contains("rail")) {
                return i;
            }
        }
        return -1;
    }

    private int findFlameBow(PlayerInventory inventory) {
        for (int i = 0; i < 9; i++) {
            ItemStack stack = inventory.getStack(i);
            if (stack.getItem() == Items.BOW) {
                ItemEnchantmentsComponent enchantments = stack.getOrDefault(
                        DataComponentTypes.ENCHANTMENTS,
                        ItemEnchantmentsComponent.DEFAULT
                );

                if (!enchantments.isEmpty()) {
                    var enchantmentRegistry = mc.world.getRegistryManager()
                            .getOrThrow(RegistryKeys.ENCHANTMENT);
                    var flame = enchantmentRegistry.get(Enchantments.FLAME);

                    if (flame != null) {
                        var flameEntry = enchantmentRegistry.getEntry(flame);
                        if (enchantments.getLevel(flameEntry) > 0) {
                            return i;
                        }
                    }
                }
            }
        }
        return -1;
    }
}
кому надо ?
 
Назад
Сверху Снизу