Predictions как в нурике (почти) eva ready

Начинающий
Статус
Оффлайн
Регистрация
19 Мар 2022
Сообщения
14
Реакции[?]
0
Поинты[?]
0
ss ->
Пожалуйста, авторизуйтесь для просмотра ссылки.




Java:
package cc.paycheck.modules.impl.render;

import com.google.common.eventbus.Subscribe;
import cc.paycheck.modules.settings.impl.ColorSetting;
import cc.paycheck.utils.client.IMinecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import cc.paycheck.events.EventDisplay;
import cc.paycheck.events.WorldEvent;
import cc.paycheck.modules.api.Category;
import cc.paycheck.modules.api.Module;
import cc.paycheck.modules.api.ModuleRegister;
import cc.paycheck.utils.math.Vector4i;
import cc.paycheck.utils.projections.ProjectionUtil;
import cc.paycheck.utils.render.color.ColorUtils;
import cc.paycheck.utils.render.rect.DisplayUtils;
import cc.paycheck.utils.render.font.Fonts;
import net.minecraft.util.math.vector.Vector4f;

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

import static org.lwjgl.opengl.GL11.*;

@ModuleRegister(name = "Predictions", category = Category.Render)
public class Predictions extends Module {


    private float lineWidth = 1.5f;

    public Predictions() {

    }

    public void setLineWidth(float newWidth) {
        if (newWidth >= 1.0f && newWidth <= 10.0f) {
            lineWidth = newWidth;
            System.out.println("Толщина линии изменена на: " + lineWidth);
        } else {
            System.out.println("Толщина линии должна быть в диапазоне от 1.0 до 10.0.");
        }
    }

    record ThrowablePoint(Vector3d position, int ticks, ResourceLocation texture) {
    }

    final List<ThrowablePoint> throwablePoints = new ArrayList<>();

    @Subscribe
    public void onRender(EventDisplay e) {
        for (ThrowablePoint throwablePoint : throwablePoints) {
            Vector3d pos = throwablePoint.position;
            Vector2f projection = ProjectionUtil.project(pos.x, pos.y - 0.3F, pos.z);
            int ticks = throwablePoint.ticks;
            ResourceLocation texture = throwablePoint.texture;

            if (projection.equals(new Vector2f(Float.MAX_VALUE, Float.MAX_VALUE))) {
                continue;
            }


            boolean isMoving = ticks > 0;

            if (isMoving) {
                double time = ticks * 50 / 1000.0;
                String text = String.format("%.1f" + " сек.", time);
                float width = Fonts.montserrat.getWidth(text, 5);

                float textWidth = width + 8 + 8;

                float posX = projection.x - textWidth / 2;
                float posY = projection.y;

                DisplayUtils.drawRoundedRect(posX + 2, posY + 2 - 3, textWidth - 4, 12 - 3, 0, ColorUtils.rgba(24, 24, 24, 80));
                DisplayUtils.drawImage(texture, (int) posX + 4, (int) posY + 2 + 1 - 4, 8, 8, -1);
                Fonts.montserrat.drawText(e.getMatrixStack(), text, (float) (posX + 14), (float) (posY + 4.5f - 4), -1, 5);
            }


        }
    }

    @Subscribe
    public void onWorldRender(WorldEvent event) {
        glPushMatrix();

        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);

        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);

        Vector3d renderOffset = mc.getRenderManager().info.getProjectedView();

        glTranslated(-renderOffset.x, -renderOffset.y, -renderOffset.z);


        glLineWidth(lineWidth);

        buffer.begin(1, DefaultVertexFormats.POSITION);

        throwablePoints.clear();
        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof ThrowableEntity throwable) {

                Vector3d motion = throwable.getMotion();
                Vector3d pos = throwable.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ResourceLocation texture = getTextureForThrowable(throwable);

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotion(throwable, motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            throwable
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            } else if (entity instanceof ItemEntity itemEntity) {

                Vector3d motion = itemEntity.getMotion();
                Vector3d pos = itemEntity.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ItemStack itemStack = itemEntity.getItem();
                ResourceLocation texture = getTextureForItem(itemStack.getItem());

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotionForItem(motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            itemEntity
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            }
        }

        tessellator.draw();

        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);

        glPopMatrix();
    }

    private Vector3d getNextMotion(ThrowableEntity throwable, Vector3d motion) {
        if (throwable.isInWater()) {
            motion = motion.scale(0.8);
        } else {
            motion = motion.scale(0.99);
        }

        if (!throwable.hasNoGravity()) {
            motion.y -= throwable.getGravityVelocity();
        }

        return motion;
    }

    private Vector3d getNextMotionForItem(Vector3d motion) {

        motion = motion.scale(0.99);
        motion = motion.subtract(0, 0.04, 0);
        return motion;
    }

    private ResourceLocation getTextureForThrowable(ThrowableEntity throwable) {
        if (throwable instanceof EnderPearlEntity) {
            return new ResourceLocation("textures/item/ender_pearl.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("snowball")) {
            return new ResourceLocation("textures/item/snowball.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("egg")) {
            return new ResourceLocation("textures/item/egg.png");
        } else {
            System.err.println("Unknown throwable type: " + throwable.getClass().getSimpleName());
            return new ResourceLocation("textures/item/ender_pearl.png");
        }
    }

    private ResourceLocation getTextureForItem(Item item) {

        String itemName = item.getTranslationKey().replace("item.minecraft.", "");
        ResourceLocation texture = new ResourceLocation("textures/item/" + itemName + ".png");


        System.out.println("Requested texture: " + texture);

        return texture;
    }
}
 
Начинающий
Статус
Оффлайн
Регистрация
27 Янв 2024
Сообщения
68
Реакции[?]
1
Поинты[?]
1K
спасибо! только после данного поста не заходи на сайт!
 
Начинающий
Статус
Оффлайн
Регистрация
21 Ноя 2024
Сообщения
11
Реакции[?]
0
Поинты[?]
0
package eva.ware.modules.impl.movement;

import com.google.common.eventbus.Subscribe;
import eva.ware.events.EventMotion;
import eva.ware.modules.api.Category;
import eva.ware.modules.api.Module;
import eva.ware.modules.api.ModuleRegister;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import eva.ware.utils.player.MoveUtils;
import net.minecraft.util.math.BlockPos;

@ModuleRegister(name = "Speed", category = Category.Movement)
public class Speed extends Module {

private final Minecraft mc = Minecraft.getInstance();

@Subscribe
public void onMotion(EventMotion event) {
// Check if the player is on snow
BlockPos playerPos = new BlockPos(mc.player.getPosX(), mc.player.getPosY() - 1, mc.player.getPosZ());
if (mc.world.getBlockState(playerPos).getBlock() == Blocks.SNOW || mc.world.getBlockState(playerPos).getBlock() == Blocks.SNOW_BLOCK) {
handleFuntimeSnow();
}
}

private void handleFuntimeSnow() {
mc.player.jumpMovementFactor = 0.035f;

if (!mc.player.isOnGround()) return;

if (!MoveUtils.isMoving()) return;


if (mc.player.collidedHorizontally && mc.gameSettings.keyBindJump.isPressed()) {
mc.player.jump();
return;
}


mc.player.jump();
mc.player.motion.y = 0.0;
}
}
 
Начинающий
Статус
Оффлайн
Регистрация
16 Июл 2024
Сообщения
114
Реакции[?]
1
Поинты[?]
1K
ss ->
Пожалуйста, авторизуйтесь для просмотра ссылки.




Java:
package cc.paycheck.modules.impl.render;

import com.google.common.eventbus.Subscribe;
import cc.paycheck.modules.settings.impl.ColorSetting;
import cc.paycheck.utils.client.IMinecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import cc.paycheck.events.EventDisplay;
import cc.paycheck.events.WorldEvent;
import cc.paycheck.modules.api.Category;
import cc.paycheck.modules.api.Module;
import cc.paycheck.modules.api.ModuleRegister;
import cc.paycheck.utils.math.Vector4i;
import cc.paycheck.utils.projections.ProjectionUtil;
import cc.paycheck.utils.render.color.ColorUtils;
import cc.paycheck.utils.render.rect.DisplayUtils;
import cc.paycheck.utils.render.font.Fonts;
import net.minecraft.util.math.vector.Vector4f;

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

import static org.lwjgl.opengl.GL11.*;

@ModuleRegister(name = "Predictions", category = Category.Render)
public class Predictions extends Module {


    private float lineWidth = 1.5f;

    public Predictions() {

    }

    public void setLineWidth(float newWidth) {
        if (newWidth >= 1.0f && newWidth <= 10.0f) {
            lineWidth = newWidth;
            System.out.println("Толщина линии изменена на: " + lineWidth);
        } else {
            System.out.println("Толщина линии должна быть в диапазоне от 1.0 до 10.0.");
        }
    }

    record ThrowablePoint(Vector3d position, int ticks, ResourceLocation texture) {
    }

    final List<ThrowablePoint> throwablePoints = new ArrayList<>();

    @Subscribe
    public void onRender(EventDisplay e) {
        for (ThrowablePoint throwablePoint : throwablePoints) {
            Vector3d pos = throwablePoint.position;
            Vector2f projection = ProjectionUtil.project(pos.x, pos.y - 0.3F, pos.z);
            int ticks = throwablePoint.ticks;
            ResourceLocation texture = throwablePoint.texture;

            if (projection.equals(new Vector2f(Float.MAX_VALUE, Float.MAX_VALUE))) {
                continue;
            }


            boolean isMoving = ticks > 0;

            if (isMoving) {
                double time = ticks * 50 / 1000.0;
                String text = String.format("%.1f" + " сек.", time);
                float width = Fonts.montserrat.getWidth(text, 5);

                float textWidth = width + 8 + 8;

                float posX = projection.x - textWidth / 2;
                float posY = projection.y;

                DisplayUtils.drawRoundedRect(posX + 2, posY + 2 - 3, textWidth - 4, 12 - 3, 0, ColorUtils.rgba(24, 24, 24, 80));
                DisplayUtils.drawImage(texture, (int) posX + 4, (int) posY + 2 + 1 - 4, 8, 8, -1);
                Fonts.montserrat.drawText(e.getMatrixStack(), text, (float) (posX + 14), (float) (posY + 4.5f - 4), -1, 5);
            }


        }
    }

    @Subscribe
    public void onWorldRender(WorldEvent event) {
        glPushMatrix();

        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);

        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);

        Vector3d renderOffset = mc.getRenderManager().info.getProjectedView();

        glTranslated(-renderOffset.x, -renderOffset.y, -renderOffset.z);


        glLineWidth(lineWidth);

        buffer.begin(1, DefaultVertexFormats.POSITION);

        throwablePoints.clear();
        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof ThrowableEntity throwable) {

                Vector3d motion = throwable.getMotion();
                Vector3d pos = throwable.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ResourceLocation texture = getTextureForThrowable(throwable);

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotion(throwable, motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            throwable
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            } else if (entity instanceof ItemEntity itemEntity) {

                Vector3d motion = itemEntity.getMotion();
                Vector3d pos = itemEntity.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ItemStack itemStack = itemEntity.getItem();
                ResourceLocation texture = getTextureForItem(itemStack.getItem());

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotionForItem(motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            itemEntity
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            }
        }

        tessellator.draw();

        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);

        glPopMatrix();
    }

    private Vector3d getNextMotion(ThrowableEntity throwable, Vector3d motion) {
        if (throwable.isInWater()) {
            motion = motion.scale(0.8);
        } else {
            motion = motion.scale(0.99);
        }

        if (!throwable.hasNoGravity()) {
            motion.y -= throwable.getGravityVelocity();
        }

        return motion;
    }

    private Vector3d getNextMotionForItem(Vector3d motion) {

        motion = motion.scale(0.99);
        motion = motion.subtract(0, 0.04, 0);
        return motion;
    }

    private ResourceLocation getTextureForThrowable(ThrowableEntity throwable) {
        if (throwable instanceof EnderPearlEntity) {
            return new ResourceLocation("textures/item/ender_pearl.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("snowball")) {
            return new ResourceLocation("textures/item/snowball.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("egg")) {
            return new ResourceLocation("textures/item/egg.png");
        } else {
            System.err.println("Unknown throwable type: " + throwable.getClass().getSimpleName());
            return new ResourceLocation("textures/item/ender_pearl.png");
        }
    }

    private ResourceLocation getTextureForItem(Item item) {

        String itemName = item.getTranslationKey().replace("item.minecraft.", "");
        ResourceLocation texture = new ResourceLocation("textures/item/" + itemName + ".png");


        System.out.println("Requested texture: " + texture);

        return texture;
    }
}
советовал бы перед тем как что-то выкладывать сначало подумать
 
Начинающий
Статус
Оффлайн
Регистрация
13 Июл 2024
Сообщения
66
Реакции[?]
0
Поинты[?]
0
ss ->
Пожалуйста, авторизуйтесь для просмотра ссылки.




Java:
package cc.paycheck.modules.impl.render;

import com.google.common.eventbus.Subscribe;
import cc.paycheck.modules.settings.impl.ColorSetting;
import cc.paycheck.utils.client.IMinecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import cc.paycheck.events.EventDisplay;
import cc.paycheck.events.WorldEvent;
import cc.paycheck.modules.api.Category;
import cc.paycheck.modules.api.Module;
import cc.paycheck.modules.api.ModuleRegister;
import cc.paycheck.utils.math.Vector4i;
import cc.paycheck.utils.projections.ProjectionUtil;
import cc.paycheck.utils.render.color.ColorUtils;
import cc.paycheck.utils.render.rect.DisplayUtils;
import cc.paycheck.utils.render.font.Fonts;
import net.minecraft.util.math.vector.Vector4f;

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

import static org.lwjgl.opengl.GL11.*;

@ModuleRegister(name = "Predictions", category = Category.Render)
public class Predictions extends Module {


    private float lineWidth = 1.5f;

    public Predictions() {

    }

    public void setLineWidth(float newWidth) {
        if (newWidth >= 1.0f && newWidth <= 10.0f) {
            lineWidth = newWidth;
            System.out.println("Толщина линии изменена на: " + lineWidth);
        } else {
            System.out.println("Толщина линии должна быть в диапазоне от 1.0 до 10.0.");
        }
    }

    record ThrowablePoint(Vector3d position, int ticks, ResourceLocation texture) {
    }

    final List<ThrowablePoint> throwablePoints = new ArrayList<>();

    @Subscribe
    public void onRender(EventDisplay e) {
        for (ThrowablePoint throwablePoint : throwablePoints) {
            Vector3d pos = throwablePoint.position;
            Vector2f projection = ProjectionUtil.project(pos.x, pos.y - 0.3F, pos.z);
            int ticks = throwablePoint.ticks;
            ResourceLocation texture = throwablePoint.texture;

            if (projection.equals(new Vector2f(Float.MAX_VALUE, Float.MAX_VALUE))) {
                continue;
            }


            boolean isMoving = ticks > 0;

            if (isMoving) {
                double time = ticks * 50 / 1000.0;
                String text = String.format("%.1f" + " сек.", time);
                float width = Fonts.montserrat.getWidth(text, 5);

                float textWidth = width + 8 + 8;

                float posX = projection.x - textWidth / 2;
                float posY = projection.y;

                DisplayUtils.drawRoundedRect(posX + 2, posY + 2 - 3, textWidth - 4, 12 - 3, 0, ColorUtils.rgba(24, 24, 24, 80));
                DisplayUtils.drawImage(texture, (int) posX + 4, (int) posY + 2 + 1 - 4, 8, 8, -1);
                Fonts.montserrat.drawText(e.getMatrixStack(), text, (float) (posX + 14), (float) (posY + 4.5f - 4), -1, 5);
            }


        }
    }

    @Subscribe
    public void onWorldRender(WorldEvent event) {
        glPushMatrix();

        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);

        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);

        Vector3d renderOffset = mc.getRenderManager().info.getProjectedView();

        glTranslated(-renderOffset.x, -renderOffset.y, -renderOffset.z);


        glLineWidth(lineWidth);

        buffer.begin(1, DefaultVertexFormats.POSITION);

        throwablePoints.clear();
        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof ThrowableEntity throwable) {

                Vector3d motion = throwable.getMotion();
                Vector3d pos = throwable.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ResourceLocation texture = getTextureForThrowable(throwable);

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotion(throwable, motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            throwable
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            } else if (entity instanceof ItemEntity itemEntity) {

                Vector3d motion = itemEntity.getMotion();
                Vector3d pos = itemEntity.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ItemStack itemStack = itemEntity.getItem();
                ResourceLocation texture = getTextureForItem(itemStack.getItem());

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotionForItem(motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            itemEntity
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            }
        }

        tessellator.draw();

        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);

        glPopMatrix();
    }

    private Vector3d getNextMotion(ThrowableEntity throwable, Vector3d motion) {
        if (throwable.isInWater()) {
            motion = motion.scale(0.8);
        } else {
            motion = motion.scale(0.99);
        }

        if (!throwable.hasNoGravity()) {
            motion.y -= throwable.getGravityVelocity();
        }

        return motion;
    }

    private Vector3d getNextMotionForItem(Vector3d motion) {

        motion = motion.scale(0.99);
        motion = motion.subtract(0, 0.04, 0);
        return motion;
    }

    private ResourceLocation getTextureForThrowable(ThrowableEntity throwable) {
        if (throwable instanceof EnderPearlEntity) {
            return new ResourceLocation("textures/item/ender_pearl.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("snowball")) {
            return new ResourceLocation("textures/item/snowball.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("egg")) {
            return new ResourceLocation("textures/item/egg.png");
        } else {
            System.err.println("Unknown throwable type: " + throwable.getClass().getSimpleName());
            return new ResourceLocation("textures/item/ender_pearl.png");
        }
    }

    private ResourceLocation getTextureForItem(Item item) {

        String itemName = item.getTranslationKey().replace("item.minecraft.", "");
        ResourceLocation texture = new ResourceLocation("textures/item/" + itemName + ".png");


        System.out.println("Requested texture: " + texture);

        return texture;
    }
}
ss ->
Пожалуйста, авторизуйтесь для просмотра ссылки.




Java:
package cc.paycheck.modules.impl.render;

import com.google.common.eventbus.Subscribe;
import cc.paycheck.modules.settings.impl.ColorSetting;
import cc.paycheck.utils.client.IMinecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import cc.paycheck.events.EventDisplay;
import cc.paycheck.events.WorldEvent;
import cc.paycheck.modules.api.Category;
import cc.paycheck.modules.api.Module;
import cc.paycheck.modules.api.ModuleRegister;
import cc.paycheck.utils.math.Vector4i;
import cc.paycheck.utils.projections.ProjectionUtil;
import cc.paycheck.utils.render.color.ColorUtils;
import cc.paycheck.utils.render.rect.DisplayUtils;
import cc.paycheck.utils.render.font.Fonts;
import net.minecraft.util.math.vector.Vector4f;

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

import static org.lwjgl.opengl.GL11.*;

@ModuleRegister(name = "Predictions", category = Category.Render)
public class Predictions extends Module {


    private float lineWidth = 1.5f;

    public Predictions() {

    }

    public void setLineWidth(float newWidth) {
        if (newWidth >= 1.0f && newWidth <= 10.0f) {
            lineWidth = newWidth;
            System.out.println("Толщина линии изменена на: " + lineWidth);
        } else {
            System.out.println("Толщина линии должна быть в диапазоне от 1.0 до 10.0.");
        }
    }

    record ThrowablePoint(Vector3d position, int ticks, ResourceLocation texture) {
    }

    final List<ThrowablePoint> throwablePoints = new ArrayList<>();

    @Subscribe
    public void onRender(EventDisplay e) {
        for (ThrowablePoint throwablePoint : throwablePoints) {
            Vector3d pos = throwablePoint.position;
            Vector2f projection = ProjectionUtil.project(pos.x, pos.y - 0.3F, pos.z);
            int ticks = throwablePoint.ticks;
            ResourceLocation texture = throwablePoint.texture;

            if (projection.equals(new Vector2f(Float.MAX_VALUE, Float.MAX_VALUE))) {
                continue;
            }


            boolean isMoving = ticks > 0;

            if (isMoving) {
                double time = ticks * 50 / 1000.0;
                String text = String.format("%.1f" + " сек.", time);
                float width = Fonts.montserrat.getWidth(text, 5);

                float textWidth = width + 8 + 8;

                float posX = projection.x - textWidth / 2;
                float posY = projection.y;

                DisplayUtils.drawRoundedRect(posX + 2, posY + 2 - 3, textWidth - 4, 12 - 3, 0, ColorUtils.rgba(24, 24, 24, 80));
                DisplayUtils.drawImage(texture, (int) posX + 4, (int) posY + 2 + 1 - 4, 8, 8, -1);
                Fonts.montserrat.drawText(e.getMatrixStack(), text, (float) (posX + 14), (float) (posY + 4.5f - 4), -1, 5);
            }


        }
    }

    @Subscribe
    public void onWorldRender(WorldEvent event) {
        glPushMatrix();

        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);

        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);

        Vector3d renderOffset = mc.getRenderManager().info.getProjectedView();

        glTranslated(-renderOffset.x, -renderOffset.y, -renderOffset.z);


        glLineWidth(lineWidth);

        buffer.begin(1, DefaultVertexFormats.POSITION);

        throwablePoints.clear();
        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof ThrowableEntity throwable) {

                Vector3d motion = throwable.getMotion();
                Vector3d pos = throwable.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ResourceLocation texture = getTextureForThrowable(throwable);

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotion(throwable, motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            throwable
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            } else if (entity instanceof ItemEntity itemEntity) {

                Vector3d motion = itemEntity.getMotion();
                Vector3d pos = itemEntity.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ItemStack itemStack = itemEntity.getItem();
                ResourceLocation texture = getTextureForItem(itemStack.getItem());

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotionForItem(motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            itemEntity
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            }
        }

        tessellator.draw();

        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);

        glPopMatrix();
    }

    private Vector3d getNextMotion(ThrowableEntity throwable, Vector3d motion) {
        if (throwable.isInWater()) {
            motion = motion.scale(0.8);
        } else {
            motion = motion.scale(0.99);
        }

        if (!throwable.hasNoGravity()) {
            motion.y -= throwable.getGravityVelocity();
        }

        return motion;
    }

    private Vector3d getNextMotionForItem(Vector3d motion) {

        motion = motion.scale(0.99);
        motion = motion.subtract(0, 0.04, 0);
        return motion;
    }

    private ResourceLocation getTextureForThrowable(ThrowableEntity throwable) {
        if (throwable instanceof EnderPearlEntity) {
            return new ResourceLocation("textures/item/ender_pearl.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("snowball")) {
            return new ResourceLocation("textures/item/snowball.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("egg")) {
            return new ResourceLocation("textures/item/egg.png");
        } else {
            System.err.println("Unknown throwable type: " + throwable.getClass().getSimpleName());
            return new ResourceLocation("textures/item/ender_pearl.png");
        }
    }

    private ResourceLocation getTextureForItem(Item item) {

        String itemName = item.getTranslationKey().replace("item.minecraft.", "");
        ResourceLocation texture = new ResourceLocation("textures/item/" + itemName + ".png");


        System.out.println("Requested texture: " + texture);

        return texture;
    }
}
овнеры еверласта бегут пастить
 
Начинающий
Статус
Оффлайн
Регистрация
11 Дек 2023
Сообщения
34
Реакции[?]
0
Поинты[?]
1K
ss ->
Пожалуйста, авторизуйтесь для просмотра ссылки.




Java:
package cc.paycheck.modules.impl.render;

import com.google.common.eventbus.Subscribe;
import cc.paycheck.modules.settings.impl.ColorSetting;
import cc.paycheck.utils.client.IMinecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import cc.paycheck.events.EventDisplay;
import cc.paycheck.events.WorldEvent;
import cc.paycheck.modules.api.Category;
import cc.paycheck.modules.api.Module;
import cc.paycheck.modules.api.ModuleRegister;
import cc.paycheck.utils.math.Vector4i;
import cc.paycheck.utils.projections.ProjectionUtil;
import cc.paycheck.utils.render.color.ColorUtils;
import cc.paycheck.utils.render.rect.DisplayUtils;
import cc.paycheck.utils.render.font.Fonts;
import net.minecraft.util.math.vector.Vector4f;

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

import static org.lwjgl.opengl.GL11.*;

@ModuleRegister(name = "Predictions", category = Category.Render)
public class Predictions extends Module {


    private float lineWidth = 1.5f;

    public Predictions() {

    }

    public void setLineWidth(float newWidth) {
        if (newWidth >= 1.0f && newWidth <= 10.0f) {
            lineWidth = newWidth;
            System.out.println("Толщина линии изменена на: " + lineWidth);
        } else {
            System.out.println("Толщина линии должна быть в диапазоне от 1.0 до 10.0.");
        }
    }

    record ThrowablePoint(Vector3d position, int ticks, ResourceLocation texture) {
    }

    final List<ThrowablePoint> throwablePoints = new ArrayList<>();

    @Subscribe
    public void onRender(EventDisplay e) {
        for (ThrowablePoint throwablePoint : throwablePoints) {
            Vector3d pos = throwablePoint.position;
            Vector2f projection = ProjectionUtil.project(pos.x, pos.y - 0.3F, pos.z);
            int ticks = throwablePoint.ticks;
            ResourceLocation texture = throwablePoint.texture;

            if (projection.equals(new Vector2f(Float.MAX_VALUE, Float.MAX_VALUE))) {
                continue;
            }


            boolean isMoving = ticks > 0;

            if (isMoving) {
                double time = ticks * 50 / 1000.0;
                String text = String.format("%.1f" + " сек.", time);
                float width = Fonts.montserrat.getWidth(text, 5);

                float textWidth = width + 8 + 8;

                float posX = projection.x - textWidth / 2;
                float posY = projection.y;

                DisplayUtils.drawRoundedRect(posX + 2, posY + 2 - 3, textWidth - 4, 12 - 3, 0, ColorUtils.rgba(24, 24, 24, 80));
                DisplayUtils.drawImage(texture, (int) posX + 4, (int) posY + 2 + 1 - 4, 8, 8, -1);
                Fonts.montserrat.drawText(e.getMatrixStack(), text, (float) (posX + 14), (float) (posY + 4.5f - 4), -1, 5);
            }


        }
    }

    @Subscribe
    public void onWorldRender(WorldEvent event) {
        glPushMatrix();

        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);

        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);

        Vector3d renderOffset = mc.getRenderManager().info.getProjectedView();

        glTranslated(-renderOffset.x, -renderOffset.y, -renderOffset.z);


        glLineWidth(lineWidth);

        buffer.begin(1, DefaultVertexFormats.POSITION);

        throwablePoints.clear();
        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof ThrowableEntity throwable) {

                Vector3d motion = throwable.getMotion();
                Vector3d pos = throwable.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ResourceLocation texture = getTextureForThrowable(throwable);

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotion(throwable, motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            throwable
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            } else if (entity instanceof ItemEntity itemEntity) {

                Vector3d motion = itemEntity.getMotion();
                Vector3d pos = itemEntity.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ItemStack itemStack = itemEntity.getItem();
                ResourceLocation texture = getTextureForItem(itemStack.getItem());

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotionForItem(motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            itemEntity
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            }
        }

        tessellator.draw();

        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);

        glPopMatrix();
    }

    private Vector3d getNextMotion(ThrowableEntity throwable, Vector3d motion) {
        if (throwable.isInWater()) {
            motion = motion.scale(0.8);
        } else {
            motion = motion.scale(0.99);
        }

        if (!throwable.hasNoGravity()) {
            motion.y -= throwable.getGravityVelocity();
        }

        return motion;
    }

    private Vector3d getNextMotionForItem(Vector3d motion) {

        motion = motion.scale(0.99);
        motion = motion.subtract(0, 0.04, 0);
        return motion;
    }

    private ResourceLocation getTextureForThrowable(ThrowableEntity throwable) {
        if (throwable instanceof EnderPearlEntity) {
            return new ResourceLocation("textures/item/ender_pearl.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("snowball")) {
            return new ResourceLocation("textures/item/snowball.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("egg")) {
            return new ResourceLocation("textures/item/egg.png");
        } else {
            System.err.println("Unknown throwable type: " + throwable.getClass().getSimpleName());
            return new ResourceLocation("textures/item/ender_pearl.png");
        }
    }

    private ResourceLocation getTextureForItem(Item item) {

        String itemName = item.getTranslationKey().replace("item.minecraft.", "");
        ResourceLocation texture = new ResourceLocation("textures/item/" + itemName + ".png");


        System.out.println("Requested texture: " + texture);

        return texture;
    }
}
годно
 
Начинающий
Статус
Оффлайн
Регистрация
29 Окт 2024
Сообщения
109
Реакции[?]
1
Поинты[?]
1K
ss ->
Пожалуйста, авторизуйтесь для просмотра ссылки.




Java:
package cc.paycheck.modules.impl.render;

import com.google.common.eventbus.Subscribe;
import cc.paycheck.modules.settings.impl.ColorSetting;
import cc.paycheck.utils.client.IMinecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import cc.paycheck.events.EventDisplay;
import cc.paycheck.events.WorldEvent;
import cc.paycheck.modules.api.Category;
import cc.paycheck.modules.api.Module;
import cc.paycheck.modules.api.ModuleRegister;
import cc.paycheck.utils.math.Vector4i;
import cc.paycheck.utils.projections.ProjectionUtil;
import cc.paycheck.utils.render.color.ColorUtils;
import cc.paycheck.utils.render.rect.DisplayUtils;
import cc.paycheck.utils.render.font.Fonts;
import net.minecraft.util.math.vector.Vector4f;

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

import static org.lwjgl.opengl.GL11.*;

@ModuleRegister(name = "Predictions", category = Category.Render)
public class Predictions extends Module {


    private float lineWidth = 1.5f;

    public Predictions() {

    }

    public void setLineWidth(float newWidth) {
        if (newWidth >= 1.0f && newWidth <= 10.0f) {
            lineWidth = newWidth;
            System.out.println("Толщина линии изменена на: " + lineWidth);
        } else {
            System.out.println("Толщина линии должна быть в диапазоне от 1.0 до 10.0.");
        }
    }

    record ThrowablePoint(Vector3d position, int ticks, ResourceLocation texture) {
    }

    final List<ThrowablePoint> throwablePoints = new ArrayList<>();

    @Subscribe
    public void onRender(EventDisplay e) {
        for (ThrowablePoint throwablePoint : throwablePoints) {
            Vector3d pos = throwablePoint.position;
            Vector2f projection = ProjectionUtil.project(pos.x, pos.y - 0.3F, pos.z);
            int ticks = throwablePoint.ticks;
            ResourceLocation texture = throwablePoint.texture;

            if (projection.equals(new Vector2f(Float.MAX_VALUE, Float.MAX_VALUE))) {
                continue;
            }


            boolean isMoving = ticks > 0;

            if (isMoving) {
                double time = ticks * 50 / 1000.0;
                String text = String.format("%.1f" + " сек.", time);
                float width = Fonts.montserrat.getWidth(text, 5);

                float textWidth = width + 8 + 8;

                float posX = projection.x - textWidth / 2;
                float posY = projection.y;

                DisplayUtils.drawRoundedRect(posX + 2, posY + 2 - 3, textWidth - 4, 12 - 3, 0, ColorUtils.rgba(24, 24, 24, 80));
                DisplayUtils.drawImage(texture, (int) posX + 4, (int) posY + 2 + 1 - 4, 8, 8, -1);
                Fonts.montserrat.drawText(e.getMatrixStack(), text, (float) (posX + 14), (float) (posY + 4.5f - 4), -1, 5);
            }


        }
    }

    @Subscribe
    public void onWorldRender(WorldEvent event) {
        glPushMatrix();

        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);

        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);

        Vector3d renderOffset = mc.getRenderManager().info.getProjectedView();

        glTranslated(-renderOffset.x, -renderOffset.y, -renderOffset.z);


        glLineWidth(lineWidth);

        buffer.begin(1, DefaultVertexFormats.POSITION);

        throwablePoints.clear();
        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof ThrowableEntity throwable) {

                Vector3d motion = throwable.getMotion();
                Vector3d pos = throwable.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ResourceLocation texture = getTextureForThrowable(throwable);

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotion(throwable, motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            throwable
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            } else if (entity instanceof ItemEntity itemEntity) {

                Vector3d motion = itemEntity.getMotion();
                Vector3d pos = itemEntity.getPositionVec();
                Vector3d prevPos;
                int ticks = 0;

                ItemStack itemStack = itemEntity.getItem();
                ResourceLocation texture = getTextureForItem(itemStack.getItem());

                for (int i = 0; i < 150; i++) {
                    prevPos = pos;
                    pos = pos.add(motion);
                    motion = getNextMotionForItem(motion);
                    ColorUtils.setAlpha(ColorUtils.getColor(0), 165);

                    buffer.pos(prevPos.x, prevPos.y, prevPos.z).endVertex();

                    RayTraceContext rayTraceContext = new RayTraceContext(
                            prevPos,
                            pos,
                            RayTraceContext.BlockMode.COLLIDER,
                            RayTraceContext.FluidMode.NONE,
                            itemEntity
                    );

                    BlockRayTraceResult blockHitResult = mc.world.rayTraceBlocks(rayTraceContext);

                    boolean isLast = blockHitResult.getType() == RayTraceResult.Type.BLOCK;

                    if (isLast) {
                        pos = blockHitResult.getHitVec();
                    }

                    buffer.pos(pos.x, pos.y, pos.z).endVertex();

                    if (blockHitResult.getType() == BlockRayTraceResult.Type.BLOCK || pos.y < -128) {

                        if (motion.lengthSquared() < 0.04) {
                            break;
                        }
                        throwablePoints.add(new ThrowablePoint(pos, ticks, texture));
                        break;
                    }
                    ticks++;
                }
            }
        }

        tessellator.draw();

        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);

        glPopMatrix();
    }

    private Vector3d getNextMotion(ThrowableEntity throwable, Vector3d motion) {
        if (throwable.isInWater()) {
            motion = motion.scale(0.8);
        } else {
            motion = motion.scale(0.99);
        }

        if (!throwable.hasNoGravity()) {
            motion.y -= throwable.getGravityVelocity();
        }

        return motion;
    }

    private Vector3d getNextMotionForItem(Vector3d motion) {

        motion = motion.scale(0.99);
        motion = motion.subtract(0, 0.04, 0);
        return motion;
    }

    private ResourceLocation getTextureForThrowable(ThrowableEntity throwable) {
        if (throwable instanceof EnderPearlEntity) {
            return new ResourceLocation("textures/item/ender_pearl.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("snowball")) {
            return new ResourceLocation("textures/item/snowball.png");
        } else if (throwable.getClass().getSimpleName().toLowerCase().contains("egg")) {
            return new ResourceLocation("textures/item/egg.png");
        } else {
            System.err.println("Unknown throwable type: " + throwable.getClass().getSimpleName());
            return new ResourceLocation("textures/item/ender_pearl.png");
        }
    }

    private ResourceLocation getTextureForItem(Item item) {

        String itemName = item.getTranslationKey().replace("item.minecraft.", "");
        ResourceLocation texture = new ResourceLocation("textures/item/" + itemName + ".png");


        System.out.println("Requested texture: " + texture);

        return texture;
    }
}
а блоки не в счет?
 
Начинающий
Статус
Оффлайн
Регистрация
27 Янв 2024
Сообщения
68
Реакции[?]
1
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
19 Мар 2022
Сообщения
14
Реакции[?]
0
Поинты[?]
0
я уже давно написал что это рофл был xd,там же онли геттер оставить надо а калькулятор вырезать можно
cool 👍
package eva.ware.modules.impl.movement;

import com.google.common.eventbus.Subscribe;
import eva.ware.events.EventMotion;
import eva.ware.modules.api.Category;
import eva.ware.modules.api.Module;
import eva.ware.modules.api.ModuleRegister;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import eva.ware.utils.player.MoveUtils;
import net.minecraft.util.math.BlockPos;

@ModuleRegister(name = "Speed", category = Category.Movement)
public class Speed extends Module {

private final Minecraft mc = Minecraft.getInstance();

@Subscribe
public void onMotion(EventMotion event) {
// Check if the player is on snow
BlockPos playerPos = new BlockPos(mc.player.getPosX(), mc.player.getPosY() - 1, mc.player.getPosZ());
if (mc.world.getBlockState(playerPos).getBlock() == Blocks.SNOW || mc.world.getBlockState(playerPos).getBlock() == Blocks.SNOW_BLOCK) {
handleFuntimeSnow();
}
}

private void handleFuntimeSnow() {
mc.player.jumpMovementFactor = 0.035f;

if (!mc.player.isOnGround()) return;

if (!MoveUtils.isMoving()) return;


if (mc.player.collidedHorizontally && mc.gameSettings.keyBindJump.isPressed()) {
mc.player.jump();
return;
}


mc.player.jump();
mc.player.motion.y = 0.0;
}
}
и что ты хотел сказать
:fearscream:
 
Сверху Снизу