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

Вопрос Почему NameTag не работает 1.21.4?

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
25 Июн 2024
Сообщения
104
Реакции
1
/dell
 
Последнее редактирование:
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
ни крашлога, ни ошибок, я те че блять гадать должен почему они у тебя не работают?
 
NameTag:
Expand Collapse Copy
package dev.satofan.white.feature.modules.impl.render;

import com.google.common.base.Suppliers;
import dev.satofan.white.feature.modules.api.Category;
import dev.satofan.white.feature.modules.api.Module;
import dev.satofan.white.utils.builders.Builder;
import dev.satofan.white.utils.builders.states.QuadColorState;
import dev.satofan.white.utils.builders.states.QuadRadiusState;
import dev.satofan.white.utils.builders.states.SizeState;
import dev.satofan.white.utils.render.ProjectionUtil;
import dev.satofan.white.utils.render.msdf.MsdfFont;
import dev.satofan.white.utils.render.renderers.impl.BuiltBlur;
import dev.satofan.white.utils.render.renderers.impl.BuiltBorder;
import dev.satofan.white.utils.render.renderers.impl.BuiltRectangle;
import dev.satofan.white.utils.render.renderers.impl.BuiltText;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.joml.Matrix4f;
import org.joml.Vector4d;
import org.lwjgl.glfw.GLFW;

import java.awt.*;
import java.util.function.Supplier;

import static dev.satofan.white.utils.Inventory.IHolder.mc;

public class NameTag extends Module {
private static final Supplier<MsdfFont> BIKO_FONT = Suppliers.memoize(() -> MsdfFont.builder().atlas("biko").data("biko").build());

public NameTag() {
super("NameTag", Category.RENDER, "Отображает никнеймы над игроками", GLFW.GLFW_KEY_INSERT);
}

public void render(MatrixStack matrices) {
if (mc.player == null || mc.world == null || mc.options.hudHidden) return;
for (Entity entity : mc.world.getEntities()) {
if ((entity instanceof PlayerEntity || entity instanceof MobEntity)) {
if (entity.isInvisible()) continue;
if (mc.player.distanceTo(entity) > 50) continue;
if (entity == mc.player && mc.options.getPerspective().isFirstPerson()) continue;
renderNameTag(entity, matrices, mc.getRenderTickCounter().getTickDelta(true));
}
}
}


private void renderNameTag(Entity entity, MatrixStack drawContext, float partialTicks) {
double x = entity.prevX + (entity.getX() - entity.prevX) * partialTicks;
double y = entity.prevY + (entity.getY() - entity.prevY) * partialTicks;
double z = entity.prevZ + (entity.getZ() - entity.prevZ) * partialTicks;

Vec3d vector = new Vec3d(x, y + entity.getHeight() + 0.5, z);

Vector4d position = null;
Vec3d screenPos = ProjectionUtil.worldSpaceToScreenSpace(vector);
if (screenPos.z > 0 && screenPos.z < 1) {
position = new Vector4d(screenPos.x, screenPos.y, screenPos.z, 0);
}

if (position != null) {
double posX = position.x;
double posY = position.y;

Text name = entity.getName();
String displayName = name.getString();

//int textColor = entity instanceof PlayerEntity ? 0xFFFFFF : 0x00FF00;

assert mc.player != null;
float distance = mc.player.distanceTo(entity);
float maxDistance = 50f;
float minScale = 0.41f;
float maxScale = 0.96f;
float scale = MathHelper.clamp(1 - distance / maxDistance, minScale, maxScale);

float alpha = 210;

float baseFontSize = 12f;
float baseTextHeight = 16f;
float basePaddingX = 4f;
float basePaddingY = 2f;

float fontSize = baseFontSize * scale;
float textHeight = baseTextHeight * scale;
float paddingX = basePaddingX * scale;
float paddingY = basePaddingY * scale;

float textWidth = BIKO_FONT.get().getWidth(displayName, fontSize);

float backgroundWidth = textWidth + paddingX * 2 + 2f * scale;
float backgroundHeight = textHeight + paddingY * 2;

float tagX = (float) (posX - backgroundWidth / 2);
float tagY = (float) (posY - backgroundHeight - 2 + 23f * scale);

Matrix4f matrix = drawContext.peek().getPositionMatrix();

BuiltBlur backgroundBlur = Builder.blur()
.size(new SizeState(backgroundWidth, backgroundHeight))
.radius(new QuadRadiusState(5 * scale))
.blurRadius(9f)
.smoothness(1.2f)
.color(new QuadColorState(new Color(255, 255, 255, 255)))
.build();
backgroundBlur.render(matrix, tagX, tagY);

BuiltRectangle background = Builder.rectangle()
.size(new SizeState(backgroundWidth, backgroundHeight))
.color(new QuadColorState(new Color(15, 15, 18, (int) alpha - 30)))
.radius(new QuadRadiusState(5 * scale))
.smoothness(1f)
.build();
background.render(matrix, tagX, tagY);

BuiltBorder backgroundBorder = Builder.border()
.size(new SizeState(backgroundWidth, backgroundHeight))
.color(new QuadColorState(new Color(8, 8, 8, 105)))
.radius(new QuadRadiusState(5 * scale))
.thickness(0.03f)
.smoothness(1f, 1.2f)
.build();
backgroundBorder.render(matrix, tagX, tagY);

BuiltText nameText = Builder.text()
.font(BIKO_FONT.get())
.text(displayName)
.color(new Color(255,255,255,230))
.size(fontSize)
.thickness(0.01f)
.build();

float textX = (float) (posX - textWidth / 2 - scale);
float textY = (float) (posY - textHeight - 2 + paddingY + 20f * scale);
nameText.render(matrix, textX, textY);
}
}
}

GameRenderer.mixin:
Expand Collapse Copy
   @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z", opcode = Opcodes.GETFIELD, ordinal = 0), method = "renderWorld")
    public void render3D(RenderTickCounter tickCounter, CallbackInfo ci) {
        Camera camera = mc.gameRenderer.getCamera();

        MatrixStack matrixStack = new MatrixStack();
        matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
        matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0f));

        Matrix4f projMatrix = RenderSystem.getProjectionMatrix();
        Matrix4f modelMatrix = matrixStack.peek().getPositionMatrix();

        ProjectionUtil.lastProjMat.set(projMatrix);
        ProjectionUtil.lastModMat.set(modelMatrix);
        ProjectionUtil.lastWorldSpaceMatrix.set(modelMatrix);

        // Вызываем рендер неймтегов, если NameTag включен
        if (ModuleManager.isModuleEnabled("NameTag") && ModuleManager.getModuleByName("NameTag") instanceof NameTag nameTag) {
             nameTag.render(matrixStack);
        }
    }
ProjectionUtil:
Expand Collapse Copy
package dev.satofan.white.utils.render;

import net.minecraft.client.render.Camera;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.NotNull;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.joml.Vector4f;
import org.lwjgl.opengl.GL11;

import static dev.satofan.white.utils.Inventory.IHolder.mc;

public class ProjectionUtil {
    public static final Matrix4f lastProjMat = new Matrix4f();
    public static final Matrix4f lastModMat = new Matrix4f();
    public static final Matrix4f lastWorldSpaceMatrix = new Matrix4f();

    public static @NotNull Vec3d worldSpaceToScreenSpace(@NotNull Vec3d pos) {
        if (mc.getEntityRenderDispatcher().camera == null) {
            return new Vec3d(0, 0, -1);
        }

        Camera camera = mc.getEntityRenderDispatcher().camera;
        int displayHeight = mc.getWindow().getHeight();
        int[] viewport = new int[4];
        GL11.glGetIntegerv(GL11.GL_VIEWPORT, viewport);
        Vector3f target = new Vector3f();

        double deltaX = pos.x - camera.getPos().x;
        double deltaY = pos.y - camera.getPos().y;
        double deltaZ = pos.z - camera.getPos().z;

        Vector4f transformedCoordinates = new Vector4f((float) deltaX, (float) deltaY, (float) deltaZ, 1.0f);
        transformedCoordinates.mul(lastWorldSpaceMatrix);

        Matrix4f matrixProj = new Matrix4f(lastProjMat);
        Matrix4f matrixModel = new Matrix4f(lastModMat);
        matrixProj.mul(matrixModel).project(
                transformedCoordinates.x(),
                transformedCoordinates.y(),
                transformedCoordinates.z(),
                viewport,
                target
        );

        double scaleFactor = mc.getWindow().getScaleFactor();
        return new Vec3d(
                target.x / scaleFactor,
                (displayHeight - target.y) / scaleFactor,
                target.z
        );
    }
}
Чувак рендер нейм тегов в 3д пространстве? Это модно?
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
NameTag:
Expand Collapse Copy
package dev.satofan.white.feature.modules.impl.render;

import com.google.common.base.Suppliers;
import dev.satofan.white.feature.modules.api.Category;
import dev.satofan.white.feature.modules.api.Module;
import dev.satofan.white.utils.builders.Builder;
import dev.satofan.white.utils.builders.states.QuadColorState;
import dev.satofan.white.utils.builders.states.QuadRadiusState;
import dev.satofan.white.utils.builders.states.SizeState;
import dev.satofan.white.utils.render.ProjectionUtil;
import dev.satofan.white.utils.render.msdf.MsdfFont;
import dev.satofan.white.utils.render.renderers.impl.BuiltBlur;
import dev.satofan.white.utils.render.renderers.impl.BuiltBorder;
import dev.satofan.white.utils.render.renderers.impl.BuiltRectangle;
import dev.satofan.white.utils.render.renderers.impl.BuiltText;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.joml.Matrix4f;
import org.joml.Vector4d;
import org.lwjgl.glfw.GLFW;

import java.awt.*;
import java.util.function.Supplier;

import static dev.satofan.white.utils.Inventory.IHolder.mc;

public class NameTag extends Module {
private static final Supplier<MsdfFont> BIKO_FONT = Suppliers.memoize(() -> MsdfFont.builder().atlas("biko").data("biko").build());

public NameTag() {
super("NameTag", Category.RENDER, "Отображает никнеймы над игроками", GLFW.GLFW_KEY_INSERT);
}

public void render(MatrixStack matrices) {
if (mc.player == null || mc.world == null || mc.options.hudHidden) return;
for (Entity entity : mc.world.getEntities()) {
if ((entity instanceof PlayerEntity || entity instanceof MobEntity)) {
if (entity.isInvisible()) continue;
if (mc.player.distanceTo(entity) > 50) continue;
if (entity == mc.player && mc.options.getPerspective().isFirstPerson()) continue;
renderNameTag(entity, matrices, mc.getRenderTickCounter().getTickDelta(true));
}
}
}


private void renderNameTag(Entity entity, MatrixStack drawContext, float partialTicks) {
double x = entity.prevX + (entity.getX() - entity.prevX) * partialTicks;
double y = entity.prevY + (entity.getY() - entity.prevY) * partialTicks;
double z = entity.prevZ + (entity.getZ() - entity.prevZ) * partialTicks;

Vec3d vector = new Vec3d(x, y + entity.getHeight() + 0.5, z);

Vector4d position = null;
Vec3d screenPos = ProjectionUtil.worldSpaceToScreenSpace(vector);
if (screenPos.z > 0 && screenPos.z < 1) {
position = new Vector4d(screenPos.x, screenPos.y, screenPos.z, 0);
}

if (position != null) {
double posX = position.x;
double posY = position.y;

Text name = entity.getName();
String displayName = name.getString();

//int textColor = entity instanceof PlayerEntity ? 0xFFFFFF : 0x00FF00;

assert mc.player != null;
float distance = mc.player.distanceTo(entity);
float maxDistance = 50f;
float minScale = 0.41f;
float maxScale = 0.96f;
float scale = MathHelper.clamp(1 - distance / maxDistance, minScale, maxScale);

float alpha = 210;

float baseFontSize = 12f;
float baseTextHeight = 16f;
float basePaddingX = 4f;
float basePaddingY = 2f;

float fontSize = baseFontSize * scale;
float textHeight = baseTextHeight * scale;
float paddingX = basePaddingX * scale;
float paddingY = basePaddingY * scale;

float textWidth = BIKO_FONT.get().getWidth(displayName, fontSize);

float backgroundWidth = textWidth + paddingX * 2 + 2f * scale;
float backgroundHeight = textHeight + paddingY * 2;

float tagX = (float) (posX - backgroundWidth / 2);
float tagY = (float) (posY - backgroundHeight - 2 + 23f * scale);

Matrix4f matrix = drawContext.peek().getPositionMatrix();

BuiltBlur backgroundBlur = Builder.blur()
.size(new SizeState(backgroundWidth, backgroundHeight))
.radius(new QuadRadiusState(5 * scale))
.blurRadius(9f)
.smoothness(1.2f)
.color(new QuadColorState(new Color(255, 255, 255, 255)))
.build();
backgroundBlur.render(matrix, tagX, tagY);

BuiltRectangle background = Builder.rectangle()
.size(new SizeState(backgroundWidth, backgroundHeight))
.color(new QuadColorState(new Color(15, 15, 18, (int) alpha - 30)))
.radius(new QuadRadiusState(5 * scale))
.smoothness(1f)
.build();
background.render(matrix, tagX, tagY);

BuiltBorder backgroundBorder = Builder.border()
.size(new SizeState(backgroundWidth, backgroundHeight))
.color(new QuadColorState(new Color(8, 8, 8, 105)))
.radius(new QuadRadiusState(5 * scale))
.thickness(0.03f)
.smoothness(1f, 1.2f)
.build();
backgroundBorder.render(matrix, tagX, tagY);

BuiltText nameText = Builder.text()
.font(BIKO_FONT.get())
.text(displayName)
.color(new Color(255,255,255,230))
.size(fontSize)
.thickness(0.01f)
.build();

float textX = (float) (posX - textWidth / 2 - scale);
float textY = (float) (posY - textHeight - 2 + paddingY + 20f * scale);
nameText.render(matrix, textX, textY);
}
}
}

GameRenderer.mixin:
Expand Collapse Copy
   @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z", opcode = Opcodes.GETFIELD, ordinal = 0), method = "renderWorld")
    public void render3D(RenderTickCounter tickCounter, CallbackInfo ci) {
        Camera camera = mc.gameRenderer.getCamera();

        MatrixStack matrixStack = new MatrixStack();
        matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
        matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0f));

        Matrix4f projMatrix = RenderSystem.getProjectionMatrix();
        Matrix4f modelMatrix = matrixStack.peek().getPositionMatrix();

        ProjectionUtil.lastProjMat.set(projMatrix);
        ProjectionUtil.lastModMat.set(modelMatrix);
        ProjectionUtil.lastWorldSpaceMatrix.set(modelMatrix);

        // Вызываем рендер неймтегов, если NameTag включен
        if (ModuleManager.isModuleEnabled("NameTag") && ModuleManager.getModuleByName("NameTag") instanceof NameTag nameTag) {
             nameTag.render(matrixStack);
        }
    }
ProjectionUtil:
Expand Collapse Copy
package dev.satofan.white.utils.render;

import net.minecraft.client.render.Camera;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.NotNull;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.joml.Vector4f;
import org.lwjgl.opengl.GL11;

import static dev.satofan.white.utils.Inventory.IHolder.mc;

public class ProjectionUtil {
    public static final Matrix4f lastProjMat = new Matrix4f();
    public static final Matrix4f lastModMat = new Matrix4f();
    public static final Matrix4f lastWorldSpaceMatrix = new Matrix4f();

    public static @NotNull Vec3d worldSpaceToScreenSpace(@NotNull Vec3d pos) {
        if (mc.getEntityRenderDispatcher().camera == null) {
            return new Vec3d(0, 0, -1);
        }

        Camera camera = mc.getEntityRenderDispatcher().camera;
        int displayHeight = mc.getWindow().getHeight();
        int[] viewport = new int[4];
        GL11.glGetIntegerv(GL11.GL_VIEWPORT, viewport);
        Vector3f target = new Vector3f();

        double deltaX = pos.x - camera.getPos().x;
        double deltaY = pos.y - camera.getPos().y;
        double deltaZ = pos.z - camera.getPos().z;

        Vector4f transformedCoordinates = new Vector4f((float) deltaX, (float) deltaY, (float) deltaZ, 1.0f);
        transformedCoordinates.mul(lastWorldSpaceMatrix);

        Matrix4f matrixProj = new Matrix4f(lastProjMat);
        Matrix4f matrixModel = new Matrix4f(lastModMat);
        matrixProj.mul(matrixModel).project(
                transformedCoordinates.x(),
                transformedCoordinates.y(),
                transformedCoordinates.z(),
                viewport,
                target
        );

        double scaleFactor = mc.getWindow().getScaleFactor();
        return new Vec3d(
                target.x / scaleFactor,
                (displayHeight - target.y) / scaleFactor,
                target.z
        );
    }
}
Ошибка в миксине, просто создай ивент рендер 3д который я тебе завтра отправлю (или можешь сделать сам, там DrawContext нужен) и просто через ивент бас писать TvoyClient.getEventBus().post(new EventRender2DWorld либо event). А потом поставь над рендер Субскрайб и в скобки с названием метода напиши EventRender2dWorld eventRender2dWorld и все и оттуда гетай просто матрицы
 
ни крашлога, ни ошибок, я те че блять гадать должен почему они у тебя не работают?
Нету ничего, просто не рендерит
Ошибка в миксине, просто создай ивент рендер 3д который я тебе завтра отправлю (или можешь сделать сам, там DrawContext нужен) и просто через ивент бас писать TvoyClient.getEventBus().post(new EventRender2DWorld либо event). А потом поставь над рендер Субскрайб и в скобки с названием метода напиши EventRender2dWorld eventRender2dWorld и все и оттуда гетай просто матрицы
Окей
 
такая же хрень я на версии 1.21.1
 
Блять ебать вы типы, сидеть на своей базе нахуя? если вы даже неймтеги не осилили.Просто блять понять как работает матрица, неее не мое писать на югейм ыыыыы почему не работает
Если тебе уже так надо спасти с моей базы которую я сливал
 
Назад
Сверху Снизу