Исходник Govno AutoPotion EXP 3.1

Начинающий
Статус
Онлайн
Регистрация
8 Июл 2023
Сообщения
22
Реакции[?]
0
Поинты[?]
0

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

всем привет начинающие кодеры я решил слить autopotion под expensive 3.1 знаю он очень плохой но это первый именно серьёзный код желаю всем удачи!

сам кодик:
AutoPotion:
package ru.client.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import ru.client.events.EventMotion;
import ru.client.functions.api.Category;
import ru.client.functions.api.Function;
import ru.client.functions.api.FunctionRegister;
import ru.client.functions.settings.impl.BooleanSetting;
import ru.client.utils.math.MathUtil;
import ru.client.utils.math.StopWatch;
import ru.client.utils.player.InventoryUtil;
import ru.client.utils.player.MoveUtils;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.SplashPotionItem;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.network.play.client.CPlayerTryUseItemPacket;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.Hand;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.Comparator;
import java.util.List;

@FunctionRegister(name = "AutoPotion", type = Category.Combat)
public class AutoPotion extends Function {

    private final BooleanSetting mefedron = new BooleanSetting("Зелье скорости", false);
    private final BooleanSetting hui = new BooleanSetting("Зелье силы", false);
    private final BooleanSetting litenergy = new BooleanSetting("Зелье огнестойкости", false);

    public AutoPotion() {
        this.addSettings(this.mefedron, hui, litenergy);
    }

    float previousPitch;
    final StopWatch stopWatch = new StopWatch();

    @Subscribe
    public void onMotion(EventMotion e) {
        if (!canThrowPotion()) {
            return;
        }

        boolean speedActive = mc.player.isPotionActive(Effects.SPEED);
        boolean huiActive = mc.player.isPotionActive(Effects.STRENGTH);
        boolean fireResistActive = mc.player.isPotionActive(Effects.FIRE_RESISTANCE);

        boolean hasSpeedPotion = hasPotionInInventory(Potions.SPEED);
        boolean hasStrengthPotion = hasPotionInInventory(Potions.STRENGHT);
        boolean hasFireResistPotion = hasPotionInInventory(Potions.FIRE_RESIST);

        if (isActive() && !speedActive && !huiActive && !fireResistActive && (hasSpeedPotion || hasStrengthPotion || hasFireResistPotion)) {
            Vector3d posPoint = findNearestCollision();
            Vector2f rotationVector = posPoint == null
                    ? new Vector2f(mc.player.rotationYaw, 90.0F)
                    : MathUtil.rotationToVec(posPoint);

            previousPitch = rotationVector.y;
            e.setYaw(rotationVector.x);
            e.setPitch(previousPitch);
            mc.player.rotationPitchHead = previousPitch;
        }

        e.setPostMotion(() -> {
            int oldCurrentItem = mc.player.inventory.currentItem;

            if (this.mefedron.get() && shouldUsePotion(Potions.SPEED)) {
                sendPotion(Potions.SPEED);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }

            if (this.hui.get() && shouldUsePotion(Potions.STRENGHT)) {
                sendPotion(Potions.STRENGHT);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }

            if (this.litenergy.get() && shouldUsePotion(Potions.FIRE_RESIST)) {
                sendPotion(Potions.FIRE_RESIST);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }
        });
    }

    public boolean isActive() {
        return this.mefedron.get() || this.hui.get() || this.litenergy.get();
    }

    private boolean hasPotionInInventory(Potions potion) {
        int potionId = potion.getId();
        return this.findPotionSlot(potionId, true) != -1 || this.findPotionSlot(potionId, false) != -1;
    }

    private boolean canThrowPotion() {
        boolean isOnGround = !MoveUtils.isBlockUnder(0.5F) || mc.player.isOnGround();
        boolean timeIsReached = stopWatch.isReached(400);
        boolean ticksExisted = mc.player.ticksExisted > 100;

        return isOnGround && timeIsReached && ticksExisted;
    }

    private boolean shouldUsePotion(Potions potions) {
        if (mc.player.isPotionActive(potions.getPotion())) {
            potions.state = false;
            return false;
        }
        potions.state = true;
        return true;
    }

    private void sendPotion(Potions potions) {
        int potionId = potions.getId();

        int hotBarSlot = findPotionSlot(potionId, true);
        int inventorySlot = findPotionSlot(potionId, false);

        if (hotBarSlot != -1) {
            sendUsePacket(hotBarSlot, Hand.MAIN_HAND);
            return;
        }

        if (inventorySlot != -1) {
            int bestSlotInHotBar = InventoryUtil.getInstance().findBestSlotInHotBar();
            ItemStack inventoryStack = mc.player.inventory.getStackInSlot(inventorySlot);
            ItemStack bestSlotStack = mc.player.inventory.getStackInSlot(bestSlotInHotBar);

            InventoryUtil.moveItem(inventorySlot, bestSlotInHotBar + 36, bestSlotStack.getItem() != Items.AIR);
            sendUsePacket(bestSlotInHotBar, Hand.MAIN_HAND);
        }
    }

    private void sendUsePacket(int slot, Hand hand) {
        mc.player.connection.sendPacket(new CHeldItemChangePacket(slot));
        mc.player.connection.sendPacket(new CPlayerTryUseItemPacket(hand));
        mc.player.swingArm(Hand.MAIN_HAND);
        previousPitch = 0;
        stopWatch.reset();
    }

    private int findPotionSlot(int id, boolean inHotBar) {
        int start = inHotBar ? 0 : 9;
        int end = inHotBar ? 9 : 36;

        for (int i = start; i < end; i++) {
            ItemStack stack = mc.player.inventory.getStackInSlot(i);

            if (stack.isEmpty()) {
                continue;
            }

            if (!(stack.getItem() instanceof SplashPotionItem)) {
                continue;
            }

            List<EffectInstance> potionEffects = PotionUtils.getEffectsFromStack(stack);

            for (EffectInstance effectInstance : potionEffects) {
                if (effectInstance.getPotion() == Effect.get(id)) {
                    return i;
                }
            }
        }

        return -1;
    }

    private Vector3d findNearestCollision() {
        return mc.world.getCollisionShapes(mc.player, mc.player.getBoundingBox().grow(0.0, 0.5, 0.0))
                .toList()
                .stream()
                .min(Comparator.comparingDouble(box ->
                        box.getBoundingBox().getCenter().squareDistanceTo(mc.player.getPositionVec())))
                .map(box -> box.getBoundingBox().getCenter())
                .orElse(null);
    }

    [USER=270918]@Getter[/USER]
    @FieldDefaults(level = AccessLevel.PRIVATE)
    public enum Potions {
        STRENGHT(Effects.STRENGTH, 5),
        SPEED(Effects.SPEED, 1),
        FIRE_RESIST(Effects.FIRE_RESISTANCE, 12);

        final Effect potion;
        final int id;
        boolean state;

        Potions(Effect potion, int potionId) {
            this.potion = potion;
            this.id = potionId;
        }
    }
}
 
Начинающий
Статус
Оффлайн
Регистрация
23 Апр 2024
Сообщения
458
Реакции[?]
1
Поинты[?]
2K
всем привет начинающие кодеры я решил слить autopotion под expensive 3.1 знаю он очень плохой но это первый именно серьёзный код желаю всем удачи!

сам кодик:
AutoPotion:
package ru.client.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import ru.client.events.EventMotion;
import ru.client.functions.api.Category;
import ru.client.functions.api.Function;
import ru.client.functions.api.FunctionRegister;
import ru.client.functions.settings.impl.BooleanSetting;
import ru.client.utils.math.MathUtil;
import ru.client.utils.math.StopWatch;
import ru.client.utils.player.InventoryUtil;
import ru.client.utils.player.MoveUtils;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.SplashPotionItem;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.network.play.client.CPlayerTryUseItemPacket;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.Hand;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.Comparator;
import java.util.List;

@FunctionRegister(name = "AutoPotion", type = Category.Combat)
public class AutoPotion extends Function {

    private final BooleanSetting mefedron = new BooleanSetting("Зелье скорости", false);
    private final BooleanSetting hui = new BooleanSetting("Зелье силы", false);
    private final BooleanSetting litenergy = new BooleanSetting("Зелье огнестойкости", false);

    public AutoPotion() {
        this.addSettings(this.mefedron, hui, litenergy);
    }

    float previousPitch;
    final StopWatch stopWatch = new StopWatch();

    @Subscribe
    public void onMotion(EventMotion e) {
        if (!canThrowPotion()) {
            return;
        }

        boolean speedActive = mc.player.isPotionActive(Effects.SPEED);
        boolean huiActive = mc.player.isPotionActive(Effects.STRENGTH);
        boolean fireResistActive = mc.player.isPotionActive(Effects.FIRE_RESISTANCE);

        boolean hasSpeedPotion = hasPotionInInventory(Potions.SPEED);
        boolean hasStrengthPotion = hasPotionInInventory(Potions.STRENGHT);
        boolean hasFireResistPotion = hasPotionInInventory(Potions.FIRE_RESIST);

        if (isActive() && !speedActive && !huiActive && !fireResistActive && (hasSpeedPotion || hasStrengthPotion || hasFireResistPotion)) {
            Vector3d posPoint = findNearestCollision();
            Vector2f rotationVector = posPoint == null
                    ? new Vector2f(mc.player.rotationYaw, 90.0F)
                    : MathUtil.rotationToVec(posPoint);

            previousPitch = rotationVector.y;
            e.setYaw(rotationVector.x);
            e.setPitch(previousPitch);
            mc.player.rotationPitchHead = previousPitch;
        }

        e.setPostMotion(() -> {
            int oldCurrentItem = mc.player.inventory.currentItem;

            if (this.mefedron.get() && shouldUsePotion(Potions.SPEED)) {
                sendPotion(Potions.SPEED);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }

            if (this.hui.get() && shouldUsePotion(Potions.STRENGHT)) {
                sendPotion(Potions.STRENGHT);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }

            if (this.litenergy.get() && shouldUsePotion(Potions.FIRE_RESIST)) {
                sendPotion(Potions.FIRE_RESIST);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }
        });
    }

    public boolean isActive() {
        return this.mefedron.get() || this.hui.get() || this.litenergy.get();
    }

    private boolean hasPotionInInventory(Potions potion) {
        int potionId = potion.getId();
        return this.findPotionSlot(potionId, true) != -1 || this.findPotionSlot(potionId, false) != -1;
    }

    private boolean canThrowPotion() {
        boolean isOnGround = !MoveUtils.isBlockUnder(0.5F) || mc.player.isOnGround();
        boolean timeIsReached = stopWatch.isReached(400);
        boolean ticksExisted = mc.player.ticksExisted > 100;

        return isOnGround && timeIsReached && ticksExisted;
    }

    private boolean shouldUsePotion(Potions potions) {
        if (mc.player.isPotionActive(potions.getPotion())) {
            potions.state = false;
            return false;
        }
        potions.state = true;
        return true;
    }

    private void sendPotion(Potions potions) {
        int potionId = potions.getId();

        int hotBarSlot = findPotionSlot(potionId, true);
        int inventorySlot = findPotionSlot(potionId, false);

        if (hotBarSlot != -1) {
            sendUsePacket(hotBarSlot, Hand.MAIN_HAND);
            return;
        }

        if (inventorySlot != -1) {
            int bestSlotInHotBar = InventoryUtil.getInstance().findBestSlotInHotBar();
            ItemStack inventoryStack = mc.player.inventory.getStackInSlot(inventorySlot);
            ItemStack bestSlotStack = mc.player.inventory.getStackInSlot(bestSlotInHotBar);

            InventoryUtil.moveItem(inventorySlot, bestSlotInHotBar + 36, bestSlotStack.getItem() != Items.AIR);
            sendUsePacket(bestSlotInHotBar, Hand.MAIN_HAND);
        }
    }

    private void sendUsePacket(int slot, Hand hand) {
        mc.player.connection.sendPacket(new CHeldItemChangePacket(slot));
        mc.player.connection.sendPacket(new CPlayerTryUseItemPacket(hand));
        mc.player.swingArm(Hand.MAIN_HAND);
        previousPitch = 0;
        stopWatch.reset();
    }

    private int findPotionSlot(int id, boolean inHotBar) {
        int start = inHotBar ? 0 : 9;
        int end = inHotBar ? 9 : 36;

        for (int i = start; i < end; i++) {
            ItemStack stack = mc.player.inventory.getStackInSlot(i);

            if (stack.isEmpty()) {
                continue;
            }

            if (!(stack.getItem() instanceof SplashPotionItem)) {
                continue;
            }

            List<EffectInstance> potionEffects = PotionUtils.getEffectsFromStack(stack);

            for (EffectInstance effectInstance : potionEffects) {
                if (effectInstance.getPotion() == Effect.get(id)) {
                    return i;
                }
            }
        }

        return -1;
    }

    private Vector3d findNearestCollision() {
        return mc.world.getCollisionShapes(mc.player, mc.player.getBoundingBox().grow(0.0, 0.5, 0.0))
                .toList()
                .stream()
                .min(Comparator.comparingDouble(box ->
                        box.getBoundingBox().getCenter().squareDistanceTo(mc.player.getPositionVec())))
                .map(box -> box.getBoundingBox().getCenter())
                .orElse(null);
    }

    [USER=270918]@Getter[/USER]
    @FieldDefaults(level = AccessLevel.PRIVATE)
    public enum Potions {
        STRENGHT(Effects.STRENGTH, 5),
        SPEED(Effects.SPEED, 1),
        FIRE_RESIST(Effects.FIRE_RESISTANCE, 12);

        final Effect potion;
        final int id;
        boolean state;

        Potions(Effect potion, int potionId) {
            this.potion = potion;
            this.id = potionId;
        }
    }
}
САМ ты говно емае! :joycat: (кста если ты будеш обзываца я буду кусаца блина!!!) матафакер ты епэрный тиатр!!
 
Начинающий
Статус
Оффлайн
Регистрация
16 Апр 2024
Сообщения
324
Реакции[?]
3
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
13 Авг 2024
Сообщения
25
Реакции[?]
0
Поинты[?]
0
всем привет начинающие кодеры я решил слить autopotion под expensive 3.1 знаю он очень плохой но это первый именно серьёзный код желаю всем удачи!

сам кодик:
AutoPotion:
package ru.client.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import ru.client.events.EventMotion;
import ru.client.functions.api.Category;
import ru.client.functions.api.Function;
import ru.client.functions.api.FunctionRegister;
import ru.client.functions.settings.impl.BooleanSetting;
import ru.client.utils.math.MathUtil;
import ru.client.utils.math.StopWatch;
import ru.client.utils.player.InventoryUtil;
import ru.client.utils.player.MoveUtils;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.SplashPotionItem;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.network.play.client.CPlayerTryUseItemPacket;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.Hand;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.Comparator;
import java.util.List;

@FunctionRegister(name = "AutoPotion", type = Category.Combat)
public class AutoPotion extends Function {

    private final BooleanSetting mefedron = new BooleanSetting("Зелье скорости", false);
    private final BooleanSetting hui = new BooleanSetting("Зелье силы", false);
    private final BooleanSetting litenergy = new BooleanSetting("Зелье огнестойкости", false);

    public AutoPotion() {
        this.addSettings(this.mefedron, hui, litenergy);
    }

    float previousPitch;
    final StopWatch stopWatch = new StopWatch();

    @Subscribe
    public void onMotion(EventMotion e) {
        if (!canThrowPotion()) {
            return;
        }

        boolean speedActive = mc.player.isPotionActive(Effects.SPEED);
        boolean huiActive = mc.player.isPotionActive(Effects.STRENGTH);
        boolean fireResistActive = mc.player.isPotionActive(Effects.FIRE_RESISTANCE);

        boolean hasSpeedPotion = hasPotionInInventory(Potions.SPEED);
        boolean hasStrengthPotion = hasPotionInInventory(Potions.STRENGHT);
        boolean hasFireResistPotion = hasPotionInInventory(Potions.FIRE_RESIST);

        if (isActive() && !speedActive && !huiActive && !fireResistActive && (hasSpeedPotion || hasStrengthPotion || hasFireResistPotion)) {
            Vector3d posPoint = findNearestCollision();
            Vector2f rotationVector = posPoint == null
                    ? new Vector2f(mc.player.rotationYaw, 90.0F)
                    : MathUtil.rotationToVec(posPoint);

            previousPitch = rotationVector.y;
            e.setYaw(rotationVector.x);
            e.setPitch(previousPitch);
            mc.player.rotationPitchHead = previousPitch;
        }

        e.setPostMotion(() -> {
            int oldCurrentItem = mc.player.inventory.currentItem;

            if (this.mefedron.get() && shouldUsePotion(Potions.SPEED)) {
                sendPotion(Potions.SPEED);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }

            if (this.hui.get() && shouldUsePotion(Potions.STRENGHT)) {
                sendPotion(Potions.STRENGHT);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }

            if (this.litenergy.get() && shouldUsePotion(Potions.FIRE_RESIST)) {
                sendPotion(Potions.FIRE_RESIST);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(oldCurrentItem));
                mc.playerController.syncCurrentPlayItem();
            }
        });
    }

    public boolean isActive() {
        return this.mefedron.get() || this.hui.get() || this.litenergy.get();
    }

    private boolean hasPotionInInventory(Potions potion) {
        int potionId = potion.getId();
        return this.findPotionSlot(potionId, true) != -1 || this.findPotionSlot(potionId, false) != -1;
    }

    private boolean canThrowPotion() {
        boolean isOnGround = !MoveUtils.isBlockUnder(0.5F) || mc.player.isOnGround();
        boolean timeIsReached = stopWatch.isReached(400);
        boolean ticksExisted = mc.player.ticksExisted > 100;

        return isOnGround && timeIsReached && ticksExisted;
    }

    private boolean shouldUsePotion(Potions potions) {
        if (mc.player.isPotionActive(potions.getPotion())) {
            potions.state = false;
            return false;
        }
        potions.state = true;
        return true;
    }

    private void sendPotion(Potions potions) {
        int potionId = potions.getId();

        int hotBarSlot = findPotionSlot(potionId, true);
        int inventorySlot = findPotionSlot(potionId, false);

        if (hotBarSlot != -1) {
            sendUsePacket(hotBarSlot, Hand.MAIN_HAND);
            return;
        }

        if (inventorySlot != -1) {
            int bestSlotInHotBar = InventoryUtil.getInstance().findBestSlotInHotBar();
            ItemStack inventoryStack = mc.player.inventory.getStackInSlot(inventorySlot);
            ItemStack bestSlotStack = mc.player.inventory.getStackInSlot(bestSlotInHotBar);

            InventoryUtil.moveItem(inventorySlot, bestSlotInHotBar + 36, bestSlotStack.getItem() != Items.AIR);
            sendUsePacket(bestSlotInHotBar, Hand.MAIN_HAND);
        }
    }

    private void sendUsePacket(int slot, Hand hand) {
        mc.player.connection.sendPacket(new CHeldItemChangePacket(slot));
        mc.player.connection.sendPacket(new CPlayerTryUseItemPacket(hand));
        mc.player.swingArm(Hand.MAIN_HAND);
        previousPitch = 0;
        stopWatch.reset();
    }

    private int findPotionSlot(int id, boolean inHotBar) {
        int start = inHotBar ? 0 : 9;
        int end = inHotBar ? 9 : 36;

        for (int i = start; i < end; i++) {
            ItemStack stack = mc.player.inventory.getStackInSlot(i);

            if (stack.isEmpty()) {
                continue;
            }

            if (!(stack.getItem() instanceof SplashPotionItem)) {
                continue;
            }

            List<EffectInstance> potionEffects = PotionUtils.getEffectsFromStack(stack);

            for (EffectInstance effectInstance : potionEffects) {
                if (effectInstance.getPotion() == Effect.get(id)) {
                    return i;
                }
            }
        }

        return -1;
    }

    private Vector3d findNearestCollision() {
        return mc.world.getCollisionShapes(mc.player, mc.player.getBoundingBox().grow(0.0, 0.5, 0.0))
                .toList()
                .stream()
                .min(Comparator.comparingDouble(box ->
                        box.getBoundingBox().getCenter().squareDistanceTo(mc.player.getPositionVec())))
                .map(box -> box.getBoundingBox().getCenter())
                .orElse(null);
    }

    [USER=270918]@Getter[/USER]
    @FieldDefaults(level = AccessLevel.PRIVATE)
    public enum Potions {
        STRENGHT(Effects.STRENGTH, 5),
        SPEED(Effects.SPEED, 1),
        FIRE_RESIST(Effects.FIRE_RESISTANCE, 12);

        final Effect potion;
        final int id;
        boolean state;

        Potions(Effect potion, int potionId) {
            this.potion = potion;
            this.id = potionId;
        }
    }
}
ss плиз
 
Начинающий
Статус
Оффлайн
Регистрация
8 Июн 2023
Сообщения
336
Реакции[?]
3
Поинты[?]
3K
Сверху Снизу