• Я зарабатываю 100 000 RUB / месяц на этом сайте!

    А знаешь как? Я всего-лишь публикую (создаю темы), а админ мне платит. Трачу деньги на мороженое, робуксы и сервера в Minecraft. А ещё на паль из Китая. 

    Хочешь так же? Пиши и узнавай условия: https://t.me/alex_redact
    Реклама: https://t.me/yougame_official

Часть функционала ProjectileHelper Upgrade exp3.1\eva

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
13 Янв 2025
Сообщения
31
Реакции
0
Выберите загрузчик игры
  1. Forge
  2. Fabric
  3. OptiFine
Улучшеная версия ProjectileHelper

Код:
Expand Collapse Copy
import com.google.common.eventbus.Subscribe;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.TridentItem;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;


import java.util.*;

import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@FunctionRegister(name = "ProjectileHelper", type = Category.Combat)
public class ProjectileHelper extends Function {
    private final ModeListSetting weapons = new ModeListSetting("Оружие",
            new BooleanSetting("Лук", true),
            new BooleanSetting("Трезубец", true));
    private final BooleanSetting predictPosition = new BooleanSetting("Предугадывать поз", true);
    private final SliderSetting predictionAccuracy = new SliderSetting("Точность предсказания", 3, 1, 5, 1).setVisible(predictPosition:: get);
    private final SliderSetting predictionIterations = new SliderSetting("Итерации предсказания", 5, 1, 10, 1).setVisible(predictPosition:: get);
    private final BooleanSetting advancedPhysics = new BooleanSetting("Продвинутая физика", true).setVisible(predictPosition:: get);
    private final SliderSetting aimRange = new SliderSetting("Дистанция наводки", 30.0f, 10.0f, 50.0f, 1.0f);
    private final SliderSetting aimSpeed = new SliderSetting("Скорость наводки", 15.0f, 1.0f, 30.0f, 0.5f);
    private LivingEntity target;
    private Vector2f rotation;
    private boolean aiming;
    private boolean initialAim;
    private boolean wasCharging;
    private final Map<LivingEntity, List<Vector3d>> positionHistory = new WeakHashMap<>();
    private final Map<LivingEntity, List<Long>> positionHistoryTimestamps = new WeakHashMap<>();
    public ProjectileHelper() {
        addSettings(weapons, aimRange, aimSpeed,predictPosition,predictionAccuracy,predictionIterations,advancedPhysics);
    }

  @Subscribe
    public void onUpdate(EventUpdate event) {
        if (mc.player == null || mc.world == null) {
            reset();
            return;
        }

        boolean charging = ValidItem() && mc.player.isHandActive() && mc.player.getActiveHand() == Hand.MAIN_HAND;

        if (!charging && wasCharging) {
            reset();
        }
        wasCharging = charging;

        if (!charging) return;

        updateTarget();

        if (target != null) {
            if (!aiming) initialAim = true;
            aim();
        }
      if (target != null) {
          positionHistory.computeIfAbsent(target, k -> new ArrayList<>(5)).add(0, target.getPositionVec());
          positionHistoryTimestamps.computeIfAbsent(target, k -> new ArrayList<>(5)).add(0, System.currentTimeMillis());

          // Ограничиваем историю 5 последними позициями
          if (positionHistory.get(target).size() > 5) {
              positionHistory.get(target).remove(5);
              positionHistoryTimestamps.get(target).remove(5);
          }
      }
  }

    @Subscribe
    private void onMotion(EventMotion event) {
        if (target == null || !ValidItem() || !mc.player.isHandActive() || mc.player.getActiveHand() != Hand.MAIN_HAND)
            return;

        if (rotation != null) {
            event.setYaw(rotation.x);
            event.setPitch(rotation.y);
        }
    }

    private void aim() {
        if (target == null) return;

        Vector3d targetPos;
        if ((Boolean)predictPosition.get()) {
            targetPos = predictTargetPos();
        } else {
            targetPos = target.getPositionVec().add(0, target.getHeight() * 0.5, 0);
        }

        Vector3d vec = targetPos.subtract(mc.player.getEyePosition(1.0F));

        float yawToTarget = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(vec.z, vec.x)) - 90);
        float pitchToTarget = (float) (-Math.toDegrees(Math.atan2(vec.y, Math.sqrt(vec.x * vec.x + vec.z * vec.z))));

        if (rotation == null) {
            rotation = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }

        float yawDelta = wrapDegrees(yawToTarget - rotation.x);
        float pitchDelta = wrapDegrees(pitchToTarget - rotation.y);

        float clampedYaw = Math.min(Math.max(Math.abs(yawDelta), 1.0f), aimSpeed.get());
        float clampedPitch = Math.min(Math.max(Math.abs(pitchDelta), 1.0f), aimSpeed.get()) / 3f;

        float yaw = rotation.x + (yawDelta > 0 ? clampedYaw : -clampedYaw);
        float pitch = clamp(rotation.y + (pitchDelta > 0 ? clampedPitch : -clampedPitch), -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        yaw -= (yaw - rotation.x) % gcd;
        pitch -= (pitch - rotation.y) % gcd;

        rotation = new Vector2f(yaw, pitch);
        aiming = true;
    }
//райн сасал
    private Vector3d predictTargetPos() {

        Vector3d pos = target.getPositionVec().add(0, target.getHeight() * 0.5, 0);

        if (target.getMotion().lengthSquared() < 0.001) {
            return pos;
        }

        double projectileSpeed = Trident() ? 2.5 : Bow() ? 3.0 : 2.5;
        double gravity = 0.05; // Гравитация для трезубца/лука

        double distance = mc.player.getDistance(target);
        double predictionTime = distance / projectileSpeed;

        for (int i = 0; i < 3; i++) {
            Vector3d predictedPos = pos.add(
                    target.getMotion().x * predictionTime,
                    (target.getMotion().y - gravity * predictionTime/2) * predictionTime, // Учет гравитации
                    target.getMotion().z * predictionTime
            );

            double newDistance = mc.player.getPositionVec().distanceTo(predictedPos);

            predictionTime = newDistance / projectileSpeed;
        }

        Vector3d finalPos = pos.add(
                target.getMotion().x * predictionTime,
                (target.getMotion().y - gravity * predictionTime/2) * predictionTime,
                target.getMotion().z * predictionTime
        );

        return finalPos.add(0, target.getHeight() * 0.2, 0); // Смещение в верхнюю часть хитбокса
    }

    private boolean Bow() {
        ItemStack item = mc.player.getHeldItemMainhand();
        return item.getItem() instanceof BowItem;
    }

    private boolean Trident() {
        ItemStack item = mc.player.getHeldItemMainhand();
        return item.getItem() instanceof TridentItem;
    }

    private void updateTarget() {
        List<LivingEntity> targets = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (ValidTarget(entity)) {
                targets.add((LivingEntity) entity);
            }
        }

        targets.sort(Comparator.comparingDouble(e -> mc.player.getDistanceSq(e)));
        target = targets.isEmpty() ? null : targets.get(0);
    }

    private boolean ValidTarget(Entity entity) {
        if (!(entity instanceof LivingEntity)) return false;
        if (entity instanceof ClientPlayerEntity) return false;
        if (!entity.isAlive() || entity.ticksExisted < 10 || entity.isInvulnerable()) return false;
        if (mc.player.getDistanceSq(entity) > aimRange.get() * aimRange.get()) return false;
        if (entity.getName().getString().equalsIgnoreCase(mc.player.getName().getString())) return false;
        return true;
    }

    private boolean ValidItem() {
        ItemStack item = mc.player.getHeldItemMainhand();
        if (item.isEmpty()) return false;
        if (item.getItem() instanceof BowItem) return weapons.getValueByName("Лук").get();
        if (item.getItem() instanceof TridentItem) return weapons.getValueByName("Трезубец").get();
        return false;
    }

    private void reset() {
        if (mc.player != null) {
            rotation = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }
        target = null;
        aiming = false;
        initialAim = false;
    }

    @Override
    public boolean onEnable() {
        super.onEnable();
        reset();
        return false;
    }

    @Override
    public void onDisable() {
        super.onDisable();
        reset();
        mc.gameSettings.keyBindUseItem.setPressed(false);
    }
}
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
ну конечно блять это принимают а мою тему 4 дня не принимают спс паймон !!!
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
ну по коду вроде норм
 
ну конечно блять это принимают а мою тему 4 дня не принимают спс паймон !!!
Ну так может у тебя тема мусор не думал?) да и паймон один на весь раздел он столько говна уже повидал
 
-_- ну обидно что улучшенную версию моего кода закинули):
предикт добавили круто...
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Ну так может у тебя тема мусор не думал?) да и паймон один на весь раздел он столько говна уже повидал
хз не думаю,кликгуишка моим юзерам нравилась как и все остальное так шо я не ебу
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Тихо спастил и ушел называется селфффкод
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
чем ета версия лудше?
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
chatgpt solution
 
не робит
 
а что делать с ошибками в коде?
 
Назад
Сверху Снизу