Исходник Snow с регулировкой скорости падения | 2 видами логики падения | подарочек от меня (SXDpandora) 3.1

Начинающий
Статус
Оффлайн
Регистрация
1 Дек 2020
Сообщения
63
Реакции[?]
1
Поинты[?]
1K

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

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

Спасибо!

Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
 
Начинающий
Статус
Оффлайн
Регистрация
4 Июл 2021
Сообщения
191
Реакции[?]
1
Поинты[?]
2K
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
:seemsgood:
 
Read Only
Статус
Оффлайн
Регистрация
3 Май 2024
Сообщения
59
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
сас
 
Начинающий
Статус
Оффлайн
Регистрация
26 Янв 2023
Сообщения
252
Реакции[?]
1
Поинты[?]
1K
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
Когда будет Particles
 
Начинающий
Статус
Оффлайн
Регистрация
1 Дек 2020
Сообщения
63
Реакции[?]
1
Поинты[?]
1K
Когда будет Particles
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.AttackEvent;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.impl.render.HUD;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.math.Vector4i;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.DisplayUtils;
import dF.Wirent.utils.render.font.Fonts;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadLocalRandom;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

@FunctionRegister(name="Particles", type=Category.Render)
public class Particles
extends Function {
private final ModeSetting setting = new ModeSetting("\u0412\u0438\u0434", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u041e\u0440\u0431\u0438\u0437\u044b", "\u041c\u043e\u043b\u043d\u0438\u044f", "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438", "Star");
private final ModeSetting sigma = new ModeSetting("Вид", "1", "1", "2");
private final SliderSetting value = new SliderSetting("\u041a\u043e\u043b-\u0432\u043e \u0437\u0430 \u0443\u0434\u0430\u0440", 20.0f, 1.0f, 50.0f, 1.0f);
private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList();

public Particles() {
this.addSettings(this.setting,this.sigma, this.value);
}

@Override
protected float[] rotations(PlayerEntity player) {
return new float[0];
}

private boolean isInView(Vector3d pos) {
WorldRenderer.frustum.setCameraPosition(Particles.mc.getRenderManager().info.getProjectedView().x, Particles.mc.getRenderManager().info.getProjectedView().y, Particles.mc.getRenderManager().info.getProjectedView().z);
return WorldRenderer.frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
}

private boolean isVisible(Vector3d pos) {
Vector3d cameraPos = Particles.mc.getRenderManager().info.getProjectedView();
RayTraceContext context = new RayTraceContext(cameraPos, pos, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, Minecraft.player);
BlockRayTraceResult result = Minecraft.world.rayTraceBlocks(context);
return result.getType() == RayTraceResult.Type.MISS;
}

@Subscribe
private void onUpdate(AttackEvent e) {
if (e.entity == Minecraft.player) {
return;
}
Entity entity2 = e.entity;
if (entity2 instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity2;
Vector3d center = livingEntity.getPositionVec().add(0.0, livingEntity.getHeight() / 2.0f, 0.0);
int i = 0;
while ((float) i < ((Float) this.value.get()).floatValue()) {
this.particles.add(new Particle(center));
++i;
}
}
}

@Subscribe
private void onDisplay(EventDisplay e) {
block22:
{
block21:
{
if (Minecraft.player == null) break block21;
if (Minecraft.world != null && e.getType() == EventDisplay.Type.PRE) break block22;
}
return;
}
for (Particle p : this.particles) {
if (System.currentTimeMillis() - p.time > 7000L || p.alpha <= 0.0f) {
this.particles.remove(p);
continue;
}
if (Minecraft.player.getPositionVec().distanceTo(p.pos) > 30.0) {
this.particles.remove(p);
continue;
}
if (this.isInView(p.pos) && this.isVisible(p.pos)) {
p.update();
Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);
float size = 1.0f - (float) (System.currentTimeMillis() - p.time) / 7000.0f;
ResourceLocation logo = new ResourceLocation("W1rent/images/star.png");
Vector4i colors = new Vector4i(HUD.getColor(0, 1.0f), HUD.getColor(90, 1.0f), HUD.getColor(180, 1.0f), HUD.getColor(270, 1.0f));
switch ((String) this.setting.get()) {
case "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438": {
Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438": {
Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u041c\u043e\u043b\u043d\u0438\u044f": {
Fonts.damage.drawText(e.getMatrixStack(), "C", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u041e\u0440\u0431\u0438\u0437\u044b": {
DisplayUtils.drawCircle(pos.x, pos.y, 5.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
break;
}
case "Custom": {
DisplayUtils.drawImage(logo, pos.x, pos.y, 30.0f * size, 30.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
}
}
continue;
}
this.particles.remove(p);
}
}

private class Particle {
private Vector3d pos;
private Vector3d end;
private long time;
private long collisionTime = -1L;
private Vector3d velocity;
private float alpha;

public Particle(Vector3d pos) {
this.pos = pos;
this.end = pos.add(-ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f));
this.time = System.currentTimeMillis();
this.velocity = new Vector3d(ThreadLocalRandom.current().nextDouble(-0.01, 0.01), ThreadLocalRandom.current().nextDouble(-0.05, -0.02), ThreadLocalRandom.current().nextDouble(-0.01, 0.01));
this.alpha = 1.0f;
}

public void update() {
if (sigma.get().equals("1")) {
update1();
} else if (sigma.get().equals("2")) {
update2();
}
}

private void update1() {
long elapsedTime = System.currentTimeMillis() - this.time;

// Настройки
long totalDuration = 3000L;
double maxHeight = 1.2;
double spinSpeed = 0.2;
double fallSpeed = 0.001;

this.alpha = Math.max(0.0f, 1.0f - (float) elapsedTime / totalDuration);

if (this.pos.y < this.end.y + maxHeight) {
this.velocity = new Vector3d(this.velocity.x, 0.01, this.velocity.z);
} else {
this.velocity = new Vector3d(0.0, -fallSpeed, 0.0);
}

double angle = spinSpeed * elapsedTime;
double offsetX = Math.cos(angle) * 0.0;
double offsetZ = Math.sin(angle) * 0.0;

this.pos = this.pos.add(this.velocity.x + offsetX, this.velocity.y, this.velocity.z + offsetZ);

if (elapsedTime > totalDuration) {
this.alpha = 0.0f;
}
}

private void update2() {
if (this.collisionTime != -1L) {
long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
}
this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
Vector3d newPos = this.pos.add(this.velocity);
BlockPos particlePos = new BlockPos(newPos);
BlockState blockState = Minecraft.world.getBlockState(particlePos);

if (!blockState.isAir()) {
if (this.collisionTime == -1L) {
this.collisionTime = System.currentTimeMillis();
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
}
this.pos = this.pos.add(this.velocity);
} else {
this.pos = newPos;
}
}
}
}
Когда будет Particles
Код:
    package dF.Wirent.functions.impl.render;

    import com.google.common.eventbus.Subscribe;
    import dF.Wirent.events.AttackEvent;
    import dF.Wirent.events.EventDisplay;
    import dF.Wirent.functions.api.Category;
    import dF.Wirent.functions.api.Function;
    import dF.Wirent.functions.api.FunctionRegister;
    import dF.Wirent.functions.impl.render.HUD;
    import dF.Wirent.functions.settings.impl.ModeSetting;
    import dF.Wirent.functions.settings.impl.SliderSetting;
    import dF.Wirent.utils.math.Vector4i;
    import dF.Wirent.utils.projections.ProjectionUtil;
    import dF.Wirent.utils.render.ColorUtils;
    import dF.Wirent.utils.render.DisplayUtils;
    import dF.Wirent.utils.render.font.Fonts;
    import java.util.concurrent.CopyOnWriteArrayList;
    import java.util.concurrent.ThreadLocalRandom;
    import net.minecraft.block.BlockState;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.WorldRenderer;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.LivingEntity;
    import net.minecraft.entity.player.PlayerEntity;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.math.AxisAlignedBB;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.util.math.BlockRayTraceResult;
    import net.minecraft.util.math.RayTraceContext;
    import net.minecraft.util.math.RayTraceResult;
    import net.minecraft.util.math.vector.Vector2f;
    import net.minecraft.util.math.vector.Vector3d;

    @FunctionRegister(name="Particles", type=Category.Render)
    public class Particles
            extends Function {
        private final ModeSetting setting = new ModeSetting("\u0412\u0438\u0434", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u041e\u0440\u0431\u0438\u0437\u044b", "\u041c\u043e\u043b\u043d\u0438\u044f", "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438", "Star");
        private final ModeSetting sigma = new ModeSetting("Вид", "1", "1", "2");
        private final SliderSetting value = new SliderSetting("\u041a\u043e\u043b-\u0432\u043e \u0437\u0430 \u0443\u0434\u0430\u0440", 20.0f, 1.0f, 50.0f, 1.0f);
        private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList();

        public Particles() {
            this.addSettings(this.setting,this.sigma, this.value);
        }

        @Override
        protected float[] rotations(PlayerEntity player) {
            return new float[0];
        }

        private boolean isInView(Vector3d pos) {
            WorldRenderer.frustum.setCameraPosition(Particles.mc.getRenderManager().info.getProjectedView().x, Particles.mc.getRenderManager().info.getProjectedView().y, Particles.mc.getRenderManager().info.getProjectedView().z);
            return WorldRenderer.frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
        }

        private boolean isVisible(Vector3d pos) {
            Vector3d cameraPos = Particles.mc.getRenderManager().info.getProjectedView();
            RayTraceContext context = new RayTraceContext(cameraPos, pos, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, Minecraft.player);
            BlockRayTraceResult result = Minecraft.world.rayTraceBlocks(context);
            return result.getType() == RayTraceResult.Type.MISS;
        }

        @Subscribe
        private void onUpdate(AttackEvent e) {
            if (e.entity == Minecraft.player) {
                return;
            }
            Entity entity2 = e.entity;
            if (entity2 instanceof LivingEntity) {
                LivingEntity livingEntity = (LivingEntity) entity2;
                Vector3d center = livingEntity.getPositionVec().add(0.0, livingEntity.getHeight() / 2.0f, 0.0);
                int i = 0;
                while ((float) i < ((Float) this.value.get()).floatValue()) {
                    this.particles.add(new Particle(center));
                    ++i;
                }
            }
        }

        @Subscribe
        private void onDisplay(EventDisplay e) {
            block22:
            {
                block21:
                {
                    if (Minecraft.player == null) break block21;
                    if (Minecraft.world != null && e.getType() == EventDisplay.Type.PRE) break block22;
                }
                return;
            }
            for (Particle p : this.particles) {
                if (System.currentTimeMillis() - p.time > 7000L || p.alpha <= 0.0f) {
                    this.particles.remove(p);
                    continue;
                }
                if (Minecraft.player.getPositionVec().distanceTo(p.pos) > 30.0) {
                    this.particles.remove(p);
                    continue;
                }
                if (this.isInView(p.pos) && this.isVisible(p.pos)) {
                    p.update();
                    Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);
                    float size = 1.0f - (float) (System.currentTimeMillis() - p.time) / 7000.0f;
                    ResourceLocation logo = new ResourceLocation("W1rent/images/star.png");
                    Vector4i colors = new Vector4i(HUD.getColor(0, 1.0f), HUD.getColor(90, 1.0f), HUD.getColor(180, 1.0f), HUD.getColor(270, 1.0f));
                    switch ((String) this.setting.get()) {
                        case "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438": {
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438": {
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u041c\u043e\u043b\u043d\u0438\u044f": {
                            Fonts.damage.drawText(e.getMatrixStack(), "C", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u041e\u0440\u0431\u0438\u0437\u044b": {
                            DisplayUtils.drawCircle(pos.x, pos.y, 5.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
                            break;
                        }
                        case "Custom": {
                            DisplayUtils.drawImage(logo, pos.x, pos.y, 30.0f * size, 30.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
                        }
                    }
                    continue;
                }
                this.particles.remove(p);
            }
        }

        private class Particle {
            private Vector3d pos;
            private Vector3d end;
            private long time;
            private long collisionTime = -1L;
            private Vector3d velocity;
            private float alpha;

            public Particle(Vector3d pos) {
                this.pos = pos;
                this.end = pos.add(-ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f));
                this.time = System.currentTimeMillis();
                this.velocity = new Vector3d(ThreadLocalRandom.current().nextDouble(-0.01, 0.01), ThreadLocalRandom.current().nextDouble(-0.05, -0.02), ThreadLocalRandom.current().nextDouble(-0.01, 0.01));
                this.alpha = 1.0f;
            }

            public void update() {
                if (sigma.get().equals("1")) {
                    update1();
                } else if (sigma.get().equals("2")) {
                    update2();
                }
            }

            private void update1() {
                long elapsedTime = System.currentTimeMillis() - this.time;

                // Настройки
                long totalDuration = 3000L;
                double maxHeight = 1.2;
                double spinSpeed = 0.2;
                double fallSpeed = 0.001;

                this.alpha = Math.max(0.0f, 1.0f - (float) elapsedTime / totalDuration);

                if (this.pos.y < this.end.y + maxHeight) {
                    this.velocity = new Vector3d(this.velocity.x, 0.01, this.velocity.z);
                } else {
                    this.velocity = new Vector3d(0.0, -fallSpeed, 0.0);
                }

                double angle = spinSpeed * elapsedTime;
                double offsetX = Math.cos(angle) * 0.0;
                double offsetZ = Math.sin(angle) * 0.0;

                this.pos = this.pos.add(this.velocity.x + offsetX, this.velocity.y, this.velocity.z + offsetZ);

                if (elapsedTime > totalDuration) {
                    this.alpha = 0.0f;
                }
            }

            private void update2() {
                if (this.collisionTime != -1L) {
                    long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                    this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
                }
                this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
                Vector3d newPos = this.pos.add(this.velocity);
                BlockPos particlePos = new BlockPos(newPos);
                BlockState blockState = Minecraft.world.getBlockState(particlePos);

                if (!blockState.isAir()) {
                    if (this.collisionTime == -1L) {
                        this.collisionTime = System.currentTimeMillis();
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                        this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                        this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                        this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                    }
                    this.pos = this.pos.add(this.velocity);
                } else {
                    this.pos = newPos;
                }
            }
        }
    }
 
Начинающий
Статус
Оффлайн
Регистрация
22 Июл 2024
Сообщения
154
Реакции[?]
2
Поинты[?]
2K
слиш давай еще подарок от сердца слей чето прикольно еше
 
Начинающий
Статус
Оффлайн
Регистрация
26 Авг 2022
Сообщения
74
Реакции[?]
1
Поинты[?]
1K
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
/del бесполезная хуйня которая только нагружает комп
 
Начинающий
Статус
Оффлайн
Регистрация
8 Мар 2024
Сообщения
639
Реакции[?]
2
Поинты[?]
2K
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
бля расстреляйте дизайнера
 
Начинающий
Статус
Оффлайн
Регистрация
4 Июн 2024
Сообщения
44
Реакции[?]
0
Поинты[?]
0
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
пойдет
 
Начинающий
Статус
Оффлайн
Регистрация
22 Май 2023
Сообщения
91
Реакции[?]
0
Поинты[?]
0
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.AttackEvent;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.impl.render.HUD;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.math.Vector4i;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.DisplayUtils;
import dF.Wirent.utils.render.font.Fonts;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadLocalRandom;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

@FunctionRegister(name="Particles", type=Category.Render)
public class Particles
extends Function {
private final ModeSetting setting = new ModeSetting("\u0412\u0438\u0434", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u041e\u0440\u0431\u0438\u0437\u044b", "\u041c\u043e\u043b\u043d\u0438\u044f", "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438", "Star");
private final ModeSetting sigma = new ModeSetting("Вид", "1", "1", "2");
private final SliderSetting value = new SliderSetting("\u041a\u043e\u043b-\u0432\u043e \u0437\u0430 \u0443\u0434\u0430\u0440", 20.0f, 1.0f, 50.0f, 1.0f);
private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList();

public Particles() {
this.addSettings(this.setting,this.sigma, this.value);
}

@Override
protected float[] rotations(PlayerEntity player) {
return new float[0];
}

private boolean isInView(Vector3d pos) {
WorldRenderer.frustum.setCameraPosition(Particles.mc.getRenderManager().info.getProjectedView().x, Particles.mc.getRenderManager().info.getProjectedView().y, Particles.mc.getRenderManager().info.getProjectedView().z);
return WorldRenderer.frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
}

private boolean isVisible(Vector3d pos) {
Vector3d cameraPos = Particles.mc.getRenderManager().info.getProjectedView();
RayTraceContext context = new RayTraceContext(cameraPos, pos, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, Minecraft.player);
BlockRayTraceResult result = Minecraft.world.rayTraceBlocks(context);
return result.getType() == RayTraceResult.Type.MISS;
}

@Subscribe
private void onUpdate(AttackEvent e) {
if (e.entity == Minecraft.player) {
return;
}
Entity entity2 = e.entity;
if (entity2 instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity2;
Vector3d center = livingEntity.getPositionVec().add(0.0, livingEntity.getHeight() / 2.0f, 0.0);
int i = 0;
while ((float) i < ((Float) this.value.get()).floatValue()) {
this.particles.add(new Particle(center));
++i;
}
}
}

@Subscribe
private void onDisplay(EventDisplay e) {
block22:
{
block21:
{
if (Minecraft.player == null) break block21;
if (Minecraft.world != null && e.getType() == EventDisplay.Type.PRE) break block22;
}
return;
}
for (Particle p : this.particles) {
if (System.currentTimeMillis() - p.time > 7000L || p.alpha <= 0.0f) {
this.particles.remove(p);
continue;
}
if (Minecraft.player.getPositionVec().distanceTo(p.pos) > 30.0) {
this.particles.remove(p);
continue;
}
if (this.isInView(p.pos) && this.isVisible(p.pos)) {
p.update();
Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);
float size = 1.0f - (float) (System.currentTimeMillis() - p.time) / 7000.0f;
ResourceLocation logo = new ResourceLocation("W1rent/images/star.png");
Vector4i colors = new Vector4i(HUD.getColor(0, 1.0f), HUD.getColor(90, 1.0f), HUD.getColor(180, 1.0f), HUD.getColor(270, 1.0f));
switch ((String) this.setting.get()) {
case "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438": {
Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438": {
Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u041c\u043e\u043b\u043d\u0438\u044f": {
Fonts.damage.drawText(e.getMatrixStack(), "C", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u041e\u0440\u0431\u0438\u0437\u044b": {
DisplayUtils.drawCircle(pos.x, pos.y, 5.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
break;
}
case "Custom": {
DisplayUtils.drawImage(logo, pos.x, pos.y, 30.0f * size, 30.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
}
}
continue;
}
this.particles.remove(p);
}
}

private class Particle {
private Vector3d pos;
private Vector3d end;
private long time;
private long collisionTime = -1L;
private Vector3d velocity;
private float alpha;

public Particle(Vector3d pos) {
this.pos = pos;
this.end = pos.add(-ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f));
this.time = System.currentTimeMillis();
this.velocity = new Vector3d(ThreadLocalRandom.current().nextDouble(-0.01, 0.01), ThreadLocalRandom.current().nextDouble(-0.05, -0.02), ThreadLocalRandom.current().nextDouble(-0.01, 0.01));
this.alpha = 1.0f;
}

public void update() {
if (sigma.get().equals("1")) {
update1();
} else if (sigma.get().equals("2")) {
update2();
}
}

private void update1() {
long elapsedTime = System.currentTimeMillis() - this.time;

// Настройки
long totalDuration = 3000L;
double maxHeight = 1.2;
double spinSpeed = 0.2;
double fallSpeed = 0.001;

this.alpha = Math.max(0.0f, 1.0f - (float) elapsedTime / totalDuration);

if (this.pos.y < this.end.y + maxHeight) {
this.velocity = new Vector3d(this.velocity.x, 0.01, this.velocity.z);
} else {
this.velocity = new Vector3d(0.0, -fallSpeed, 0.0);
}

double angle = spinSpeed * elapsedTime;
double offsetX = Math.cos(angle) * 0.0;
double offsetZ = Math.sin(angle) * 0.0;

this.pos = this.pos.add(this.velocity.x + offsetX, this.velocity.y, this.velocity.z + offsetZ);

if (elapsedTime > totalDuration) {
this.alpha = 0.0f;
}
}

private void update2() {
if (this.collisionTime != -1L) {
long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
}
this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
Vector3d newPos = this.pos.add(this.velocity);
BlockPos particlePos = new BlockPos(newPos);
BlockState blockState = Minecraft.world.getBlockState(particlePos);

if (!blockState.isAir()) {
if (this.collisionTime == -1L) {
this.collisionTime = System.currentTimeMillis();
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
}
this.pos = this.pos.add(this.velocity);
} else {
this.pos = newPos;
}
}
}
}

Код:
    package dF.Wirent.functions.impl.render;

    import com.google.common.eventbus.Subscribe;
    import dF.Wirent.events.AttackEvent;
    import dF.Wirent.events.EventDisplay;
    import dF.Wirent.functions.api.Category;
    import dF.Wirent.functions.api.Function;
    import dF.Wirent.functions.api.FunctionRegister;
    import dF.Wirent.functions.impl.render.HUD;
    import dF.Wirent.functions.settings.impl.ModeSetting;
    import dF.Wirent.functions.settings.impl.SliderSetting;
    import dF.Wirent.utils.math.Vector4i;
    import dF.Wirent.utils.projections.ProjectionUtil;
    import dF.Wirent.utils.render.ColorUtils;
    import dF.Wirent.utils.render.DisplayUtils;
    import dF.Wirent.utils.render.font.Fonts;
    import java.util.concurrent.CopyOnWriteArrayList;
    import java.util.concurrent.ThreadLocalRandom;
    import net.minecraft.block.BlockState;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.WorldRenderer;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.LivingEntity;
    import net.minecraft.entity.player.PlayerEntity;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.math.AxisAlignedBB;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.util.math.BlockRayTraceResult;
    import net.minecraft.util.math.RayTraceContext;
    import net.minecraft.util.math.RayTraceResult;
    import net.minecraft.util.math.vector.Vector2f;
    import net.minecraft.util.math.vector.Vector3d;

    @FunctionRegister(name="Particles", type=Category.Render)
    public class Particles
            extends Function {
        private final ModeSetting setting = new ModeSetting("\u0412\u0438\u0434", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u041e\u0440\u0431\u0438\u0437\u044b", "\u041c\u043e\u043b\u043d\u0438\u044f", "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438", "Star");
        private final ModeSetting sigma = new ModeSetting("Вид", "1", "1", "2");
        private final SliderSetting value = new SliderSetting("\u041a\u043e\u043b-\u0432\u043e \u0437\u0430 \u0443\u0434\u0430\u0440", 20.0f, 1.0f, 50.0f, 1.0f);
        private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList();

        public Particles() {
            this.addSettings(this.setting,this.sigma, this.value);
        }

        @Override
        protected float[] rotations(PlayerEntity player) {
            return new float[0];
        }

        private boolean isInView(Vector3d pos) {
            WorldRenderer.frustum.setCameraPosition(Particles.mc.getRenderManager().info.getProjectedView().x, Particles.mc.getRenderManager().info.getProjectedView().y, Particles.mc.getRenderManager().info.getProjectedView().z);
            return WorldRenderer.frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
        }

        private boolean isVisible(Vector3d pos) {
            Vector3d cameraPos = Particles.mc.getRenderManager().info.getProjectedView();
            RayTraceContext context = new RayTraceContext(cameraPos, pos, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, Minecraft.player);
            BlockRayTraceResult result = Minecraft.world.rayTraceBlocks(context);
            return result.getType() == RayTraceResult.Type.MISS;
        }

        @Subscribe
        private void onUpdate(AttackEvent e) {
            if (e.entity == Minecraft.player) {
                return;
            }
            Entity entity2 = e.entity;
            if (entity2 instanceof LivingEntity) {
                LivingEntity livingEntity = (LivingEntity) entity2;
                Vector3d center = livingEntity.getPositionVec().add(0.0, livingEntity.getHeight() / 2.0f, 0.0);
                int i = 0;
                while ((float) i < ((Float) this.value.get()).floatValue()) {
                    this.particles.add(new Particle(center));
                    ++i;
                }
            }
        }

        @Subscribe
        private void onDisplay(EventDisplay e) {
            block22:
            {
                block21:
                {
                    if (Minecraft.player == null) break block21;
                    if (Minecraft.world != null && e.getType() == EventDisplay.Type.PRE) break block22;
                }
                return;
            }
            for (Particle p : this.particles) {
                if (System.currentTimeMillis() - p.time > 7000L || p.alpha <= 0.0f) {
                    this.particles.remove(p);
                    continue;
                }
                if (Minecraft.player.getPositionVec().distanceTo(p.pos) > 30.0) {
                    this.particles.remove(p);
                    continue;
                }
                if (this.isInView(p.pos) && this.isVisible(p.pos)) {
                    p.update();
                    Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);
                    float size = 1.0f - (float) (System.currentTimeMillis() - p.time) / 7000.0f;
                    ResourceLocation logo = new ResourceLocation("W1rent/images/star.png");
                    Vector4i colors = new Vector4i(HUD.getColor(0, 1.0f), HUD.getColor(90, 1.0f), HUD.getColor(180, 1.0f), HUD.getColor(270, 1.0f));
                    switch ((String) this.setting.get()) {
                        case "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438": {
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438": {
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u041c\u043e\u043b\u043d\u0438\u044f": {
                            Fonts.damage.drawText(e.getMatrixStack(), "C", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u041e\u0440\u0431\u0438\u0437\u044b": {
                            DisplayUtils.drawCircle(pos.x, pos.y, 5.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
                            break;
                        }
                        case "Custom": {
                            DisplayUtils.drawImage(logo, pos.x, pos.y, 30.0f * size, 30.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
                        }
                    }
                    continue;
                }
                this.particles.remove(p);
            }
        }

        private class Particle {
            private Vector3d pos;
            private Vector3d end;
            private long time;
            private long collisionTime = -1L;
            private Vector3d velocity;
            private float alpha;

            public Particle(Vector3d pos) {
                this.pos = pos;
                this.end = pos.add(-ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f));
                this.time = System.currentTimeMillis();
                this.velocity = new Vector3d(ThreadLocalRandom.current().nextDouble(-0.01, 0.01), ThreadLocalRandom.current().nextDouble(-0.05, -0.02), ThreadLocalRandom.current().nextDouble(-0.01, 0.01));
                this.alpha = 1.0f;
            }

            public void update() {
                if (sigma.get().equals("1")) {
                    update1();
                } else if (sigma.get().equals("2")) {
                    update2();
                }
            }

            private void update1() {
                long elapsedTime = System.currentTimeMillis() - this.time;

                // Настройки
                long totalDuration = 3000L;
                double maxHeight = 1.2;
                double spinSpeed = 0.2;
                double fallSpeed = 0.001;

                this.alpha = Math.max(0.0f, 1.0f - (float) elapsedTime / totalDuration);

                if (this.pos.y < this.end.y + maxHeight) {
                    this.velocity = new Vector3d(this.velocity.x, 0.01, this.velocity.z);
                } else {
                    this.velocity = new Vector3d(0.0, -fallSpeed, 0.0);
                }

                double angle = spinSpeed * elapsedTime;
                double offsetX = Math.cos(angle) * 0.0;
                double offsetZ = Math.sin(angle) * 0.0;

                this.pos = this.pos.add(this.velocity.x + offsetX, this.velocity.y, this.velocity.z + offsetZ);

                if (elapsedTime > totalDuration) {
                    this.alpha = 0.0f;
                }
            }

            private void update2() {
                if (this.collisionTime != -1L) {
                    long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                    this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
                }
                this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
                Vector3d newPos = this.pos.add(this.velocity);
                BlockPos particlePos = new BlockPos(newPos);
                BlockState blockState = Minecraft.world.getBlockState(particlePos);

                if (!blockState.isAir()) {
                    if (this.collisionTime == -1L) {
                        this.collisionTime = System.currentTimeMillis();
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                        this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                        this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                        this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                    }
                    this.pos = this.pos.add(this.velocity);
                } else {
                    this.pos = newPos;
                }
            }
        }
    }
ждём фул сурс intelij ready
 
Начинающий
Статус
Оффлайн
Регистрация
29 Апр 2023
Сообщения
788
Реакции[?]
4
Поинты[?]
5K
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.AttackEvent;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.impl.render.HUD;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.math.Vector4i;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.DisplayUtils;
import dF.Wirent.utils.render.font.Fonts;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadLocalRandom;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

@FunctionRegister(name="Particles", type=Category.Render)
public class Particles
extends Function {
private final ModeSetting setting = new ModeSetting("\u0412\u0438\u0434", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u041e\u0440\u0431\u0438\u0437\u044b", "\u041c\u043e\u043b\u043d\u0438\u044f", "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438", "Star");
private final ModeSetting sigma = new ModeSetting("Вид", "1", "1", "2");
private final SliderSetting value = new SliderSetting("\u041a\u043e\u043b-\u0432\u043e \u0437\u0430 \u0443\u0434\u0430\u0440", 20.0f, 1.0f, 50.0f, 1.0f);
private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList();

public Particles() {
this.addSettings(this.setting,this.sigma, this.value);
}

@Override
protected float[] rotations(PlayerEntity player) {
return new float[0];
}

private boolean isInView(Vector3d pos) {
WorldRenderer.frustum.setCameraPosition(Particles.mc.getRenderManager().info.getProjectedView().x, Particles.mc.getRenderManager().info.getProjectedView().y, Particles.mc.getRenderManager().info.getProjectedView().z);
return WorldRenderer.frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
}

private boolean isVisible(Vector3d pos) {
Vector3d cameraPos = Particles.mc.getRenderManager().info.getProjectedView();
RayTraceContext context = new RayTraceContext(cameraPos, pos, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, Minecraft.player);
BlockRayTraceResult result = Minecraft.world.rayTraceBlocks(context);
return result.getType() == RayTraceResult.Type.MISS;
}

@Subscribe
private void onUpdate(AttackEvent e) {
if (e.entity == Minecraft.player) {
return;
}
Entity entity2 = e.entity;
if (entity2 instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity2;
Vector3d center = livingEntity.getPositionVec().add(0.0, livingEntity.getHeight() / 2.0f, 0.0);
int i = 0;
while ((float) i < ((Float) this.value.get()).floatValue()) {
this.particles.add(new Particle(center));
++i;
}
}
}

@Subscribe
private void onDisplay(EventDisplay e) {
block22:
{
block21:
{
if (Minecraft.player == null) break block21;
if (Minecraft.world != null && e.getType() == EventDisplay.Type.PRE) break block22;
}
return;
}
for (Particle p : this.particles) {
if (System.currentTimeMillis() - p.time > 7000L || p.alpha <= 0.0f) {
this.particles.remove(p);
continue;
}
if (Minecraft.player.getPositionVec().distanceTo(p.pos) > 30.0) {
this.particles.remove(p);
continue;
}
if (this.isInView(p.pos) && this.isVisible(p.pos)) {
p.update();
Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);
float size = 1.0f - (float) (System.currentTimeMillis() - p.time) / 7000.0f;
ResourceLocation logo = new ResourceLocation("W1rent/images/star.png");
Vector4i colors = new Vector4i(HUD.getColor(0, 1.0f), HUD.getColor(90, 1.0f), HUD.getColor(180, 1.0f), HUD.getColor(270, 1.0f));
switch ((String) this.setting.get()) {
case "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438": {
Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438": {
Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u041c\u043e\u043b\u043d\u0438\u044f": {
Fonts.damage.drawText(e.getMatrixStack(), "C", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
break;
}
case "\u041e\u0440\u0431\u0438\u0437\u044b": {
DisplayUtils.drawCircle(pos.x, pos.y, 5.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
break;
}
case "Custom": {
DisplayUtils.drawImage(logo, pos.x, pos.y, 30.0f * size, 30.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
}
}
continue;
}
this.particles.remove(p);
}
}

private class Particle {
private Vector3d pos;
private Vector3d end;
private long time;
private long collisionTime = -1L;
private Vector3d velocity;
private float alpha;

public Particle(Vector3d pos) {
this.pos = pos;
this.end = pos.add(-ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f));
this.time = System.currentTimeMillis();
this.velocity = new Vector3d(ThreadLocalRandom.current().nextDouble(-0.01, 0.01), ThreadLocalRandom.current().nextDouble(-0.05, -0.02), ThreadLocalRandom.current().nextDouble(-0.01, 0.01));
this.alpha = 1.0f;
}

public void update() {
if (sigma.get().equals("1")) {
update1();
} else if (sigma.get().equals("2")) {
update2();
}
}

private void update1() {
long elapsedTime = System.currentTimeMillis() - this.time;

// Настройки
long totalDuration = 3000L;
double maxHeight = 1.2;
double spinSpeed = 0.2;
double fallSpeed = 0.001;

this.alpha = Math.max(0.0f, 1.0f - (float) elapsedTime / totalDuration);

if (this.pos.y < this.end.y + maxHeight) {
this.velocity = new Vector3d(this.velocity.x, 0.01, this.velocity.z);
} else {
this.velocity = new Vector3d(0.0, -fallSpeed, 0.0);
}

double angle = spinSpeed * elapsedTime;
double offsetX = Math.cos(angle) * 0.0;
double offsetZ = Math.sin(angle) * 0.0;

this.pos = this.pos.add(this.velocity.x + offsetX, this.velocity.y, this.velocity.z + offsetZ);

if (elapsedTime > totalDuration) {
this.alpha = 0.0f;
}
}

private void update2() {
if (this.collisionTime != -1L) {
long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
}
this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
Vector3d newPos = this.pos.add(this.velocity);
BlockPos particlePos = new BlockPos(newPos);
BlockState blockState = Minecraft.world.getBlockState(particlePos);

if (!blockState.isAir()) {
if (this.collisionTime == -1L) {
this.collisionTime = System.currentTimeMillis();
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
}
if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
}
this.pos = this.pos.add(this.velocity);
} else {
this.pos = newPos;
}
}
}
}

Код:
    package dF.Wirent.functions.impl.render;

    import com.google.common.eventbus.Subscribe;
    import dF.Wirent.events.AttackEvent;
    import dF.Wirent.events.EventDisplay;
    import dF.Wirent.functions.api.Category;
    import dF.Wirent.functions.api.Function;
    import dF.Wirent.functions.api.FunctionRegister;
    import dF.Wirent.functions.impl.render.HUD;
    import dF.Wirent.functions.settings.impl.ModeSetting;
    import dF.Wirent.functions.settings.impl.SliderSetting;
    import dF.Wirent.utils.math.Vector4i;
    import dF.Wirent.utils.projections.ProjectionUtil;
    import dF.Wirent.utils.render.ColorUtils;
    import dF.Wirent.utils.render.DisplayUtils;
    import dF.Wirent.utils.render.font.Fonts;
    import java.util.concurrent.CopyOnWriteArrayList;
    import java.util.concurrent.ThreadLocalRandom;
    import net.minecraft.block.BlockState;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.WorldRenderer;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.LivingEntity;
    import net.minecraft.entity.player.PlayerEntity;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.math.AxisAlignedBB;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.util.math.BlockRayTraceResult;
    import net.minecraft.util.math.RayTraceContext;
    import net.minecraft.util.math.RayTraceResult;
    import net.minecraft.util.math.vector.Vector2f;
    import net.minecraft.util.math.vector.Vector3d;

    @FunctionRegister(name="Particles", type=Category.Render)
    public class Particles
            extends Function {
        private final ModeSetting setting = new ModeSetting("\u0412\u0438\u0434", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438", "\u041e\u0440\u0431\u0438\u0437\u044b", "\u041c\u043e\u043b\u043d\u0438\u044f", "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438", "Star");
        private final ModeSetting sigma = new ModeSetting("Вид", "1", "1", "2");
        private final SliderSetting value = new SliderSetting("\u041a\u043e\u043b-\u0432\u043e \u0437\u0430 \u0443\u0434\u0430\u0440", 20.0f, 1.0f, 50.0f, 1.0f);
        private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList();

        public Particles() {
            this.addSettings(this.setting,this.sigma, this.value);
        }

        @Override
        protected float[] rotations(PlayerEntity player) {
            return new float[0];
        }

        private boolean isInView(Vector3d pos) {
            WorldRenderer.frustum.setCameraPosition(Particles.mc.getRenderManager().info.getProjectedView().x, Particles.mc.getRenderManager().info.getProjectedView().y, Particles.mc.getRenderManager().info.getProjectedView().z);
            return WorldRenderer.frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
        }

        private boolean isVisible(Vector3d pos) {
            Vector3d cameraPos = Particles.mc.getRenderManager().info.getProjectedView();
            RayTraceContext context = new RayTraceContext(cameraPos, pos, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, Minecraft.player);
            BlockRayTraceResult result = Minecraft.world.rayTraceBlocks(context);
            return result.getType() == RayTraceResult.Type.MISS;
        }

        @Subscribe
        private void onUpdate(AttackEvent e) {
            if (e.entity == Minecraft.player) {
                return;
            }
            Entity entity2 = e.entity;
            if (entity2 instanceof LivingEntity) {
                LivingEntity livingEntity = (LivingEntity) entity2;
                Vector3d center = livingEntity.getPositionVec().add(0.0, livingEntity.getHeight() / 2.0f, 0.0);
                int i = 0;
                while ((float) i < ((Float) this.value.get()).floatValue()) {
                    this.particles.add(new Particle(center));
                    ++i;
                }
            }
        }

        @Subscribe
        private void onDisplay(EventDisplay e) {
            block22:
            {
                block21:
                {
                    if (Minecraft.player == null) break block21;
                    if (Minecraft.world != null && e.getType() == EventDisplay.Type.PRE) break block22;
                }
                return;
            }
            for (Particle p : this.particles) {
                if (System.currentTimeMillis() - p.time > 7000L || p.alpha <= 0.0f) {
                    this.particles.remove(p);
                    continue;
                }
                if (Minecraft.player.getPositionVec().distanceTo(p.pos) > 30.0) {
                    this.particles.remove(p);
                    continue;
                }
                if (this.isInView(p.pos) && this.isVisible(p.pos)) {
                    p.update();
                    Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);
                    float size = 1.0f - (float) (System.currentTimeMillis() - p.time) / 7000.0f;
                    ResourceLocation logo = new ResourceLocation("W1rent/images/star.png");
                    Vector4i colors = new Vector4i(HUD.getColor(0, 1.0f), HUD.getColor(90, 1.0f), HUD.getColor(180, 1.0f), HUD.getColor(270, 1.0f));
                    switch ((String) this.setting.get()) {
                        case "\u0421\u0435\u0440\u0434\u0435\u0447\u043a\u0438": {
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u0421\u043d\u0435\u0436\u0438\u043d\u043a\u0438": {
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u041c\u043e\u043b\u043d\u0438\u044f": {
                            Fonts.damage.drawText(e.getMatrixStack(), "C", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                            break;
                        }
                        case "\u041e\u0440\u0431\u0438\u0437\u044b": {
                            DisplayUtils.drawCircle(pos.x, pos.y, 5.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
                            break;
                        }
                        case "Custom": {
                            DisplayUtils.drawImage(logo, pos.x, pos.y, 30.0f * size, 30.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)));
                        }
                    }
                    continue;
                }
                this.particles.remove(p);
            }
        }

        private class Particle {
            private Vector3d pos;
            private Vector3d end;
            private long time;
            private long collisionTime = -1L;
            private Vector3d velocity;
            private float alpha;

            public Particle(Vector3d pos) {
                this.pos = pos;
                this.end = pos.add(-ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f), -ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f));
                this.time = System.currentTimeMillis();
                this.velocity = new Vector3d(ThreadLocalRandom.current().nextDouble(-0.01, 0.01), ThreadLocalRandom.current().nextDouble(-0.05, -0.02), ThreadLocalRandom.current().nextDouble(-0.01, 0.01));
                this.alpha = 1.0f;
            }

            public void update() {
                if (sigma.get().equals("1")) {
                    update1();
                } else if (sigma.get().equals("2")) {
                    update2();
                }
            }

            private void update1() {
                long elapsedTime = System.currentTimeMillis() - this.time;

                // Настройки
                long totalDuration = 3000L;
                double maxHeight = 1.2;
                double spinSpeed = 0.2;
                double fallSpeed = 0.001;

                this.alpha = Math.max(0.0f, 1.0f - (float) elapsedTime / totalDuration);

                if (this.pos.y < this.end.y + maxHeight) {
                    this.velocity = new Vector3d(this.velocity.x, 0.01, this.velocity.z);
                } else {
                    this.velocity = new Vector3d(0.0, -fallSpeed, 0.0);
                }

                double angle = spinSpeed * elapsedTime;
                double offsetX = Math.cos(angle) * 0.0;
                double offsetZ = Math.sin(angle) * 0.0;

                this.pos = this.pos.add(this.velocity.x + offsetX, this.velocity.y, this.velocity.z + offsetZ);

                if (elapsedTime > totalDuration) {
                    this.alpha = 0.0f;
                }
            }

            private void update2() {
                if (this.collisionTime != -1L) {
                    long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                    this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
                }
                this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
                Vector3d newPos = this.pos.add(this.velocity);
                BlockPos particlePos = new BlockPos(newPos);
                BlockState blockState = Minecraft.world.getBlockState(particlePos);

                if (!blockState.isAir()) {
                    if (this.collisionTime == -1L) {
                        this.collisionTime = System.currentTimeMillis();
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                        this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                        this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                    }
                    if (!Minecraft.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                        this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                    }
                    this.pos = this.pos.add(this.velocity);
                } else {
                    this.pos = newPos;
                }
            }
        }
    }
слить фулл сурс - ✖, сливать по 1 функции - ✔
 
Начинающий
Статус
Оффлайн
Регистрация
16 Авг 2024
Сообщения
28
Реакции[?]
2
Поинты[?]
2K
Код:
                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                       
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
Сука, зачем объясните нахуя вам партиклы одних видов в небе, сделайте их массивом и спавните по рандому и У ВАС БУДЕТ ВСЁ СРАЗУ, нахуй делать этот свитч с десятками партиклов
 
Начинающий
Статус
Оффлайн
Регистрация
25 Фев 2024
Сообщения
222
Реакции[?]
4
Поинты[?]
1K
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
кринж через 2д делать партиклы какой же кринж
 
Забаненный
Статус
Оффлайн
Регистрация
10 Май 2023
Сообщения
827
Реакции[?]
9
Поинты[?]
3K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
сказал мега селф кодер гамболоф (незаметно запастил в свой гумбулуф клиент)
Код:
package dF.Wirent.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import dF.Wirent.events.EventDisplay;
import dF.Wirent.functions.api.Category;
import dF.Wirent.functions.api.Function;
import dF.Wirent.functions.api.FunctionRegister;
import dF.Wirent.functions.settings.impl.ModeSetting;
import dF.Wirent.functions.settings.impl.SliderSetting;
import dF.Wirent.utils.client.IMinecraft;
import dF.Wirent.utils.math.MathUtil;
import dF.Wirent.utils.projections.ProjectionUtil;
import dF.Wirent.utils.render.ColorUtils;
import dF.Wirent.utils.render.font.Fonts;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Snow", type = Category.Render)
public class Snow extends Function {
    // Добавляем новый ModeSetting для выбора логики падения
    private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки");
    private final ModeSetting setting = new ModeSetting("Вид", "Звёздочки", "Сердечки", "Молния", "Эмодзи", "Снежинки");
    public static final SliderSetting speedSetting = new SliderSetting("Скорость", 0, 0, 0.1f, 0.01f);

    private final List<Particle> particles = new ArrayList<>();

    public Snow() {
        addSettings(fallModeSetting, setting, speedSetting);
    }

    @Override
    protected float[] rotations(PlayerEntity var1) {
        return new float[0];
    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(
                IMinecraft.mc.getRenderManager().info.getProjectedView().x,
                IMinecraft.mc.getRenderManager().info.getProjectedView().y,
                IMinecraft.mc.getRenderManager().info.getProjectedView().z
        );
        return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.player == null || mc.world == null || e.getType() != EventDisplay.Type.PRE) {
            return;
        }

        particles.add(new Particle());

        Iterator<Particle> iterator = particles.iterator();
        while (iterator.hasNext()) {
            Particle p = iterator.next();

            if (System.currentTimeMillis() - p.time > 5000) {
                iterator.remove();
                continue;
            }

            if (mc.player.getPositionVec().distanceTo(p.pos) > 30) {
                iterator.remove();
                continue;
            }

            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    iterator.remove();
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1 - ((System.currentTimeMillis() - p.time) / 5000f);

                int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 1), (int) ((155 * p.alpha) * size));
                float scaleFactor = 15 * size;

                switch (setting.get()) {
                    case "Сердечки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "C", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Пенисы" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "B", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Звёздочки" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Эмодзи" ->
                            Fonts.test521488.drawText(e.getMatrixStack(), "D", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Снежинки" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "A", pos.x - 3 * size, pos.y - 3 * size, color, scaleFactor, 0.05f);
                    case "Молния" ->
                            Fonts.damage.drawText(e.getMatrixStack(), "B", pos.x - 3.0f * size, pos.y - 3.0f * size, ColorUtils.setAlpha(HUD.getColor(this.particles.indexOf(p), 1.0f), (int) (200.0f * p.alpha * size)), 15.0f * size, 0.05f);
                }
            } else {
                iterator.remove();
            }
        }
    }

    private class Particle {
        private Vector3d pos;
        private final long time;
        private float alpha;
        private Vector3d velocity;
        private long collisionTime = -1L;

        public Particle() {
            pos = mc.player.getPositionVec().add(
                    ThreadLocalRandom.current().nextDouble(-20, 20),
                    ThreadLocalRandom.current().nextDouble(-5, 20),
                    ThreadLocalRandom.current().nextDouble(-20, 20)
            );
            time = System.currentTimeMillis();
            double speed = (double) speedSetting.get();
            velocity = new Vector3d(0, -speed, 0);
        }

        public void update() {
            if (fallModeSetting.get().equals("Простой")) {
                updateSimple();
            } else if (fallModeSetting.get().equals("Отскоки")) {
                updateWithBounce();
            }
        }

        private void updateSimple() {
            alpha = MathUtil.fast(alpha, 1, 10);
            pos = pos.add(velocity);
            if (pos.y < mc.player.getPositionVec().y - 5) {
                pos = mc.player.getPositionVec().add(
                        ThreadLocalRandom.current().nextDouble(-20, 20),
                        ThreadLocalRandom.current().nextDouble(10, 20),
                        ThreadLocalRandom.current().nextDouble(-20, 20)
                );
            }
        }

        private void updateWithBounce() {
            if (this.collisionTime != -1L) {
                long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
                this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
            }

            this.velocity = this.velocity.add(0.0, -8.0E-4, 0.0);
            Vector3d newPos = this.pos.add(this.velocity);
            BlockPos particlePos = new BlockPos(newPos);
            BlockState blockState = mc.world.getBlockState(particlePos);
            if (!blockState.isAir()) {
                if (this.collisionTime == -1L) {
                    this.collisionTime = System.currentTimeMillis();
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x + this.velocity.x, this.pos.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(0.0, this.velocity.y, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y + this.velocity.y, this.pos.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, -this.velocity.y * 0.8, this.velocity.z);
                }
                if (!mc.world.getBlockState(new BlockPos(this.pos.x, this.pos.y, this.pos.z + this.velocity.z)).isAir()) {
                    this.velocity = new Vector3d(this.velocity.x, this.velocity.y, 0.0);
                }
                this.pos = this.pos.add(this.velocity);
            } else {
                this.pos = newPos;
            }
        }
    }
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
выглядит если честно хуево, а сама идея классная
че ты там югейм кли... ой премку купил у тебя кто-то?
"югейм клиент" насмешил
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
24 Июл 2022
Сообщения
261
Реакции[?]
2
Поинты[?]
1K
сказал мега селф кодер гамболоф (незаметно запастил в свой гумбулуф клиент)

выглядит если честно хуево, а сама идея классная

"югейм клиент" насмешил
Сказал человек который кроме базы Экспениса ничего в шарах своих не видел
 
Сверху Снизу