Визуальная часть Particles Exp 3.1

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
3 Мар 2024
Сообщения
107
Реакции
0

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

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

Спасибо!

на вам партиклы с пасты(ассетсы свои закиньте пж ) :roflanPominki:


Пожалуйста, авторизуйтесь для просмотра ссылки.



Код:
Expand Collapse Copy
package im.expensive.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.events.AttackEvent;
import im.expensive.events.EventDisplay;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.projections.ProjectionUtil;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadLocalRandom;

import static com.mojang.blaze3d.platform.GlStateManager.DestFactor.ONE;
import static com.mojang.blaze3d.platform.GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA;
import static com.mojang.blaze3d.platform.GlStateManager.SourceFactor.SRC_ALPHA;
import static com.mojang.blaze3d.systems.RenderSystem.blendFunc;
import static com.mojang.blaze3d.systems.RenderSystem.depthMask;
import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Particles", server = "", description = "", type = Category.Render)
public class Particles extends Function {
    private final ResourceLocation star = new ResourceLocation("expensive/images/stars.png");
    private final ResourceLocation skull = new ResourceLocation("expensive/images/skull.png");
    private final ResourceLocation d = new ResourceLocation("expensive/images/f.png");
    private final ResourceLocation dg = new ResourceLocation("expensive/images/glow.png");
    private final ResourceLocation heart = new ResourceLocation("expensive/images/Combat.png");
    private final ResourceLocation flower = new ResourceLocation("expensive/images/flower.png");
    private final ResourceLocation quads = new ResourceLocation("expensive/images/quads.png");
    private final ResourceLocation Crown = new ResourceLocation("expensive/images/crown.png");
    private final ResourceLocation treug = new ResourceLocation("expensive/images/trugol.png");
    private final ResourceLocation amogus = new ResourceLocation("expensive/images/amongus.png");
    private final ResourceLocation cross = new ResourceLocation("expensive/images/cross.png");
    private final ResourceLocation romb = new ResourceLocation("expensive/images/rhombus.png");
    private final ResourceLocation zvez = new ResourceLocation("expensive/images/star.png");
    private final ResourceLocation lightning = new ResourceLocation("expensive/images/lightning.png");

    private final List<ResourceLocation> textures = Arrays.asList(star, dg,  flower,lightning,zvez,romb ,cross);
    private final ModeSetting setting = new ModeSetting("Вид", "Случайный" ,"Случайный","Звёздочки","lightning", "Звез","Снежинки","Квадратики","Мечи","Крест", "Орбизы", "Череп", "Цветок","Ромб" ,"Корона", "Амогус");
    private final SliderSetting value = new SliderSetting("Кол-во за удар", 20.0f, 1.0f, 50.0f, 1.0f);
    private final SliderSetting glowIntensity = new SliderSetting("Свечение", 2, 0, 10, 1);
    private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList<>();

    public Particles() {
        addSettings(value, glowIntensity,setting);
    }

    @Override
    public void onUpdate(EventUpdate e) {

    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(mc.getRenderManager().info.getProjectedView().x,
                mc.getRenderManager().info.getProjectedView().y,
                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
    public void onUpdate(AttackEvent e) {
        if (e.entity == mc.player) return;
        if (e.entity instanceof LivingEntity livingEntity) {
            for (int i = 0; i < value.get(); i++) {
                Vector3d entityPos = livingEntity.getPositon(mc.getRenderPartialTicks());
                Vector3d randomOffset = new Vector3d(
                        ThreadLocalRandom.current().nextDouble(-0.5, 0.5),
                        ThreadLocalRandom.current().nextDouble(-0.2, 0.8),
                        ThreadLocalRandom.current().nextDouble(-0.5, 0.5)
                );
                ResourceLocation texture;
                if (setting.get().equalsIgnoreCase("Случайный")) {
                    texture = textures.get(ThreadLocalRandom.current().nextInt(textures.size()));
                } else {
                    switch (setting.get()) {
                        case "Мечи" -> texture = heart;
                        case "Звёздочки" -> texture = star;
                        case "Снежинки" -> texture = d;
                        case "Орбизы" -> texture = dg;
                        case "Череп" -> texture = skull;
                        case "Цветок" -> texture = flower;
                        case "Корона" -> texture = Crown;
                        case "Амогус" -> texture = amogus;
                        case "Треугольник" -> texture = treug;
                        case "Крест" -> texture = cross;
                        case "Квадратики" -> texture = quads;
                        case "Ромб" -> texture = romb;
                        case "Звез" -> texture = zvez;
                        case "lightning" -> texture = lightning;

                        default -> texture = star;
                    }
                }
                particles.add(new Particle(entityPos.add(randomOffset).add(0, livingEntity.getHeight() / 2f, 0), texture));
            }
        }
    }

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

        for (Particle p : particles) {
            if (System.currentTimeMillis() - p.time > 3500f) {
                particles.remove(p);
                continue;
            }
            if (mc.player.getPositionVec().distanceTo(p.pos) > 100) {
                particles.remove(p);
                continue;
            }
            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    particles.remove(p);
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1.3F - ((System.currentTimeMillis() - p.time) / 3300f);


                drawGlow(stack, p, pos, size, 1);

            } else {
                particles.remove(p);
            }
        }
    }
    private void drawGlow(MatrixStack stack, Particle p, Vector2f pos, float size, int intensity) {

        float alpha = p.alpha;
        int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 6), (int) ((200 * alpha) * size));





        for (int i = 1; i <= glowIntensity.get(); i++) {
            float offset = i * 0.5f * size;

            stack.push();
            depthMask(false);

            blendFunc(SRC_ALPHA, ONE);
            DisplayUtils.drawImage(p.texture, pos.x - offset - 3.0F * size, pos.y - offset - 3.0F * size, 16 * size , 16 * size,  ColorUtils.setAlpha(color, (int) ((100 * p.alpha) * (size / (float) i))));

            blendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);

            DisplayUtils.drawImage(p.texture, pos.x - 3.0F * size, pos.y - 3.0F * size, 16 * size, 16 * size, color);

            depthMask(true);
            stack.pop();
        }
    }
    private class Particle {
        private Vector3d pos;
        private Vector3d velocity;
        private final Vector3d end;
        private final long time;
        private final ResourceLocation texture;

        private float alpha;

        public Particle(Vector3d pos, ResourceLocation texture) {
            this.pos = pos;
            this.texture = texture;
            this.velocity = new Vector3d(
                    ThreadLocalRandom.current().nextDouble(-0.08, 0.08),
                    ThreadLocalRandom.current().nextDouble(0.02, 0.1),
                    ThreadLocalRandom.current().nextDouble(-0.08, 0.08)
            );
            end = pos.add(
                    ThreadLocalRandom.current().nextDouble(-2.0, 2.0),
                    ThreadLocalRandom.current().nextDouble(-2.0, 2.0),
                    ThreadLocalRandom.current().nextDouble(-2.0, 2.0)
            );
            time = System.currentTimeMillis();
        }

        public void update() {
            alpha = MathUtil.fast(alpha, 1, 10);
            velocity = velocity.add(0, -0.0004, 0);
            pos = pos.add(velocity);
            BlockPos blockPos = new BlockPos(pos.x, pos.y, pos.z);
            if (mc.world.getBlockState(blockPos).getMaterial().isSolid()) {
                double yCorrection = blockPos.getY() + 1 - pos.y;
                pos = pos.add(0, yCorrection, 0);
                velocity = Vector3d.ZERO;
            }
            pos = MathUtil.fast(pos, end, 0.5f);
        }
    }
}
 
2Д хуйня
/del
 
норм но дай картинки
 
Что у тебя за градиент?
 
Скинь images для партиклов
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
че делать то?
 

Вложения

  • зображення_2025-02-21_125101650.png
    зображення_2025-02-21_125101650.png
    61 KB · Просмотры: 167
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
на вам партиклы с пасты(ассетсы свои закиньте пж ) :roflanPominki:


Пожалуйста, авторизуйтесь для просмотра ссылки.



Код:
Expand Collapse Copy
package im.expensive.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.events.AttackEvent;
import im.expensive.events.EventDisplay;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.projections.ProjectionUtil;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadLocalRandom;

import static com.mojang.blaze3d.platform.GlStateManager.DestFactor.ONE;
import static com.mojang.blaze3d.platform.GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA;
import static com.mojang.blaze3d.platform.GlStateManager.SourceFactor.SRC_ALPHA;
import static com.mojang.blaze3d.systems.RenderSystem.blendFunc;
import static com.mojang.blaze3d.systems.RenderSystem.depthMask;
import static net.minecraft.client.renderer.WorldRenderer.frustum;

@FunctionRegister(name = "Particles", server = "", description = "", type = Category.Render)
public class Particles extends Function {
    private final ResourceLocation star = new ResourceLocation("expensive/images/stars.png");
    private final ResourceLocation skull = new ResourceLocation("expensive/images/skull.png");
    private final ResourceLocation d = new ResourceLocation("expensive/images/f.png");
    private final ResourceLocation dg = new ResourceLocation("expensive/images/glow.png");
    private final ResourceLocation heart = new ResourceLocation("expensive/images/Combat.png");
    private final ResourceLocation flower = new ResourceLocation("expensive/images/flower.png");
    private final ResourceLocation quads = new ResourceLocation("expensive/images/quads.png");
    private final ResourceLocation Crown = new ResourceLocation("expensive/images/crown.png");
    private final ResourceLocation treug = new ResourceLocation("expensive/images/trugol.png");
    private final ResourceLocation amogus = new ResourceLocation("expensive/images/amongus.png");
    private final ResourceLocation cross = new ResourceLocation("expensive/images/cross.png");
    private final ResourceLocation romb = new ResourceLocation("expensive/images/rhombus.png");
    private final ResourceLocation zvez = new ResourceLocation("expensive/images/star.png");
    private final ResourceLocation lightning = new ResourceLocation("expensive/images/lightning.png");

    private final List<ResourceLocation> textures = Arrays.asList(star, dg,  flower,lightning,zvez,romb ,cross);
    private final ModeSetting setting = new ModeSetting("Вид", "Случайный" ,"Случайный","Звёздочки","lightning", "Звез","Снежинки","Квадратики","Мечи","Крест", "Орбизы", "Череп", "Цветок","Ромб" ,"Корона", "Амогус");
    private final SliderSetting value = new SliderSetting("Кол-во за удар", 20.0f, 1.0f, 50.0f, 1.0f);
    private final SliderSetting glowIntensity = new SliderSetting("Свечение", 2, 0, 10, 1);
    private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList<>();

    public Particles() {
        addSettings(value, glowIntensity,setting);
    }

    @Override
    public void onUpdate(EventUpdate e) {

    }

    private boolean isInView(Vector3d pos) {
        frustum.setCameraPosition(mc.getRenderManager().info.getProjectedView().x,
                mc.getRenderManager().info.getProjectedView().y,
                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
    public void onUpdate(AttackEvent e) {
        if (e.entity == mc.player) return;
        if (e.entity instanceof LivingEntity livingEntity) {
            for (int i = 0; i < value.get(); i++) {
                Vector3d entityPos = livingEntity.getPositon(mc.getRenderPartialTicks());
                Vector3d randomOffset = new Vector3d(
                        ThreadLocalRandom.current().nextDouble(-0.5, 0.5),
                        ThreadLocalRandom.current().nextDouble(-0.2, 0.8),
                        ThreadLocalRandom.current().nextDouble(-0.5, 0.5)
                );
                ResourceLocation texture;
                if (setting.get().equalsIgnoreCase("Случайный")) {
                    texture = textures.get(ThreadLocalRandom.current().nextInt(textures.size()));
                } else {
                    switch (setting.get()) {
                        case "Мечи" -> texture = heart;
                        case "Звёздочки" -> texture = star;
                        case "Снежинки" -> texture = d;
                        case "Орбизы" -> texture = dg;
                        case "Череп" -> texture = skull;
                        case "Цветок" -> texture = flower;
                        case "Корона" -> texture = Crown;
                        case "Амогус" -> texture = amogus;
                        case "Треугольник" -> texture = treug;
                        case "Крест" -> texture = cross;
                        case "Квадратики" -> texture = quads;
                        case "Ромб" -> texture = romb;
                        case "Звез" -> texture = zvez;
                        case "lightning" -> texture = lightning;

                        default -> texture = star;
                    }
                }
                particles.add(new Particle(entityPos.add(randomOffset).add(0, livingEntity.getHeight() / 2f, 0), texture));
            }
        }
    }

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

        for (Particle p : particles) {
            if (System.currentTimeMillis() - p.time > 3500f) {
                particles.remove(p);
                continue;
            }
            if (mc.player.getPositionVec().distanceTo(p.pos) > 100) {
                particles.remove(p);
                continue;
            }
            if (isInView(p.pos)) {
                if (!mc.player.canEntityBeSeen(p.pos)) {
                    particles.remove(p);
                    continue;
                }
                p.update();
                Vector2f pos = ProjectionUtil.project(p.pos.x, p.pos.y, p.pos.z);

                float size = 1.3F - ((System.currentTimeMillis() - p.time) / 3300f);


                drawGlow(stack, p, pos, size, 1);

            } else {
                particles.remove(p);
            }
        }
    }
    private void drawGlow(MatrixStack stack, Particle p, Vector2f pos, float size, int intensity) {

        float alpha = p.alpha;
        int color = ColorUtils.setAlpha(HUD.getColor(particles.indexOf(p), 6), (int) ((200 * alpha) * size));





        for (int i = 1; i <= glowIntensity.get(); i++) {
            float offset = i * 0.5f * size;

            stack.push();
            depthMask(false);

            blendFunc(SRC_ALPHA, ONE);
            DisplayUtils.drawImage(p.texture, pos.x - offset - 3.0F * size, pos.y - offset - 3.0F * size, 16 * size , 16 * size,  ColorUtils.setAlpha(color, (int) ((100 * p.alpha) * (size / (float) i))));

            blendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);

            DisplayUtils.drawImage(p.texture, pos.x - 3.0F * size, pos.y - 3.0F * size, 16 * size, 16 * size, color);

            depthMask(true);
            stack.pop();
        }
    }
    private class Particle {
        private Vector3d pos;
        private Vector3d velocity;
        private final Vector3d end;
        private final long time;
        private final ResourceLocation texture;

        private float alpha;

        public Particle(Vector3d pos, ResourceLocation texture) {
            this.pos = pos;
            this.texture = texture;
            this.velocity = new Vector3d(
                    ThreadLocalRandom.current().nextDouble(-0.08, 0.08),
                    ThreadLocalRandom.current().nextDouble(0.02, 0.1),
                    ThreadLocalRandom.current().nextDouble(-0.08, 0.08)
            );
            end = pos.add(
                    ThreadLocalRandom.current().nextDouble(-2.0, 2.0),
                    ThreadLocalRandom.current().nextDouble(-2.0, 2.0),
                    ThreadLocalRandom.current().nextDouble(-2.0, 2.0)
            );
            time = System.currentTimeMillis();
        }

        public void update() {
            alpha = MathUtil.fast(alpha, 1, 10);
            velocity = velocity.add(0, -0.0004, 0);
            pos = pos.add(velocity);
            BlockPos blockPos = new BlockPos(pos.x, pos.y, pos.z);
            if (mc.world.getBlockState(blockPos).getMaterial().isSolid()) {
                double yCorrection = blockPos.getY() + 1 - pos.y;
                pos = pos.add(0, yCorrection, 0);
                velocity = Vector3d.ZERO;
            }
            pos = MathUtil.fast(pos, end, 0.5f);
        }
    }
}
дай кликгуи пж
 

Похожие темы

Назад
Сверху Снизу