Исходник Trails 2 (expensive 2.0 ready)

Начинающий
Статус
Оффлайн
Регистрация
22 Янв 2024
Сообщения
79
Реакции[?]
0
Поинты[?]
0
Я решил повторить что-то по типу вилда, но сделал по своему. Тут звезды появляются за игроком только во время движения. Ток не оскорбляйте я ж пытался))
Пожалуйста, авторизуйтесь для просмотра ссылки.

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



Java:
package dev.rarchik.modules.impl.render;

import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import dev.rarchik.modules.Function;
import dev.rarchik.modules.FunctionAnnotation;
import dev.rarchik.modules.settings.imp.SliderSetting;
import dev.rarchik.util.IMinecraft;
import dev.rarchik.util.math.MathUtil;
import dev.rarchik.render.ProjectionUtils;
import dev.rarchik.render.RenderUtil;
import dev.rarchik.world.WorldUtil;
import org.joml.Vector2d;
import wtf.build.events.Event;
import dev.rarchik.events.impl.player.EventMotion;
import dev.rarchik.events.impl.render.EventRender;
import dev.rarchik.modules.Type;
import dev.rarchik.util.render.ColorUtil;
import dev.rarchik.util.render.animation.AnimationMath;

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

@FunctionAnnotation(name = "Trails 2", type = Type.Render)
public class Snow extends Function {

    private SliderSetting maxPoints = new SliderSetting("Сила", 200, 100, 200, 50);

    public Snow() {
        this.addSettings(maxPoints);
    }

    CopyOnWriteArrayList<Snow.Point> points = new CopyOnWriteArrayList<>();

    @Override
    public void onEvent(final Event event) {
        if (IMinecraft.mc.world == null || IMinecraft.mc.player == null) return;

        if (event instanceof EventMotion e) {
            Vector3d previousPos = new Vector3d(IMinecraft.mc.player.prevPosX, IMinecraft.mc.player.prevPosY, IMinecraft.mc.player.prevPosZ);
            Vector3d currentPos = new Vector3d(IMinecraft.mc.player.getPosX(), IMinecraft.mc.player.getPosY(), IMinecraft.mc.player.getPosZ());

            if (!previousPos.equals(currentPos)) {
                if (IMinecraft.mc.player.ticksExisted % 6 == 0) {
                    createPoints(currentPos);
                }
            }
        }
        if (event instanceof EventRender e) {
            if (points.size() > maxPoints.getValue().floatValue()) {
                points.remove(0);
            }
            for (Snow.Point point : points) {
                long alive = (System.currentTimeMillis() - point.createdTime);
                if (alive > point.aliveTime || !IMinecraft.mc.player.canVectorBeSeenFixed(point.position)) {
                    points.remove(point);
                    continue;
                }

                Vector2d pos = ProjectionUtils.project(point.position.x, point.position.y, point.position.z);

                if (pos != null) {

                    point.update();

                    RenderUtil.Render2D.drawImage(new ResourceLocation("tense/images/star.png"), (float) pos.x, (float) pos.y, 20, 20, ColorUtil.getColorStyle(points.indexOf(point)));
                }
            }
        }
    }
    private void createPoints(Vector3d position) {
        int numberOfStars = 40; // колва

        for (int i = 0; i < numberOfStars; i++) {
       
            Vector3d randomizedPosition = new Vector3d(
                    position.x + MathUtil.randomizeFloat(-0.5f, 0.5f),
                    position.y + MathUtil.randomizeFloat(0.0f, 2.0f),
                    position.z + MathUtil.randomizeFloat(-0.5f, 0.5f)
            );
            points.add(new Point(randomizedPosition));
        }
    }

    public final class Point {
        public Vector3d position;
        public Vector3d motion;
        public Vector3d animatedMotion;

        public long aliveTime;
        public float size;

        public long createdTime = System.currentTimeMillis();

        public Point(Vector3d position) {
            this.position = new Vector3d(position.x, position.y, position.z);
            this.motion = new Vector3d(MathUtil.randomizeFloat(0.0f, 0.0f), 0, MathUtil.randomizeFloat(0.0f, 0.0f));
            this.animatedMotion = new Vector3d(0, 0, 0);
            size = MathUtil.randomizeFloat(3, 7);
            aliveTime = ThreadLocalRandom.current().nextLong(1000, 3000);
        }


        public void update() {
            if (isGround()) {
                points.remove(points);
            } else {
                motion.y = MathUtil.randomizeFloat(-0.01f, 0.01f);
                motion.y *= 1;
                motion.x *= 1.001;
                motion.z *= 1.001;
            }


            animatedMotion.x = AnimationMath.fast((float) animatedMotion.x, (float) (motion.x), 1);
            animatedMotion.y = AnimationMath.fast((float) animatedMotion.y, (float) (motion.y), 1);
            animatedMotion.z = AnimationMath.fast((float) animatedMotion.z, (float) (motion.z), 1);

            position = position.add(animatedMotion);
        }
        boolean isGround() {
            Vector3d position = this.position.add(animatedMotion);
            AxisAlignedBB bb = new AxisAlignedBB(position.x - 0.1, position.y - 0.3, position.z - 0.1, position.x + 0.1, position.y + 0.3, position.z + 0.1);
            return WorldUtil.TotemUtil.getSphere(new BlockPos(position), 1, 2, false, true, 0)
                    .stream()
                    .anyMatch(blockPos -> !IMinecraft.mc.world.getBlockState(blockPos).isAir() &&
                            bb.intersects(new AxisAlignedBB(blockPos)) &&
                            AxisAlignedBB.calcSideHit(new AxisAlignedBB(blockPos.add(0, 0, 0)), position, new double[]{
                                    2D
                            }, null, 0.1f, 0.1f, 0.1f) == Direction.UP);
        }
    }
}
Блять, гений. Даже импорты не сделал...
 
Забаненный
Статус
Оффлайн
Регистрация
31 Авг 2023
Сообщения
699
Реакции[?]
6
Поинты[?]
5K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Начинающий
Статус
Оффлайн
Регистрация
4 Июл 2021
Сообщения
191
Реакции[?]
1
Поинты[?]
2K
Я решил повторить что-то по типу вилда, но сделал по своему. Тут звезды появляются за игроком только во время движения. Ток не оскорбляйте я ж пытался))
Пожалуйста, авторизуйтесь для просмотра ссылки.

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



Java:
package dev.rarchik.modules.impl.render;

import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import dev.rarchik.modules.Function;
import dev.rarchik.modules.FunctionAnnotation;
import dev.rarchik.modules.settings.imp.SliderSetting;
import dev.rarchik.util.IMinecraft;
import dev.rarchik.util.math.MathUtil;
import dev.rarchik.render.ProjectionUtils;
import dev.rarchik.render.RenderUtil;
import dev.rarchik.world.WorldUtil;
import org.joml.Vector2d;
import wtf.build.events.Event;
import dev.rarchik.events.impl.player.EventMotion;
import dev.rarchik.events.impl.render.EventRender;
import dev.rarchik.modules.Type;
import dev.rarchik.util.render.ColorUtil;
import dev.rarchik.util.render.animation.AnimationMath;

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

@FunctionAnnotation(name = "Trails 2", type = Type.Render)
public class Snow extends Function {

    private SliderSetting maxPoints = new SliderSetting("Сила", 200, 100, 200, 50);

    public Snow() {
        this.addSettings(maxPoints);
    }

    CopyOnWriteArrayList<Snow.Point> points = new CopyOnWriteArrayList<>();

    @Override
    public void onEvent(final Event event) {
        if (IMinecraft.mc.world == null || IMinecraft.mc.player == null) return;

        if (event instanceof EventMotion e) {
            Vector3d previousPos = new Vector3d(IMinecraft.mc.player.prevPosX, IMinecraft.mc.player.prevPosY, IMinecraft.mc.player.prevPosZ);
            Vector3d currentPos = new Vector3d(IMinecraft.mc.player.getPosX(), IMinecraft.mc.player.getPosY(), IMinecraft.mc.player.getPosZ());

            if (!previousPos.equals(currentPos)) {
                if (IMinecraft.mc.player.ticksExisted % 6 == 0) {
                    createPoints(currentPos);
                }
            }
        }
        if (event instanceof EventRender e) {
            if (points.size() > maxPoints.getValue().floatValue()) {
                points.remove(0);
            }
            for (Snow.Point point : points) {
                long alive = (System.currentTimeMillis() - point.createdTime);
                if (alive > point.aliveTime || !IMinecraft.mc.player.canVectorBeSeenFixed(point.position)) {
                    points.remove(point);
                    continue;
                }

                Vector2d pos = ProjectionUtils.project(point.position.x, point.position.y, point.position.z);

                if (pos != null) {

                    point.update();

                    RenderUtil.Render2D.drawImage(new ResourceLocation("tense/images/star.png"), (float) pos.x, (float) pos.y, 20, 20, ColorUtil.getColorStyle(points.indexOf(point)));
                }
            }
        }
    }
    private void createPoints(Vector3d position) {
        int numberOfStars = 40; // колва

        for (int i = 0; i < numberOfStars; i++) {
       
            Vector3d randomizedPosition = new Vector3d(
                    position.x + MathUtil.randomizeFloat(-0.5f, 0.5f),
                    position.y + MathUtil.randomizeFloat(0.0f, 2.0f),
                    position.z + MathUtil.randomizeFloat(-0.5f, 0.5f)
            );
            points.add(new Point(randomizedPosition));
        }
    }

    public final class Point {
        public Vector3d position;
        public Vector3d motion;
        public Vector3d animatedMotion;

        public long aliveTime;
        public float size;

        public long createdTime = System.currentTimeMillis();

        public Point(Vector3d position) {
            this.position = new Vector3d(position.x, position.y, position.z);
            this.motion = new Vector3d(MathUtil.randomizeFloat(0.0f, 0.0f), 0, MathUtil.randomizeFloat(0.0f, 0.0f));
            this.animatedMotion = new Vector3d(0, 0, 0);
            size = MathUtil.randomizeFloat(3, 7);
            aliveTime = ThreadLocalRandom.current().nextLong(1000, 3000);
        }


        public void update() {
            if (isGround()) {
                points.remove(points);
            } else {
                motion.y = MathUtil.randomizeFloat(-0.01f, 0.01f);
                motion.y *= 1;
                motion.x *= 1.001;
                motion.z *= 1.001;
            }


            animatedMotion.x = AnimationMath.fast((float) animatedMotion.x, (float) (motion.x), 1);
            animatedMotion.y = AnimationMath.fast((float) animatedMotion.y, (float) (motion.y), 1);
            animatedMotion.z = AnimationMath.fast((float) animatedMotion.z, (float) (motion.z), 1);

            position = position.add(animatedMotion);
        }
        boolean isGround() {
            Vector3d position = this.position.add(animatedMotion);
            AxisAlignedBB bb = new AxisAlignedBB(position.x - 0.1, position.y - 0.3, position.z - 0.1, position.x + 0.1, position.y + 0.3, position.z + 0.1);
            return WorldUtil.TotemUtil.getSphere(new BlockPos(position), 1, 2, false, true, 0)
                    .stream()
                    .anyMatch(blockPos -> !IMinecraft.mc.world.getBlockState(blockPos).isAir() &&
                            bb.intersects(new AxisAlignedBB(blockPos)) &&
                            AxisAlignedBB.calcSideHit(new AxisAlignedBB(blockPos.add(0, 0, 0)), position, new double[]{
                                    2D
                            }, null, 0.1f, 0.1f, 0.1f) == Direction.UP);
        }
    }
}
Дай MathUntil, строчку с randomizeFloat
 
Начинающий
Статус
Оффлайн
Регистрация
20 Мар 2023
Сообщения
10
Реакции[?]
0
Поинты[?]
0
Я решил повторить что-то по типу вилда, но сделал по своему. Тут звезды появляются за игроком только во время движения. Ток не оскорбляйте я ж пытался))
Пожалуйста, авторизуйтесь для просмотра ссылки.

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



Java:
package dev.rarchik.modules.impl.render;

import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import dev.rarchik.modules.Function;
import dev.rarchik.modules.FunctionAnnotation;
import dev.rarchik.modules.settings.imp.SliderSetting;
import dev.rarchik.util.IMinecraft;
import dev.rarchik.util.math.MathUtil;
import dev.rarchik.render.ProjectionUtils;
import dev.rarchik.render.RenderUtil;
import dev.rarchik.world.WorldUtil;
import org.joml.Vector2d;
import wtf.build.events.Event;
import dev.rarchik.events.impl.player.EventMotion;
import dev.rarchik.events.impl.render.EventRender;
import dev.rarchik.modules.Type;
import dev.rarchik.util.render.ColorUtil;
import dev.rarchik.util.render.animation.AnimationMath;

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

@FunctionAnnotation(name = "Trails 2", type = Type.Render)
public class Snow extends Function {

    private SliderSetting maxPoints = new SliderSetting("Сила", 200, 100, 200, 50);

    public Snow() {
        this.addSettings(maxPoints);
    }

    CopyOnWriteArrayList<Snow.Point> points = new CopyOnWriteArrayList<>();

    @Override
    public void onEvent(final Event event) {
        if (IMinecraft.mc.world == null || IMinecraft.mc.player == null) return;

        if (event instanceof EventMotion e) {
            Vector3d previousPos = new Vector3d(IMinecraft.mc.player.prevPosX, IMinecraft.mc.player.prevPosY, IMinecraft.mc.player.prevPosZ);
            Vector3d currentPos = new Vector3d(IMinecraft.mc.player.getPosX(), IMinecraft.mc.player.getPosY(), IMinecraft.mc.player.getPosZ());

            if (!previousPos.equals(currentPos)) {
                if (IMinecraft.mc.player.ticksExisted % 6 == 0) {
                    createPoints(currentPos);
                }
            }
        }
        if (event instanceof EventRender e) {
            if (points.size() > maxPoints.getValue().floatValue()) {
                points.remove(0);
            }
            for (Snow.Point point : points) {
                long alive = (System.currentTimeMillis() - point.createdTime);
                if (alive > point.aliveTime || !IMinecraft.mc.player.canVectorBeSeenFixed(point.position)) {
                    points.remove(point);
                    continue;
                }

                Vector2d pos = ProjectionUtils.project(point.position.x, point.position.y, point.position.z);

                if (pos != null) {

                    point.update();

                    RenderUtil.Render2D.drawImage(new ResourceLocation("tense/images/star.png"), (float) pos.x, (float) pos.y, 20, 20, ColorUtil.getColorStyle(points.indexOf(point)));
                }
            }
        }
    }
    private void createPoints(Vector3d position) {
        int numberOfStars = 40; // колва

        for (int i = 0; i < numberOfStars; i++) {
       
            Vector3d randomizedPosition = new Vector3d(
                    position.x + MathUtil.randomizeFloat(-0.5f, 0.5f),
                    position.y + MathUtil.randomizeFloat(0.0f, 2.0f),
                    position.z + MathUtil.randomizeFloat(-0.5f, 0.5f)
            );
            points.add(new Point(randomizedPosition));
        }
    }

    public final class Point {
        public Vector3d position;
        public Vector3d motion;
        public Vector3d animatedMotion;

        public long aliveTime;
        public float size;

        public long createdTime = System.currentTimeMillis();

        public Point(Vector3d position) {
            this.position = new Vector3d(position.x, position.y, position.z);
            this.motion = new Vector3d(MathUtil.randomizeFloat(0.0f, 0.0f), 0, MathUtil.randomizeFloat(0.0f, 0.0f));
            this.animatedMotion = new Vector3d(0, 0, 0);
            size = MathUtil.randomizeFloat(3, 7);
            aliveTime = ThreadLocalRandom.current().nextLong(1000, 3000);
        }


        public void update() {
            if (isGround()) {
                points.remove(points);
            } else {
                motion.y = MathUtil.randomizeFloat(-0.01f, 0.01f);
                motion.y *= 1;
                motion.x *= 1.001;
                motion.z *= 1.001;
            }


            animatedMotion.x = AnimationMath.fast((float) animatedMotion.x, (float) (motion.x), 1);
            animatedMotion.y = AnimationMath.fast((float) animatedMotion.y, (float) (motion.y), 1);
            animatedMotion.z = AnimationMath.fast((float) animatedMotion.z, (float) (motion.z), 1);

            position = position.add(animatedMotion);
        }
        boolean isGround() {
            Vector3d position = this.position.add(animatedMotion);
            AxisAlignedBB bb = new AxisAlignedBB(position.x - 0.1, position.y - 0.3, position.z - 0.1, position.x + 0.1, position.y + 0.3, position.z + 0.1);
            return WorldUtil.TotemUtil.getSphere(new BlockPos(position), 1, 2, false, true, 0)
                    .stream()
                    .anyMatch(blockPos -> !IMinecraft.mc.world.getBlockState(blockPos).isAir() &&
                            bb.intersects(new AxisAlignedBB(blockPos)) &&
                            AxisAlignedBB.calcSideHit(new AxisAlignedBB(blockPos.add(0, 0, 0)), position, new double[]{
                                    2D
                            }, null, 0.1f, 0.1f, 0.1f) == Direction.UP);
        }
    }
}
Было бы круто если при движении данные партиклы с земли поднимались вверх до головы
 
Начинающий
Статус
Оффлайн
Регистрация
22 Июл 2023
Сообщения
24
Реакции[?]
0
Поинты[?]
0
Я решил повторить что-то по типу вилда, но сделал по своему. Тут звезды появляются за игроком только во время движения. Ток не оскорбляйте я ж пытался))
Пожалуйста, авторизуйтесь для просмотра ссылки.

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



Java:
package dev.rarchik.modules.impl.render;

import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import dev.rarchik.modules.Function;
import dev.rarchik.modules.FunctionAnnotation;
import dev.rarchik.modules.settings.imp.SliderSetting;
import dev.rarchik.util.IMinecraft;
import dev.rarchik.util.math.MathUtil;
import dev.rarchik.render.ProjectionUtils;
import dev.rarchik.render.RenderUtil;
import dev.rarchik.world.WorldUtil;
import org.joml.Vector2d;
import wtf.build.events.Event;
import dev.rarchik.events.impl.player.EventMotion;
import dev.rarchik.events.impl.render.EventRender;
import dev.rarchik.modules.Type;
import dev.rarchik.util.render.ColorUtil;
import dev.rarchik.util.render.animation.AnimationMath;

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

@FunctionAnnotation(name = "Trails 2", type = Type.Render)
public class Snow extends Function {

    private SliderSetting maxPoints = new SliderSetting("Сила", 200, 100, 200, 50);

    public Snow() {
        this.addSettings(maxPoints);
    }

    CopyOnWriteArrayList<Snow.Point> points = new CopyOnWriteArrayList<>();

    @Override
    public void onEvent(final Event event) {
        if (IMinecraft.mc.world == null || IMinecraft.mc.player == null) return;

        if (event instanceof EventMotion e) {
            Vector3d previousPos = new Vector3d(IMinecraft.mc.player.prevPosX, IMinecraft.mc.player.prevPosY, IMinecraft.mc.player.prevPosZ);
            Vector3d currentPos = new Vector3d(IMinecraft.mc.player.getPosX(), IMinecraft.mc.player.getPosY(), IMinecraft.mc.player.getPosZ());

            if (!previousPos.equals(currentPos)) {
                if (IMinecraft.mc.player.ticksExisted % 6 == 0) {
                    createPoints(currentPos);
                }
            }
        }
        if (event instanceof EventRender e) {
            if (points.size() > maxPoints.getValue().floatValue()) {
                points.remove(0);
            }
            for (Snow.Point point : points) {
                long alive = (System.currentTimeMillis() - point.createdTime);
                if (alive > point.aliveTime || !IMinecraft.mc.player.canVectorBeSeenFixed(point.position)) {
                    points.remove(point);
                    continue;
                }

                Vector2d pos = ProjectionUtils.project(point.position.x, point.position.y, point.position.z);

                if (pos != null) {

                    point.update();

                    RenderUtil.Render2D.drawImage(new ResourceLocation("tense/images/star.png"), (float) pos.x, (float) pos.y, 20, 20, ColorUtil.getColorStyle(points.indexOf(point)));
                }
            }
        }
    }
    private void createPoints(Vector3d position) {
        int numberOfStars = 40; // колва

        for (int i = 0; i < numberOfStars; i++) {
       
            Vector3d randomizedPosition = new Vector3d(
                    position.x + MathUtil.randomizeFloat(-0.5f, 0.5f),
                    position.y + MathUtil.randomizeFloat(0.0f, 2.0f),
                    position.z + MathUtil.randomizeFloat(-0.5f, 0.5f)
            );
            points.add(new Point(randomizedPosition));
        }
    }

    public final class Point {
        public Vector3d position;
        public Vector3d motion;
        public Vector3d animatedMotion;

        public long aliveTime;
        public float size;

        public long createdTime = System.currentTimeMillis();

        public Point(Vector3d position) {
            this.position = new Vector3d(position.x, position.y, position.z);
            this.motion = new Vector3d(MathUtil.randomizeFloat(0.0f, 0.0f), 0, MathUtil.randomizeFloat(0.0f, 0.0f));
            this.animatedMotion = new Vector3d(0, 0, 0);
            size = MathUtil.randomizeFloat(3, 7);
            aliveTime = ThreadLocalRandom.current().nextLong(1000, 3000);
        }


        public void update() {
            if (isGround()) {
                points.remove(points);
            } else {
                motion.y = MathUtil.randomizeFloat(-0.01f, 0.01f);
                motion.y *= 1;
                motion.x *= 1.001;
                motion.z *= 1.001;
            }


            animatedMotion.x = AnimationMath.fast((float) animatedMotion.x, (float) (motion.x), 1);
            animatedMotion.y = AnimationMath.fast((float) animatedMotion.y, (float) (motion.y), 1);
            animatedMotion.z = AnimationMath.fast((float) animatedMotion.z, (float) (motion.z), 1);

            position = position.add(animatedMotion);
        }
        boolean isGround() {
            Vector3d position = this.position.add(animatedMotion);
            AxisAlignedBB bb = new AxisAlignedBB(position.x - 0.1, position.y - 0.3, position.z - 0.1, position.x + 0.1, position.y + 0.3, position.z + 0.1);
            return WorldUtil.TotemUtil.getSphere(new BlockPos(position), 1, 2, false, true, 0)
                    .stream()
                    .anyMatch(blockPos -> !IMinecraft.mc.world.getBlockState(blockPos).isAir() &&
                            bb.intersects(new AxisAlignedBB(blockPos)) &&
                            AxisAlignedBB.calcSideHit(new AxisAlignedBB(blockPos.add(0, 0, 0)), position, new double[]{
                                    2D
                            }, null, 0.1f, 0.1f, 0.1f) == Direction.UP);
        }
    }
}
/del легко пишется
 
Сверху Снизу