• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Визуальная часть Светлячки на Excellent Recode

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
15 Май 2024
Сообщения
43
Реакции
1
Выберите загрузчик игры
  1. Vanilla
1745595017778.png

1745595026314.png


Пнг и тд дефолтное вам просто нужно будет добавить клас в базу и добавить модуль в модуль менеджер


Java:
Expand Collapse Copy
package org.excellent.client.managers.module.impl.render;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.Namespaced;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
import net.mojang.blaze3d.matrix.MatrixStack;
import net.mojang.blaze3d.platform.GlStateManager;
import net.mojang.blaze3d.systems.RenderSystem;
import org.excellent.client.api.events.orbit.EventHandler;
import org.excellent.client.managers.events.player.MotionEvent;
import org.excellent.client.managers.events.render.Render3DPosedEvent;
import org.excellent.client.managers.events.world.WorldChangeEvent;
import org.excellent.client.managers.module.Category;
import org.excellent.client.managers.module.Module;
import org.excellent.client.managers.module.ModuleInfo;
import org.excellent.client.managers.module.impl.client.Theme;
import org.excellent.client.managers.module.settings.impl.BooleanSetting;
import org.excellent.client.managers.module.settings.impl.ModeSetting;
import org.excellent.client.managers.module.settings.impl.SliderSetting;
import org.excellent.client.utils.animation.Animation;
import org.excellent.client.utils.animation.util.Easings;
import org.excellent.client.utils.math.Mathf;
import org.excellent.client.utils.other.Instance;
import org.excellent.client.utils.player.PlayerUtil;
import org.excellent.client.utils.render.color.ColorUtil;
import org.excellent.client.utils.render.draw.RectUtil;
import org.excellent.client.utils.render.draw.RenderUtil;
import org.excellent.client.utils.render.draw.RenderUtil3D;
import org.excellent.common.impl.fastrandom.FastRandom;
import org.excellent.lib.util.time.StopWatch;

import java.util.ArrayList;
import java.util.List;

@Getter
@Accessors(fluent = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@ModuleInfo(name = "Comets", category = Category.RENDER)
public class Comets extends Module {
    public static Comets getInstance() {
        return Instance.get(Comets.class);
    }

    private final SliderSetting cometCount = new SliderSetting(this, "Количество комет", 3, 1, 10, 1);
    private final SliderSetting cometSize = new SliderSetting(this, "Размер комет", 0.5F, 0.2F, 1.5F, 0.1F);
    private final SliderSetting cometSpeed = new SliderSetting(this, "Скорость комет", 1.0F, 0.1F, 3.0F, 0.1F);
    private final SliderSetting particleCount = new SliderSetting(this, "Частиц за комету", 40, 10, 100, 5);
    private final SliderSetting particleLifetime = new SliderSetting(this, "Время жизни частиц", 1.0F, 0.5F, 3.0F, 0.1F);
    private final SliderSetting maxDistance = new SliderSetting(this, "Макс. радиус", 15.0F, 5.0F, 30.0F, 1.0F);
    private final SliderSetting opacity = new SliderSetting(this, "Прозрачность", 1.0F, 0.1F, 1.0F, 0.1F);
    private final BooleanSetting glowing = new BooleanSetting(this, "Свечение", true);
    private final ModeSetting particleType = new ModeSetting(this, "Тип частиц",
            "Circle",
            "Bloom",
            "Star",
            "Heart"
    ).set("Bloom");

    private final List<CometParticle> cometParticles = new ArrayList<>();
    private final List<Comet> comets = new ArrayList<>();
    private final FastRandom random = new FastRandom();
    private final StopWatch spawnTimer = new StopWatch();

    @Override
    public void toggle() {
        super.toggle();
        if (isEnabled()) {
            comets.clear();
            cometParticles.clear();
            spawnTimer.reset();
            for (int i = 0; i < cometCount.getValue(); i++) {
                spawnComet();
            }
        } else {
            comets.clear();
            cometParticles.clear();
        }
    }

    @EventHandler
    public void onEvent(WorldChangeEvent event) {
        comets.clear();
        cometParticles.clear();
        if (isEnabled()) {
            for (int i = 0; i < cometCount.getValue(); i++) {
                spawnComet();
            }
        }
    }

    @EventHandler
    public void onEvent(MotionEvent event) {
        if (!isEnabled() || mc.world == null) return;


        comets.removeIf(comet ->
                comet.position.distanceTo(mc.player.getPositionVec()) > maxDistance.getValue() * 1.5);

        if (spawnTimer.finished(1000) && comets.size() < cometCount.getValue()) {
            spawnComet();
            spawnTimer.reset();
        }

        for (Comet comet : comets) {
            comet.update();


            if (comet.particleTimer.finished(20)) {
                generateTrailParticles(comet);
                comet.particleTimer.reset();
            }

            Vector3d playerPos = mc.player.getPositionVec();
            double distance = comet.position.distanceTo(playerPos);

            if (distance > maxDistance.getValue() * 0.8) {

                Vector3d toPlayer = playerPos.subtract(comet.position).normalize();
                Vector3d currentVelocity = comet.velocity;

                toPlayer = new Vector3d(toPlayer.x, 0, toPlayer.z).normalize();

                Vector3d newDirection = currentVelocity.normalize().add(toPlayer.scale(0.2)).normalize();

                newDirection = new Vector3d(newDirection.x, 0, newDirection.z).normalize();

                double speed = currentVelocity.length();
                comet.velocity = newDirection.scale(speed);
            }
        }

        cometParticles.removeIf(particle ->
                particle.time.finished((long) (particleLifetime.getValue() * 1000)) ||
                        !PlayerUtil.isInView(particle.box));
    }

    private void spawnComet() {

        Vector3d playerPos = mc.player.getPositionVec();

        double distance = maxDistance.getValue() * 0.7 + random.nextDouble() * maxDistance.getValue() * 0.3;
        double angle = random.nextDouble() * Math.PI * 2;


        double spawnX = playerPos.x + Math.cos(angle) * distance;
        double spawnY = playerPos.y + 1.0 + random.nextDouble() * 0.5;
        double spawnZ = playerPos.z + Math.sin(angle) * distance;

        Vector3d spawnPos = new Vector3d(spawnX, spawnY, spawnZ);

        double speedMultiplier = cometSpeed.getValue() * 0.05;

        double vx = random.nextDouble() * 2 - 1;
        double vz = random.nextDouble() * 2 - 1;

        Vector3d velocity = new Vector3d(vx, 0, vz).normalize().scale(speedMultiplier);

        int color = Theme.getInstance().clientColor();

        comets.add(new Comet(spawnPos, velocity, cometSize.getValue().floatValue(), color));
    }

    private void generateTrailParticles(Comet comet) {

        int particlesToGenerate = 4;

        for (int i = 0; i < particlesToGenerate; i++) {

            double offsetX = (random.nextDouble() - 0.5) * comet.size * 0.5;
            double offsetY = (random.nextDouble() - 0.5) * comet.size * 0.5;
            double offsetZ = (random.nextDouble() - 0.5) * comet.size * 0.5;

            Vector3d oppositeDirection = comet.velocity.normalize().scale(-1);
            double trailDistance = comet.size * (0.5 + random.nextDouble() * 1.5);

            Vector3d particlePos = comet.position
                    .add(offsetX, offsetY, offsetZ)
                    .add(oppositeDirection.scale(trailDistance));

            float particleSize = comet.size * (0.2f + random.nextFloat() * 0.3f);


            ParticleType type;
            switch (particleType.getValue()) {
                case "Circle" -> type = ParticleType.CIRCLE;
                case "Star" -> type = ParticleType.STAR;
                case "Heart" -> type = ParticleType.HEART;
                default -> type = ParticleType.BLOOM;
            }

            int baseColor = Theme.getInstance().clientColor();
            int secondaryColor = Theme.getInstance().darkColor();

            int particleColor;
            if (random.nextFloat() < 0.7f) {

                particleColor = baseColor;
            } else {

                particleColor = secondaryColor;
            }


            CometParticle particle = new CometParticle(
                    type,
                    particlePos,
                    new Vector3d(0, 0, 0),
                    cometParticles.size(),
                    (int) Mathf.step(Mathf.randomValue(0, 360), 15),
                    particleColor,
                    particleSize
            );

            cometParticles.add(particle);


            if (cometParticles.size() > particleCount.getValue()) {
                cometParticles.remove(0);
            }
        }
    }

    @EventHandler
    public void onEvent(Render3DPosedEvent event) {
        if (!isEnabled()) return;

        MatrixStack matrix = event.getMatrix();

        setupRenderState();

        renderParticles(matrix, cometParticles);

        for (Comet comet : comets) {
            renderComet(matrix, comet);
        }

        resetRenderState();
    }

    private void setupRenderState() {
        RenderSystem.enableBlend();
        RenderSystem.disableAlphaTest();
        RenderSystem.depthMask(false);
        RenderSystem.disableCull();
        RenderSystem.blendFuncSeparate(
                GlStateManager.SourceFactor.SRC_ALPHA,
                GlStateManager.DestFactor.ONE,
                GlStateManager.SourceFactor.ONE,
                GlStateManager.DestFactor.ZERO
        );
    }

    private void resetRenderState() {
        RenderSystem.blendFuncSeparate(
                GlStateManager.SourceFactor.SRC_ALPHA,
                GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
                GlStateManager.SourceFactor.ONE,
                GlStateManager.DestFactor.ZERO
        );
        RenderSystem.clearCurrentColor();
        RenderSystem.enableCull();
        RenderSystem.depthMask(true);
        RenderSystem.enableAlphaTest();
    }

    private void renderComet(MatrixStack matrix, Comet comet) {
        Vector3d pos = comet.position;
        float size = comet.size;
        int color = comet.color;

        matrix.push();
        RenderUtil3D.setupOrientationMatrix(matrix, (float) pos.x, (float) pos.y, (float) pos.z);
        matrix.rotate(mc.getRenderManager().getCameraOrientation());

        if (glowing.getValue()) {
            RenderUtil.bindTexture(ParticleType.BLOOM.texture());
            RectUtil.drawRect(matrix, -size * 4, -size * 4, size * 8, size * 8, ColorUtil.multAlpha(color, 0.1F), true, true);
            RectUtil.drawRect(matrix, -size * 2, -size * 2, size * 4, size * 4, ColorUtil.multAlpha(color, 0.2F), true, true);
        }

        RenderUtil.bindTexture(ParticleType.BLOOM.texture());
        RectUtil.drawRect(matrix, -size, -size, size * 2, size * 2, color, true, true);

        matrix.pop();
    }

    private void renderParticles(MatrixStack matrix, List<CometParticle> particles) {
        if (particles.isEmpty()) return;

        for (CometParticle particle : particles) {
            particle.animation.update();

            if (particle.animation.getValue() != opacity.getValue() && !particle.time.finished(500)) {
                particle.animation.run(opacity.getValue(), 0.5, Easings.CUBIC_OUT, true);
            }
            if (particle.animation.getValue() != 0 && particle.time.finished((long) (particleLifetime.getValue() * 800))) {
                particle.animation.run(0, 0.5, Easings.CUBIC_OUT, true);
            }

            int color = ColorUtil.replAlpha(particle.color, particle.animation.get());
            Vector3d vec = particle.position;
            float x = (float) vec.x;
            float y = (float) vec.y;
            float z = (float) vec.z;

            renderParticle(matrix, particle, x, y, z, particle.size, color);
        }
    }

    private void renderParticle(MatrixStack matrix, CometParticle particle, float x, float y, float z, float pos, int color) {
        matrix.push();
        RenderUtil3D.setupOrientationMatrix(matrix, x, y, z);
        matrix.rotate(mc.getRenderManager().getCameraOrientation());

        if (particle.type.rotatable()) {
            matrix.rotate(Vector3f.ZP.rotationDegrees(particle.rotate));
        }

        if (glowing.getValue()) {
            RenderUtil.bindTexture(ParticleType.BLOOM.texture());
            RectUtil.drawRect(matrix, -pos * 2, -pos * 2, pos * 4, pos * 4, ColorUtil.multAlpha(color, 0.1F), true, true);
        }

        RenderUtil.bindTexture(particle.type.texture());
        RectUtil.drawRect(matrix, -pos, -pos, pos * 2, pos * 2, color, true, true);

        matrix.pop();
    }

    @Getter
    @Accessors(fluent = true)
    @FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
    public enum ParticleType {
        CIRCLE("circle", false),
        BLOOM("bloom", false),
        STAR("star", true),
        HEART("heart", false);

        ResourceLocation texture;
        boolean rotatable;

        ParticleType(String name, boolean rotatable) {
            texture = new Namespaced("particle/" + name + ".png");
            this.rotatable = rotatable;
        }
    }

    @Getter
    @Accessors(fluent = true)
    @FieldDefaults(level = AccessLevel.PRIVATE)
    public static class CometParticle {
        final AxisAlignedBB box;
        final ParticleType type;
        final Vector3d position;
        final Vector3d velocity;
        final int index;
        final int rotate;
        final int color;
        final float size;
        final StopWatch time = new StopWatch();
        final Animation animation = new Animation();

        public CometParticle(ParticleType type, Vector3d position, Vector3d velocity, int index, int rotate, int color, float size) {
            this.box = new AxisAlignedBB(position, position).grow(size);
            this.type = type;
            this.position = position;
            this.velocity = velocity;
            this.index = index;
            this.rotate = rotate;
            this.color = color;
            this.size = size;
            this.time.reset();
            this.animation.set(0);
        }
    }

    @FieldDefaults(level = AccessLevel.PRIVATE)
    public class Comet {
        Vector3d position;
        Vector3d velocity;
        float size;
        int color;
        final StopWatch particleTimer = new StopWatch();

        public Comet(Vector3d position, Vector3d velocity, float size, int color) {
            this.position = position;
            this.velocity = velocity;
            this.size = size;
            this.color = color;
            this.particleTimer.reset();
        }

        public void update() {
            position = position.add(velocity);
        }
    }
}
 
го на великий expensive
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
это пиздец если честно
 
рой светлячков ищут другую пасту что бы переехать
 
светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке светяшке
 
С каких пор начали делать что-то на Excellent Recode? Быстро на родину expensive 3.1 pro ultra game edition remake
 
Посмотреть вложение 304421
Посмотреть вложение 304423

Пнг и тд дефолтное вам просто нужно будет добавить клас в базу и добавить модуль в модуль менеджер


Java:
Expand Collapse Copy
package org.excellent.client.managers.module.impl.render;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.Namespaced;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
import net.mojang.blaze3d.matrix.MatrixStack;
import net.mojang.blaze3d.platform.GlStateManager;
import net.mojang.blaze3d.systems.RenderSystem;
import org.excellent.client.api.events.orbit.EventHandler;
import org.excellent.client.managers.events.player.MotionEvent;
import org.excellent.client.managers.events.render.Render3DPosedEvent;
import org.excellent.client.managers.events.world.WorldChangeEvent;
import org.excellent.client.managers.module.Category;
import org.excellent.client.managers.module.Module;
import org.excellent.client.managers.module.ModuleInfo;
import org.excellent.client.managers.module.impl.client.Theme;
import org.excellent.client.managers.module.settings.impl.BooleanSetting;
import org.excellent.client.managers.module.settings.impl.ModeSetting;
import org.excellent.client.managers.module.settings.impl.SliderSetting;
import org.excellent.client.utils.animation.Animation;
import org.excellent.client.utils.animation.util.Easings;
import org.excellent.client.utils.math.Mathf;
import org.excellent.client.utils.other.Instance;
import org.excellent.client.utils.player.PlayerUtil;
import org.excellent.client.utils.render.color.ColorUtil;
import org.excellent.client.utils.render.draw.RectUtil;
import org.excellent.client.utils.render.draw.RenderUtil;
import org.excellent.client.utils.render.draw.RenderUtil3D;
import org.excellent.common.impl.fastrandom.FastRandom;
import org.excellent.lib.util.time.StopWatch;

import java.util.ArrayList;
import java.util.List;

@Getter
@Accessors(fluent = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@ModuleInfo(name = "Comets", category = Category.RENDER)
public class Comets extends Module {
    public static Comets getInstance() {
        return Instance.get(Comets.class);
    }

    private final SliderSetting cometCount = new SliderSetting(this, "Количество комет", 3, 1, 10, 1);
    private final SliderSetting cometSize = new SliderSetting(this, "Размер комет", 0.5F, 0.2F, 1.5F, 0.1F);
    private final SliderSetting cometSpeed = new SliderSetting(this, "Скорость комет", 1.0F, 0.1F, 3.0F, 0.1F);
    private final SliderSetting particleCount = new SliderSetting(this, "Частиц за комету", 40, 10, 100, 5);
    private final SliderSetting particleLifetime = new SliderSetting(this, "Время жизни частиц", 1.0F, 0.5F, 3.0F, 0.1F);
    private final SliderSetting maxDistance = new SliderSetting(this, "Макс. радиус", 15.0F, 5.0F, 30.0F, 1.0F);
    private final SliderSetting opacity = new SliderSetting(this, "Прозрачность", 1.0F, 0.1F, 1.0F, 0.1F);
    private final BooleanSetting glowing = new BooleanSetting(this, "Свечение", true);
    private final ModeSetting particleType = new ModeSetting(this, "Тип частиц",
            "Circle",
            "Bloom",
            "Star",
            "Heart"
    ).set("Bloom");

    private final List<CometParticle> cometParticles = new ArrayList<>();
    private final List<Comet> comets = new ArrayList<>();
    private final FastRandom random = new FastRandom();
    private final StopWatch spawnTimer = new StopWatch();

    @Override
    public void toggle() {
        super.toggle();
        if (isEnabled()) {
            comets.clear();
            cometParticles.clear();
            spawnTimer.reset();
            for (int i = 0; i < cometCount.getValue(); i++) {
                spawnComet();
            }
        } else {
            comets.clear();
            cometParticles.clear();
        }
    }

    @EventHandler
    public void onEvent(WorldChangeEvent event) {
        comets.clear();
        cometParticles.clear();
        if (isEnabled()) {
            for (int i = 0; i < cometCount.getValue(); i++) {
                spawnComet();
            }
        }
    }

    @EventHandler
    public void onEvent(MotionEvent event) {
        if (!isEnabled() || mc.world == null) return;


        comets.removeIf(comet ->
                comet.position.distanceTo(mc.player.getPositionVec()) > maxDistance.getValue() * 1.5);

        if (spawnTimer.finished(1000) && comets.size() < cometCount.getValue()) {
            spawnComet();
            spawnTimer.reset();
        }

        for (Comet comet : comets) {
            comet.update();


            if (comet.particleTimer.finished(20)) {
                generateTrailParticles(comet);
                comet.particleTimer.reset();
            }

            Vector3d playerPos = mc.player.getPositionVec();
            double distance = comet.position.distanceTo(playerPos);

            if (distance > maxDistance.getValue() * 0.8) {

                Vector3d toPlayer = playerPos.subtract(comet.position).normalize();
                Vector3d currentVelocity = comet.velocity;

                toPlayer = new Vector3d(toPlayer.x, 0, toPlayer.z).normalize();

                Vector3d newDirection = currentVelocity.normalize().add(toPlayer.scale(0.2)).normalize();

                newDirection = new Vector3d(newDirection.x, 0, newDirection.z).normalize();

                double speed = currentVelocity.length();
                comet.velocity = newDirection.scale(speed);
            }
        }

        cometParticles.removeIf(particle ->
                particle.time.finished((long) (particleLifetime.getValue() * 1000)) ||
                        !PlayerUtil.isInView(particle.box));
    }

    private void spawnComet() {

        Vector3d playerPos = mc.player.getPositionVec();

        double distance = maxDistance.getValue() * 0.7 + random.nextDouble() * maxDistance.getValue() * 0.3;
        double angle = random.nextDouble() * Math.PI * 2;


        double spawnX = playerPos.x + Math.cos(angle) * distance;
        double spawnY = playerPos.y + 1.0 + random.nextDouble() * 0.5;
        double spawnZ = playerPos.z + Math.sin(angle) * distance;

        Vector3d spawnPos = new Vector3d(spawnX, spawnY, spawnZ);

        double speedMultiplier = cometSpeed.getValue() * 0.05;

        double vx = random.nextDouble() * 2 - 1;
        double vz = random.nextDouble() * 2 - 1;

        Vector3d velocity = new Vector3d(vx, 0, vz).normalize().scale(speedMultiplier);

        int color = Theme.getInstance().clientColor();

        comets.add(new Comet(spawnPos, velocity, cometSize.getValue().floatValue(), color));
    }

    private void generateTrailParticles(Comet comet) {

        int particlesToGenerate = 4;

        for (int i = 0; i < particlesToGenerate; i++) {

            double offsetX = (random.nextDouble() - 0.5) * comet.size * 0.5;
            double offsetY = (random.nextDouble() - 0.5) * comet.size * 0.5;
            double offsetZ = (random.nextDouble() - 0.5) * comet.size * 0.5;

            Vector3d oppositeDirection = comet.velocity.normalize().scale(-1);
            double trailDistance = comet.size * (0.5 + random.nextDouble() * 1.5);

            Vector3d particlePos = comet.position
                    .add(offsetX, offsetY, offsetZ)
                    .add(oppositeDirection.scale(trailDistance));

            float particleSize = comet.size * (0.2f + random.nextFloat() * 0.3f);


            ParticleType type;
            switch (particleType.getValue()) {
                case "Circle" -> type = ParticleType.CIRCLE;
                case "Star" -> type = ParticleType.STAR;
                case "Heart" -> type = ParticleType.HEART;
                default -> type = ParticleType.BLOOM;
            }

            int baseColor = Theme.getInstance().clientColor();
            int secondaryColor = Theme.getInstance().darkColor();

            int particleColor;
            if (random.nextFloat() < 0.7f) {

                particleColor = baseColor;
            } else {

                particleColor = secondaryColor;
            }


            CometParticle particle = new CometParticle(
                    type,
                    particlePos,
                    new Vector3d(0, 0, 0),
                    cometParticles.size(),
                    (int) Mathf.step(Mathf.randomValue(0, 360), 15),
                    particleColor,
                    particleSize
            );

            cometParticles.add(particle);


            if (cometParticles.size() > particleCount.getValue()) {
                cometParticles.remove(0);
            }
        }
    }

    @EventHandler
    public void onEvent(Render3DPosedEvent event) {
        if (!isEnabled()) return;

        MatrixStack matrix = event.getMatrix();

        setupRenderState();

        renderParticles(matrix, cometParticles);

        for (Comet comet : comets) {
            renderComet(matrix, comet);
        }

        resetRenderState();
    }

    private void setupRenderState() {
        RenderSystem.enableBlend();
        RenderSystem.disableAlphaTest();
        RenderSystem.depthMask(false);
        RenderSystem.disableCull();
        RenderSystem.blendFuncSeparate(
                GlStateManager.SourceFactor.SRC_ALPHA,
                GlStateManager.DestFactor.ONE,
                GlStateManager.SourceFactor.ONE,
                GlStateManager.DestFactor.ZERO
        );
    }

    private void resetRenderState() {
        RenderSystem.blendFuncSeparate(
                GlStateManager.SourceFactor.SRC_ALPHA,
                GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
                GlStateManager.SourceFactor.ONE,
                GlStateManager.DestFactor.ZERO
        );
        RenderSystem.clearCurrentColor();
        RenderSystem.enableCull();
        RenderSystem.depthMask(true);
        RenderSystem.enableAlphaTest();
    }

    private void renderComet(MatrixStack matrix, Comet comet) {
        Vector3d pos = comet.position;
        float size = comet.size;
        int color = comet.color;

        matrix.push();
        RenderUtil3D.setupOrientationMatrix(matrix, (float) pos.x, (float) pos.y, (float) pos.z);
        matrix.rotate(mc.getRenderManager().getCameraOrientation());

        if (glowing.getValue()) {
            RenderUtil.bindTexture(ParticleType.BLOOM.texture());
            RectUtil.drawRect(matrix, -size * 4, -size * 4, size * 8, size * 8, ColorUtil.multAlpha(color, 0.1F), true, true);
            RectUtil.drawRect(matrix, -size * 2, -size * 2, size * 4, size * 4, ColorUtil.multAlpha(color, 0.2F), true, true);
        }

        RenderUtil.bindTexture(ParticleType.BLOOM.texture());
        RectUtil.drawRect(matrix, -size, -size, size * 2, size * 2, color, true, true);

        matrix.pop();
    }

    private void renderParticles(MatrixStack matrix, List<CometParticle> particles) {
        if (particles.isEmpty()) return;

        for (CometParticle particle : particles) {
            particle.animation.update();

            if (particle.animation.getValue() != opacity.getValue() && !particle.time.finished(500)) {
                particle.animation.run(opacity.getValue(), 0.5, Easings.CUBIC_OUT, true);
            }
            if (particle.animation.getValue() != 0 && particle.time.finished((long) (particleLifetime.getValue() * 800))) {
                particle.animation.run(0, 0.5, Easings.CUBIC_OUT, true);
            }

            int color = ColorUtil.replAlpha(particle.color, particle.animation.get());
            Vector3d vec = particle.position;
            float x = (float) vec.x;
            float y = (float) vec.y;
            float z = (float) vec.z;

            renderParticle(matrix, particle, x, y, z, particle.size, color);
        }
    }

    private void renderParticle(MatrixStack matrix, CometParticle particle, float x, float y, float z, float pos, int color) {
        matrix.push();
        RenderUtil3D.setupOrientationMatrix(matrix, x, y, z);
        matrix.rotate(mc.getRenderManager().getCameraOrientation());

        if (particle.type.rotatable()) {
            matrix.rotate(Vector3f.ZP.rotationDegrees(particle.rotate));
        }

        if (glowing.getValue()) {
            RenderUtil.bindTexture(ParticleType.BLOOM.texture());
            RectUtil.drawRect(matrix, -pos * 2, -pos * 2, pos * 4, pos * 4, ColorUtil.multAlpha(color, 0.1F), true, true);
        }

        RenderUtil.bindTexture(particle.type.texture());
        RectUtil.drawRect(matrix, -pos, -pos, pos * 2, pos * 2, color, true, true);

        matrix.pop();
    }

    @Getter
    @Accessors(fluent = true)
    @FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
    public enum ParticleType {
        CIRCLE("circle", false),
        BLOOM("bloom", false),
        STAR("star", true),
        HEART("heart", false);

        ResourceLocation texture;
        boolean rotatable;

        ParticleType(String name, boolean rotatable) {
            texture = new Namespaced("particle/" + name + ".png");
            this.rotatable = rotatable;
        }
    }

    @Getter
    @Accessors(fluent = true)
    @FieldDefaults(level = AccessLevel.PRIVATE)
    public static class CometParticle {
        final AxisAlignedBB box;
        final ParticleType type;
        final Vector3d position;
        final Vector3d velocity;
        final int index;
        final int rotate;
        final int color;
        final float size;
        final StopWatch time = new StopWatch();
        final Animation animation = new Animation();

        public CometParticle(ParticleType type, Vector3d position, Vector3d velocity, int index, int rotate, int color, float size) {
            this.box = new AxisAlignedBB(position, position).grow(size);
            this.type = type;
            this.position = position;
            this.velocity = velocity;
            this.index = index;
            this.rotate = rotate;
            this.color = color;
            this.size = size;
            this.time.reset();
            this.animation.set(0);
        }
    }

    @FieldDefaults(level = AccessLevel.PRIVATE)
    public class Comet {
        Vector3d position;
        Vector3d velocity;
        float size;
        int color;
        final StopWatch particleTimer = new StopWatch();

        public Comet(Vector3d position, Vector3d velocity, float size, int color) {
            this.position = position;
            this.velocity = velocity;
            this.size = size;
            this.color = color;
            this.particleTimer.reset();
        }

        public void update() {
            position = position.add(velocity);
        }
    }
}
опа спасибо
 
Назад
Сверху Снизу