Исходник Particles Forge 1.16.5 Ready

Forge Api ;-;
Начинающий
Статус
Оффлайн
Регистрация
3 Май 2023
Сообщения
477
Реакции[?]
8
Поинты[?]
9K
SS:
1714507669430.png



можно было и лучше но типо и так сойдет
Bimbim:
ArrayList<Particle> particles = new ArrayList<>();

    @SubscribeEvent
    public void onRender3D(RenderWorldLastEvent renderWorldLastEvent) {
        
        Particles.color = ваш_цвет;
        
        particles.removeIf(particle -> particle.timerUtil.hasReached(particle.lifeTime));
        MatrixStack matrixStack = renderWorldLastEvent.getMatrixStack();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferBuilder = tessellator.getBuilder();
        particles.forEach(particle -> {
            particle.animation.to = (float) particle.endX;
            particle.animation2.to = (float) particle.endY;
            particle.animation3.to = (float) particle.endZ;
            Vector3d vector3d = mc.getEntityRenderDispatcher().camera.getPosition();

            mc.getTextureManager().bind(heart);
            
            matrixStack.pushPose();
            matrixStack.translate((particle.startX + particle.animation.getAnim()) - vector3d.x, (particle.startY + particle.animation2.getAnim()) - vector3d.y, (particle.startZ + particle.animation3.getAnim()) - vector3d.z);
            matrixStack.mulPose(mc.gameRenderer.getMainCamera().rotation().copy());
            matrixStack.scale((float) razmer.value, (float) razmer.value, (float) razmer.value);
            RenderSystem.pushMatrix();
            RenderSystem.disableDepthTest();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX);
            Color color = particle.color;
            float life = (float) particle.timerUtil.getMc() / particle.lifeTime;
            color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (MathHelper.clamp(1 - life, 0, 1) * 255));
            matrixStack.mulPose(Vector3f.ZP.rotationDegrees(life * 360));
            bufferBuilder.vertex(matrixStack.last().pose(), 2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 0).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), 2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 0).endVertex();
            tessellator.end();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.popMatrix();
            matrixStack.popPose();
        });
    }

    @SubscribeEvent
    public void onAttackEntity(AttackEntityEvent attackEntityEvent) {
        if (timerUtil.hasReached(200) && attackEntityEvent.getTarget().isAlive()) {
            for (int i = 0; i < kolichestvo.value; i++) {
                float r0 = random.nextInt(5) + random.nextFloat();
                float r1 = random.nextInt(5) + random.nextFloat();
                particles.add(new Particle(attackEntityEvent.getTarget().getX(), attackEntityEvent.getTarget().getY() + attackEntityEvent.getTarget().getBbHeight() / 2, attackEntityEvent.getTarget().getZ(), random.nextBoolean() ? r0 : -r0, random.nextInt(5) + random.nextFloat(), random.nextBoolean() ? r1 : -r1, random.nextInt(5000)));
                timerUtil.reset();
            }
        }
    }

    static class Particle {
        double startX, startY, startZ, endX, endY, endZ;
        TimerUtil timerUtil = new TimerUtil();
        long lifeTime;
        Color color = Particles.color;
        AnimationUtil animation = new AnimationUtil(0.01f);
        AnimationUtil animation2 = new AnimationUtil(0.01f);
        AnimationUtil animation3 = new AnimationUtil(0.01f);

        public Particle(double startX, double startY, double startZ, double endX, double endY, double endZ, long lifeTime) {
            this.startX = startX;
            this.startY = startY;
            this.startZ = startZ;
            this.endX = endX;
            this.endY = endY;
            this.endZ = endZ;
            this.lifeTime = lifeTime;
        }
    }
}

TimerUtil:
public class TimerUtil {
    long mc;

    public void reset() {
        this.mc = System.currentTimeMillis();
    }

    public long getMc() {
        return System.currentTimeMillis() - this.mc;
    }

    public boolean hasReached(final long n) {
        return System.currentTimeMillis() - this.mc > n;
    }

    public TimerUtil() {
        this.mc = System.currentTimeMillis();
    }
}
AnimationUtil:
public class AnimationUtil {
    public float anim, to, speed;
    long mc = System.currentTimeMillis();

    public AnimationUtil(float speed) {
        this.speed = speed;
    }

    public float getAnim() {
        int count = (int) ((System.currentTimeMillis() - mc) / 5);
        if (count > 0) {
            mc = System.currentTimeMillis();
        }
        for (int i = 0; i < count; i++) {
            anim = MathUtil.lerp(anim, to, speed);
        }
        return anim;
    }
}
PNG:
1714507964312.png
 
Начинающий
Статус
Оффлайн
Регистрация
5 Апр 2023
Сообщения
389
Реакции[?]
1
Поинты[?]
2K
SS:
Посмотреть вложение 275825



можно было и лучше но типо и так сойдет
Bimbim:
ArrayList<Particle> particles = new ArrayList<>();

    @SubscribeEvent
    public void onRender3D(RenderWorldLastEvent renderWorldLastEvent) {
       
        Particles.color = ваш_цвет;
       
        particles.removeIf(particle -> particle.timerUtil.hasReached(particle.lifeTime));
        MatrixStack matrixStack = renderWorldLastEvent.getMatrixStack();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferBuilder = tessellator.getBuilder();
        particles.forEach(particle -> {
            particle.animation.to = (float) particle.endX;
            particle.animation2.to = (float) particle.endY;
            particle.animation3.to = (float) particle.endZ;
            Vector3d vector3d = mc.getEntityRenderDispatcher().camera.getPosition();

            mc.getTextureManager().bind(heart);
           
            matrixStack.pushPose();
            matrixStack.translate((particle.startX + particle.animation.getAnim()) - vector3d.x, (particle.startY + particle.animation2.getAnim()) - vector3d.y, (particle.startZ + particle.animation3.getAnim()) - vector3d.z);
            matrixStack.mulPose(mc.gameRenderer.getMainCamera().rotation().copy());
            matrixStack.scale((float) razmer.value, (float) razmer.value, (float) razmer.value);
            RenderSystem.pushMatrix();
            RenderSystem.disableDepthTest();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX);
            Color color = particle.color;
            float life = (float) particle.timerUtil.getMc() / particle.lifeTime;
            color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (MathHelper.clamp(1 - life, 0, 1) * 255));
            matrixStack.mulPose(Vector3f.ZP.rotationDegrees(life * 360));
            bufferBuilder.vertex(matrixStack.last().pose(), 2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 0).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), 2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 0).endVertex();
            tessellator.end();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.popMatrix();
            matrixStack.popPose();
        });
    }

    @SubscribeEvent
    public void onAttackEntity(AttackEntityEvent attackEntityEvent) {
        if (timerUtil.hasReached(200) && attackEntityEvent.getTarget().isAlive()) {
            for (int i = 0; i < kolichestvo.value; i++) {
                float r0 = random.nextInt(5) + random.nextFloat();
                float r1 = random.nextInt(5) + random.nextFloat();
                particles.add(new Particle(attackEntityEvent.getTarget().getX(), attackEntityEvent.getTarget().getY() + attackEntityEvent.getTarget().getBbHeight() / 2, attackEntityEvent.getTarget().getZ(), random.nextBoolean() ? r0 : -r0, random.nextInt(5) + random.nextFloat(), random.nextBoolean() ? r1 : -r1, random.nextInt(5000)));
                timerUtil.reset();
            }
        }
    }

    static class Particle {
        double startX, startY, startZ, endX, endY, endZ;
        TimerUtil timerUtil = new TimerUtil();
        long lifeTime;
        Color color = Particles.color;
        AnimationUtil animation = new AnimationUtil(0.01f);
        AnimationUtil animation2 = new AnimationUtil(0.01f);
        AnimationUtil animation3 = new AnimationUtil(0.01f);

        public Particle(double startX, double startY, double startZ, double endX, double endY, double endZ, long lifeTime) {
            this.startX = startX;
            this.startY = startY;
            this.startZ = startZ;
            this.endX = endX;
            this.endY = endY;
            this.endZ = endZ;
            this.lifeTime = lifeTime;
        }
    }
}

TimerUtil:
public class TimerUtil {
    long mc;

    public void reset() {
        this.mc = System.currentTimeMillis();
    }

    public long getMc() {
        return System.currentTimeMillis() - this.mc;
    }

    public boolean hasReached(final long n) {
        return System.currentTimeMillis() - this.mc > n;
    }

    public TimerUtil() {
        this.mc = System.currentTimeMillis();
    }
}
AnimationUtil:
public class AnimationUtil {
    public float anim, to, speed;
    long mc = System.currentTimeMillis();

    public AnimationUtil(float speed) {
        this.speed = speed;
    }

    public float getAnim() {
        int count = (int) ((System.currentTimeMillis() - mc) / 5);
        if (count > 0) {
            mc = System.currentTimeMillis();
        }
        for (int i = 0; i < count; i++) {
            anim = MathUtil.lerp(anim, to, speed);
        }
        return anim;
    }
}
PNG:
Посмотреть вложение 275826
у визуал клиентов уже всё есть
 
Начинающий
Статус
Оффлайн
Регистрация
29 Апр 2023
Сообщения
422
Реакции[?]
3
Поинты[?]
4K
SS:
Посмотреть вложение 275825



можно было и лучше но типо и так сойдет
Bimbim:
ArrayList<Particle> particles = new ArrayList<>();

    @SubscribeEvent
    public void onRender3D(RenderWorldLastEvent renderWorldLastEvent) {
       
        Particles.color = ваш_цвет;
       
        particles.removeIf(particle -> particle.timerUtil.hasReached(particle.lifeTime));
        MatrixStack matrixStack = renderWorldLastEvent.getMatrixStack();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferBuilder = tessellator.getBuilder();
        particles.forEach(particle -> {
            particle.animation.to = (float) particle.endX;
            particle.animation2.to = (float) particle.endY;
            particle.animation3.to = (float) particle.endZ;
            Vector3d vector3d = mc.getEntityRenderDispatcher().camera.getPosition();

            mc.getTextureManager().bind(heart);
           
            matrixStack.pushPose();
            matrixStack.translate((particle.startX + particle.animation.getAnim()) - vector3d.x, (particle.startY + particle.animation2.getAnim()) - vector3d.y, (particle.startZ + particle.animation3.getAnim()) - vector3d.z);
            matrixStack.mulPose(mc.gameRenderer.getMainCamera().rotation().copy());
            matrixStack.scale((float) razmer.value, (float) razmer.value, (float) razmer.value);
            RenderSystem.pushMatrix();
            RenderSystem.disableDepthTest();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX);
            Color color = particle.color;
            float life = (float) particle.timerUtil.getMc() / particle.lifeTime;
            color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (MathHelper.clamp(1 - life, 0, 1) * 255));
            matrixStack.mulPose(Vector3f.ZP.rotationDegrees(life * 360));
            bufferBuilder.vertex(matrixStack.last().pose(), 2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 0).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), 2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 0).endVertex();
            tessellator.end();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.popMatrix();
            matrixStack.popPose();
        });
    }

    @SubscribeEvent
    public void onAttackEntity(AttackEntityEvent attackEntityEvent) {
        if (timerUtil.hasReached(200) && attackEntityEvent.getTarget().isAlive()) {
            for (int i = 0; i < kolichestvo.value; i++) {
                float r0 = random.nextInt(5) + random.nextFloat();
                float r1 = random.nextInt(5) + random.nextFloat();
                particles.add(new Particle(attackEntityEvent.getTarget().getX(), attackEntityEvent.getTarget().getY() + attackEntityEvent.getTarget().getBbHeight() / 2, attackEntityEvent.getTarget().getZ(), random.nextBoolean() ? r0 : -r0, random.nextInt(5) + random.nextFloat(), random.nextBoolean() ? r1 : -r1, random.nextInt(5000)));
                timerUtil.reset();
            }
        }
    }

    static class Particle {
        double startX, startY, startZ, endX, endY, endZ;
        TimerUtil timerUtil = new TimerUtil();
        long lifeTime;
        Color color = Particles.color;
        AnimationUtil animation = new AnimationUtil(0.01f);
        AnimationUtil animation2 = new AnimationUtil(0.01f);
        AnimationUtil animation3 = new AnimationUtil(0.01f);

        public Particle(double startX, double startY, double startZ, double endX, double endY, double endZ, long lifeTime) {
            this.startX = startX;
            this.startY = startY;
            this.startZ = startZ;
            this.endX = endX;
            this.endY = endY;
            this.endZ = endZ;
            this.lifeTime = lifeTime;
        }
    }
}

TimerUtil:
public class TimerUtil {
    long mc;

    public void reset() {
        this.mc = System.currentTimeMillis();
    }

    public long getMc() {
        return System.currentTimeMillis() - this.mc;
    }

    public boolean hasReached(final long n) {
        return System.currentTimeMillis() - this.mc > n;
    }

    public TimerUtil() {
        this.mc = System.currentTimeMillis();
    }
}
AnimationUtil:
public class AnimationUtil {
    public float anim, to, speed;
    long mc = System.currentTimeMillis();

    public AnimationUtil(float speed) {
        this.speed = speed;
    }

    public float getAnim() {
        int count = (int) ((System.currentTimeMillis() - mc) / 5);
        if (count > 0) {
            mc = System.currentTimeMillis();
        }
        for (int i = 0; i < count; i++) {
            anim = MathUtil.lerp(anim, to, speed);
        }
        return anim;
    }
}
PNG:
Посмотреть вложение 275826
/del
 
Начинающий
Статус
Оффлайн
Регистрация
8 Май 2023
Сообщения
407
Реакции[?]
5
Поинты[?]
6K
SS:
Посмотреть вложение 275825



можно было и лучше но типо и так сойдет
Bimbim:
ArrayList<Particle> particles = new ArrayList<>();

    @SubscribeEvent
    public void onRender3D(RenderWorldLastEvent renderWorldLastEvent) {
       
        Particles.color = ваш_цвет;
       
        particles.removeIf(particle -> particle.timerUtil.hasReached(particle.lifeTime));
        MatrixStack matrixStack = renderWorldLastEvent.getMatrixStack();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferBuilder = tessellator.getBuilder();
        particles.forEach(particle -> {
            particle.animation.to = (float) particle.endX;
            particle.animation2.to = (float) particle.endY;
            particle.animation3.to = (float) particle.endZ;
            Vector3d vector3d = mc.getEntityRenderDispatcher().camera.getPosition();

            mc.getTextureManager().bind(heart);
           
            matrixStack.pushPose();
            matrixStack.translate((particle.startX + particle.animation.getAnim()) - vector3d.x, (particle.startY + particle.animation2.getAnim()) - vector3d.y, (particle.startZ + particle.animation3.getAnim()) - vector3d.z);
            matrixStack.mulPose(mc.gameRenderer.getMainCamera().rotation().copy());
            matrixStack.scale((float) razmer.value, (float) razmer.value, (float) razmer.value);
            RenderSystem.pushMatrix();
            RenderSystem.disableDepthTest();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX);
            Color color = particle.color;
            float life = (float) particle.timerUtil.getMc() / particle.lifeTime;
            color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (MathHelper.clamp(1 - life, 0, 1) * 255));
            matrixStack.mulPose(Vector3f.ZP.rotationDegrees(life * 360));
            bufferBuilder.vertex(matrixStack.last().pose(), 2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 0).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), 2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 0).endVertex();
            tessellator.end();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.popMatrix();
            matrixStack.popPose();
        });
    }

    @SubscribeEvent
    public void onAttackEntity(AttackEntityEvent attackEntityEvent) {
        if (timerUtil.hasReached(200) && attackEntityEvent.getTarget().isAlive()) {
            for (int i = 0; i < kolichestvo.value; i++) {
                float r0 = random.nextInt(5) + random.nextFloat();
                float r1 = random.nextInt(5) + random.nextFloat();
                particles.add(new Particle(attackEntityEvent.getTarget().getX(), attackEntityEvent.getTarget().getY() + attackEntityEvent.getTarget().getBbHeight() / 2, attackEntityEvent.getTarget().getZ(), random.nextBoolean() ? r0 : -r0, random.nextInt(5) + random.nextFloat(), random.nextBoolean() ? r1 : -r1, random.nextInt(5000)));
                timerUtil.reset();
            }
        }
    }

    static class Particle {
        double startX, startY, startZ, endX, endY, endZ;
        TimerUtil timerUtil = new TimerUtil();
        long lifeTime;
        Color color = Particles.color;
        AnimationUtil animation = new AnimationUtil(0.01f);
        AnimationUtil animation2 = new AnimationUtil(0.01f);
        AnimationUtil animation3 = new AnimationUtil(0.01f);

        public Particle(double startX, double startY, double startZ, double endX, double endY, double endZ, long lifeTime) {
            this.startX = startX;
            this.startY = startY;
            this.startZ = startZ;
            this.endX = endX;
            this.endY = endY;
            this.endZ = endZ;
            this.lifeTime = lifeTime;
        }
    }
}

TimerUtil:
public class TimerUtil {
    long mc;

    public void reset() {
        this.mc = System.currentTimeMillis();
    }

    public long getMc() {
        return System.currentTimeMillis() - this.mc;
    }

    public boolean hasReached(final long n) {
        return System.currentTimeMillis() - this.mc > n;
    }

    public TimerUtil() {
        this.mc = System.currentTimeMillis();
    }
}
AnimationUtil:
public class AnimationUtil {
    public float anim, to, speed;
    long mc = System.currentTimeMillis();

    public AnimationUtil(float speed) {
        this.speed = speed;
    }

    public float getAnim() {
        int count = (int) ((System.currentTimeMillis() - mc) / 5);
        if (count > 0) {
            mc = System.currentTimeMillis();
        }
        for (int i = 0; i < count; i++) {
            anim = MathUtil.lerp(anim, to, speed);
        }
        return anim;
    }
}
PNG:
Посмотреть вложение 275826
Канабалоф и попка визуалс щас пойдут растить в свои мегарккоки
 
Начинающий
Статус
Оффлайн
Регистрация
5 Апр 2023
Сообщения
389
Реакции[?]
1
Поинты[?]
2K
Начинающий
Статус
Оффлайн
Регистрация
23 Апр 2024
Сообщения
12
Реакции[?]
0
Поинты[?]
0
SS:
Посмотреть вложение 275825



можно было и лучше но типо и так сойдет
Bimbim:
ArrayList<Particle> particles = new ArrayList<>();

    @SubscribeEvent
    public void onRender3D(RenderWorldLastEvent renderWorldLastEvent) {
       
        Particles.color = ваш_цвет;
       
        particles.removeIf(particle -> particle.timerUtil.hasReached(particle.lifeTime));
        MatrixStack matrixStack = renderWorldLastEvent.getMatrixStack();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferBuilder = tessellator.getBuilder();
        particles.forEach(particle -> {
            particle.animation.to = (float) particle.endX;
            particle.animation2.to = (float) particle.endY;
            particle.animation3.to = (float) particle.endZ;
            Vector3d vector3d = mc.getEntityRenderDispatcher().camera.getPosition();

            mc.getTextureManager().bind(heart);
           
            matrixStack.pushPose();
            matrixStack.translate((particle.startX + particle.animation.getAnim()) - vector3d.x, (particle.startY + particle.animation2.getAnim()) - vector3d.y, (particle.startZ + particle.animation3.getAnim()) - vector3d.z);
            matrixStack.mulPose(mc.gameRenderer.getMainCamera().rotation().copy());
            matrixStack.scale((float) razmer.value, (float) razmer.value, (float) razmer.value);
            RenderSystem.pushMatrix();
            RenderSystem.disableDepthTest();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX);
            Color color = particle.color;
            float life = (float) particle.timerUtil.getMc() / particle.lifeTime;
            color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (MathHelper.clamp(1 - life, 0, 1) * 255));
            matrixStack.mulPose(Vector3f.ZP.rotationDegrees(life * 360));
            bufferBuilder.vertex(matrixStack.last().pose(), 2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 0).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), 2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 0).endVertex();
            tessellator.end();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.popMatrix();
            matrixStack.popPose();
        });
    }

    @SubscribeEvent
    public void onAttackEntity(AttackEntityEvent attackEntityEvent) {
        if (timerUtil.hasReached(200) && attackEntityEvent.getTarget().isAlive()) {
            for (int i = 0; i < kolichestvo.value; i++) {
                float r0 = random.nextInt(5) + random.nextFloat();
                float r1 = random.nextInt(5) + random.nextFloat();
                particles.add(new Particle(attackEntityEvent.getTarget().getX(), attackEntityEvent.getTarget().getY() + attackEntityEvent.getTarget().getBbHeight() / 2, attackEntityEvent.getTarget().getZ(), random.nextBoolean() ? r0 : -r0, random.nextInt(5) + random.nextFloat(), random.nextBoolean() ? r1 : -r1, random.nextInt(5000)));
                timerUtil.reset();
            }
        }
    }

    static class Particle {
        double startX, startY, startZ, endX, endY, endZ;
        TimerUtil timerUtil = new TimerUtil();
        long lifeTime;
        Color color = Particles.color;
        AnimationUtil animation = new AnimationUtil(0.01f);
        AnimationUtil animation2 = new AnimationUtil(0.01f);
        AnimationUtil animation3 = new AnimationUtil(0.01f);

        public Particle(double startX, double startY, double startZ, double endX, double endY, double endZ, long lifeTime) {
            this.startX = startX;
            this.startY = startY;
            this.startZ = startZ;
            this.endX = endX;
            this.endY = endY;
            this.endZ = endZ;
            this.lifeTime = lifeTime;
        }
    }
}

TimerUtil:
public class TimerUtil {
    long mc;

    public void reset() {
        this.mc = System.currentTimeMillis();
    }

    public long getMc() {
        return System.currentTimeMillis() - this.mc;
    }

    public boolean hasReached(final long n) {
        return System.currentTimeMillis() - this.mc > n;
    }

    public TimerUtil() {
        this.mc = System.currentTimeMillis();
    }
}
AnimationUtil:
public class AnimationUtil {
    public float anim, to, speed;
    long mc = System.currentTimeMillis();

    public AnimationUtil(float speed) {
        this.speed = speed;
    }

    public float getAnim() {
        int count = (int) ((System.currentTimeMillis() - mc) / 5);
        if (count > 0) {
            mc = System.currentTimeMillis();
        }
        for (int i = 0; i < count; i++) {
            anim = MathUtil.lerp(anim, to, speed);
        }
        return anim;
    }
}
PNG:
Посмотреть вложение 275826
Только из за того что forge ready, это круто
 
Начинающий
Статус
Оффлайн
Регистрация
22 Июл 2022
Сообщения
308
Реакции[?]
7
Поинты[?]
3K
Forge Api ;-;
Начинающий
Статус
Оффлайн
Регистрация
3 Май 2023
Сообщения
477
Реакции[?]
8
Поинты[?]
9K
Начинающий
Статус
Оффлайн
Регистрация
18 Июн 2022
Сообщения
275
Реакции[?]
12
Поинты[?]
3K
SS:
Посмотреть вложение 275825



можно было и лучше но типо и так сойдет
Bimbim:
ArrayList<Particle> particles = new ArrayList<>();

    @SubscribeEvent
    public void onRender3D(RenderWorldLastEvent renderWorldLastEvent) {
       
        Particles.color = ваш_цвет;
       
        particles.removeIf(particle -> particle.timerUtil.hasReached(particle.lifeTime));
        MatrixStack matrixStack = renderWorldLastEvent.getMatrixStack();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferBuilder = tessellator.getBuilder();
        particles.forEach(particle -> {
            particle.animation.to = (float) particle.endX;
            particle.animation2.to = (float) particle.endY;
            particle.animation3.to = (float) particle.endZ;
            Vector3d vector3d = mc.getEntityRenderDispatcher().camera.getPosition();

            mc.getTextureManager().bind(heart);
           
            matrixStack.pushPose();
            matrixStack.translate((particle.startX + particle.animation.getAnim()) - vector3d.x, (particle.startY + particle.animation2.getAnim()) - vector3d.y, (particle.startZ + particle.animation3.getAnim()) - vector3d.z);
            matrixStack.mulPose(mc.gameRenderer.getMainCamera().rotation().copy());
            matrixStack.scale((float) razmer.value, (float) razmer.value, (float) razmer.value);
            RenderSystem.pushMatrix();
            RenderSystem.disableDepthTest();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX);
            Color color = particle.color;
            float life = (float) particle.timerUtil.getMc() / particle.lifeTime;
            color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (MathHelper.clamp(1 - life, 0, 1) * 255));
            matrixStack.mulPose(Vector3f.ZP.rotationDegrees(life * 360));
            bufferBuilder.vertex(matrixStack.last().pose(), 2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 0).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), 2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(0, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, -2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 1).endVertex();
            bufferBuilder.vertex(matrixStack.last().pose(), -2, 2, 0).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).uv(1, 0).endVertex();
            tessellator.end();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.popMatrix();
            matrixStack.popPose();
        });
    }

    @SubscribeEvent
    public void onAttackEntity(AttackEntityEvent attackEntityEvent) {
        if (timerUtil.hasReached(200) && attackEntityEvent.getTarget().isAlive()) {
            for (int i = 0; i < kolichestvo.value; i++) {
                float r0 = random.nextInt(5) + random.nextFloat();
                float r1 = random.nextInt(5) + random.nextFloat();
                particles.add(new Particle(attackEntityEvent.getTarget().getX(), attackEntityEvent.getTarget().getY() + attackEntityEvent.getTarget().getBbHeight() / 2, attackEntityEvent.getTarget().getZ(), random.nextBoolean() ? r0 : -r0, random.nextInt(5) + random.nextFloat(), random.nextBoolean() ? r1 : -r1, random.nextInt(5000)));
                timerUtil.reset();
            }
        }
    }

    static class Particle {
        double startX, startY, startZ, endX, endY, endZ;
        TimerUtil timerUtil = new TimerUtil();
        long lifeTime;
        Color color = Particles.color;
        AnimationUtil animation = new AnimationUtil(0.01f);
        AnimationUtil animation2 = new AnimationUtil(0.01f);
        AnimationUtil animation3 = new AnimationUtil(0.01f);

        public Particle(double startX, double startY, double startZ, double endX, double endY, double endZ, long lifeTime) {
            this.startX = startX;
            this.startY = startY;
            this.startZ = startZ;
            this.endX = endX;
            this.endY = endY;
            this.endZ = endZ;
            this.lifeTime = lifeTime;
        }
    }
}

TimerUtil:
public class TimerUtil {
    long mc;

    public void reset() {
        this.mc = System.currentTimeMillis();
    }

    public long getMc() {
        return System.currentTimeMillis() - this.mc;
    }

    public boolean hasReached(final long n) {
        return System.currentTimeMillis() - this.mc > n;
    }

    public TimerUtil() {
        this.mc = System.currentTimeMillis();
    }
}
AnimationUtil:
public class AnimationUtil {
    public float anim, to, speed;
    long mc = System.currentTimeMillis();

    public AnimationUtil(float speed) {
        this.speed = speed;
    }

    public float getAnim() {
        int count = (int) ((System.currentTimeMillis() - mc) / 5);
        if (count > 0) {
            mc = System.currentTimeMillis();
        }
        for (int i = 0; i < count; i++) {
            anim = MathUtil.lerp(anim, to, speed);
        }
        return anim;
    }
}
PNG:
Посмотреть вложение 275826
+rep и за утилки тоже
 
Начинающий
Статус
Оффлайн
Регистрация
30 Июл 2023
Сообщения
52
Реакции[?]
0
Поинты[?]
1K
а чо почему если два раза по мобу тыкнуть то частицы после первого раза заного активируются???!!
 
Сверху Снизу