твоя задача переписать esp полоску хп перенеси на ...

Erstellt am: 16. Februar 2025

Beantwortet mit O1 von Chat01

Frage

твоя задача переписать esp полоску хп перенеси на правую сторону и пиши сразу весь код package cc.alwayswin.modules.impl.visuals;

import cc.alwayswin.AlwaysWin;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import cc.alwayswin.command.friends.FriendStorage;
import cc.alwayswin.events.EventDisplay;
import cc.alwayswin.modules.api.Category;
import cc.alwayswin.modules.api.Module;
import cc.alwayswin.modules.api.ModuleRegister;
import cc.alwayswin.modules.impl.combat.AntiBot;
import cc.alwayswin.modules.settings.impl.BooleanSetting;
import cc.alwayswin.modules.settings.impl.ModeListSetting;
import cc.alwayswin.utils.math.MathUtil;
import cc.alwayswin.utils.math.Vector4i;
import cc.alwayswin.utils.projections.ProjectionUtil;
import cc.alwayswin.utils.render.ColorUtils;
import cc.alwayswin.utils.render.DisplayUtils;
import cc.alwayswin.utils.render.font.Fonts;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.PointOfView;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.EffectUtils;
import net.minecraft.scoreboard.Score;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector4f;
import net.minecraft.util.text.*;
import org.lwjgl.opengl.GL11;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static net.minecraft.client.renderer.WorldRenderer.frustum;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef;

@ModuleRegister(name = "ESP", type = Category.Visuals)
public class ESP extends Module {

text
public ModeListSetting remove = new ModeListSetting("Убрать", new BooleanSetting("Боксы", false), new BooleanSetting("Полоску хп", false), new BooleanSetting("Текст хп", false), new BooleanSetting("Зачарования", true), new BooleanSetting("Список эффектов", false) ); public ESP() { addSettings(remove); } private final HashMap<Entity, Vector4f> positions = new HashMap<>(); @Subscribe public void onDisplay(EventDisplay e) { if (mc.world == null || e.getType() != EventDisplay.Type.PRE) { return; } positions.clear(); Vector4i colors = new Vector4i(HUD.getColor(0, 1), HUD.getColor(90, 1), HUD.getColor(180, 1), HUD.getColor(270, 1)); Vector4i friendColors = new Vector4i(HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 0, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 90, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 180, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 270, 1)); boolean box = remove.getValueByName("Боксы").get(); boolean healthLine = remove.getValueByName("Полоску хп").get(); boolean healthText = remove.getValueByName("Текст хп").get(); boolean pots = remove.getValueByName("Список эффектов").get(); for (Entity entity : mc.world.getAllEntities()) { if (!isValid(entity)) continue; if (AntiBot.isBot(entity)) continue; if (!(entity instanceof PlayerEntity || entity instanceof ItemEntity)) continue; if (entity == mc.player && (mc.gameSettings.getPointOfView() == PointOfView.FIRST_PERSON)) continue; double x = MathUtil.interpolate(entity.getPosX(), entity.lastTickPosX, e.getPartialTicks()); double y = MathUtil.interpolate(entity.getPosY(), entity.lastTickPosY, e.getPartialTicks()); double z = MathUtil.interpolate(entity.getPosZ(), entity.lastTickPosZ, e.getPartialTicks()); Vector3d size = new Vector3d(entity.getBoundingBox().maxX - entity.getBoundingBox().minX, entity.getBoundingBox().maxY - entity.getBoundingBox().minY, entity.getBoundingBox().maxZ - entity.getBoundingBox().minZ); AxisAlignedBB aabb = new AxisAlignedBB(x - size.x / 2f, y, z - size.z / 2f, x + size.x / 2f, y + size.y, z + size.z / 2f); Vector4f position = null; for (int i = 0; i < 8; i++) { Vector2f vector = ProjectionUtil.project(i % 2 == 0 ? aabb.minX : aabb.maxX, (i / 2) % 2 == 0 ? aabb.minY : aabb.maxY, (i / 4) % 2 == 0 ? aabb.minZ : aabb.maxZ); if (position == null) { position = new Vector4f(vector.x, vector.y, 1, 1.0f); } else { position.x = Math.min(vector.x, position.x); position.y = Math.min(vector.y, position.y); position.z = Math.max(vector.x, position.z); position.w = Math.max(vector.y, position.w); } } positions.put(entity, position); } RenderSystem.enableBlend(); RenderSystem.disableTexture(); RenderSystem.defaultBlendFunc(); RenderSystem.shadeModel(7425); buffer.begin(7, DefaultVertexFormats.POSITION_COLOR); for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Vector4f position = entry.getValue(); if (entry.getKey() instanceof LivingEntity entity) { if (!box) { DisplayUtils.drawBox(position.x - 0.5f, position.y - 0.5f, position.z + 0.5f, position.w + 0.5f, 2, ColorUtils.rgba(0, 0, 0, 128)); DisplayUtils.drawBoxTest(position.x, position.y, position.z, position.w, 1, FriendStorage.isFriend(entity.getName().getString()) ? friendColors : colors); } float hpOffset = 3f; float out = 0.5f; if (!healthLine) { String header = mc.ingameGUI.getTabList().header == null ? " " : mc.ingameGUI.getTabList().header.getString().toLowerCase(); DisplayUtils.drawRectBuilding(position.x - hpOffset - out, position.y - out, position.x - hpOffset + 1 + out, position.w + out, ColorUtils.rgba(0, 0, 0, 128)); DisplayUtils.drawRectBuilding(position.x - hpOffset, position.y, position.x - hpOffset + 1, position.w, ColorUtils.rgba(0, 0, 0, 128)); float entityHealth = fix1000Health(entity, entity.getHealth()); DisplayUtils.drawMCVerticalBuilding(position.x - hpOffset, position.y + (position.w - position.y) * (1 - MathHelper.clamp(entityHealth / entity.getMaxHealth(), 0, 1)), position.x - hpOffset + 1, position.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.w : colors.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.x : colors.x); } } } Tessellator.getInstance().draw(); RenderSystem.shadeModel(7424); RenderSystem.enableTexture(); RenderSystem.disableBlend(); for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Entity entity = entry.getKey(); if (entity instanceof LivingEntity living) { float health = fix1000Health(living, living.getHealth()); Vector4f position = entry.getValue(); float width = position.z - position.x; String hpText = (int) health + "HP"; float hpWidth = Fonts.consolas.getWidth(hpText, 6); float hpPercent = MathHelper.clamp(health / living.getMaxHealth(), 0, 1); float hpPosY = position.y + (position.w - position.y) * (1 - hpPercent); if (!healthText) { Fonts.consolas.drawText(e.getMatrixStack(), hpText, position.x - hpWidth - 6, hpPosY, -1, 6, 0.05f); } float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); String friendPrefix = FriendStorage.isFriend(entity.getName().getString()) ? TextFormatting.GREEN + "[F] " : ""; TextComponent name = (TextComponent) ITextComponent.getTextComponentOrEmpty(friendPrefix); if ((AlwaysWin.getInstance().getFunctionRegistry().getNameProtect().isState())) { if (FriendStorage.isFriend(entity.getName().getString())) { name.append(new StringTextComponent(TextFormatting.RED + "protected")); } else { name.append(entity.getDisplayName()); } } else { name.append(entity.getDisplayName()); } mc.fontRenderer.func_243246_a(e.getMatrixStack(), name, position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); if (!pots) { drawPotions(e.getMatrixStack(), living, position.z + 2, position.y); } drawItems(e.getMatrixStack(), living, (int) (position.x + width / 2f), (int) (position.y - 20)); } else if (entity instanceof ItemEntity item) { Vector4f position = entry.getValue(); float width = position.z - position.x; float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); mc.fontRenderer.func_243246_a(e.getMatrixStack(), entity.getDisplayName(), position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); } } } private float fix1000Health(Entity entity, float original) { Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2)); return userConnectedToFunTimeAndEntityIsPlayer(entity) ? score.getScorePoints() : original; } private boolean userConnectedToFunTimeAndEntityIsPlayer(Entity entity) { String header = mc.ingameGUI.getTabList().header == null ? " " : mc.ingameGUI.getTabList().header.getString().toLowerCase(); return (mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP.contains("funtime") && (header.contains("анархия") || header.contains("гриферский")) && entity instanceof PlayerEntity); } public boolean isInView(Entity ent) { if (mc.getRenderViewEntity() == null) { return false; } frustum.setCameraPosition(mc.getRenderManager().info.getProjectedView().x, mc.getRenderManager().info.getProjectedView().y, mc.getRenderManager().info.getProjectedView().z); return frustum.isBoundingBoxInFrustum(ent.getBoundingBox()) || ent.ignoreFrustumCheck; } private void drawPotions(MatrixStack matrixStack, LivingEntity entity, float posX, float posY) { for (EffectInstance pot : entity.getActivePotionEffects()) { int amp = pot.getAmplifier(); String ampStr = ""; if (amp >= 1 && amp <= 9) { ampStr = " " + I18n.format("enchantment.level." + (amp + 1)); } String text = I18n.format(pot.getEffectName()) + ampStr + " - " + EffectUtils.getPotionDurationString(pot, 1); Fonts.consolas.drawText(matrixStack, text, posX, posY, -1, 6, 0.05f); posY += Fonts.consolas.getHeight(6); } } private void drawItems(MatrixStack matrixStack, LivingEntity entity, int posX, int posY) { int size = 8; int padding = 6; float fontHeight = Fonts.consolas.getHeight(6); List<ItemStack> items = new ArrayList<>(); ItemStack mainStack = entity.getHeldItemMainhand(); if (!mainStack.isEmpty()) { items.add(mainStack); } for (ItemStack itemStack : entity.getArmorInventoryList()) { if (itemStack.isEmpty()) continue; items.add(itemStack); } ItemStack offStack = entity.getHeldItemOffhand(); if (!offStack.isEmpty()) { items.add(offStack); } posX -= (items.size() * (size + padding)) / 2f; for (ItemStack itemStack : items) { if (itemStack.isEmpty()) continue; GL11.glPushMatrix(); glCenteredScale(posX, posY, size / 2f, size / 2f, 0.5f); mc.getItemRenderer().renderItemAndEffectIntoGUI(itemStack, posX, posY); mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, posX, posY, null); GL11.glPopMatrix(); if (itemStack.isEnchanted() && !remove.getValueByName("Зачарования").get()) { int ePosY = (int) (posY - fontHeight); Map<Enchantment, Integer> enchantmentsMap = EnchantmentHelper.getEnchantments(itemStack); for (Enchantment enchantment : enchantmentsMap.keySet()) { int level = enchantmentsMap.get(enchantment); if (level < 1 || !enchantment.canApply(itemStack)) continue; IFormattableTextComponent iformattabletextcomponent = new TranslationTextComponent(enchantment.getName()); String enchText = iformattabletextcomponent.getString().substring(0, 2) + level; Fonts.consolas.drawText(matrixStack, enchText, posX, ePosY, -1, 6, 0.05f); ePosY -= (int) fontHeight; } } posX += size + padding; } } public boolean isValid(Entity e) { return isInView(e); } public void glCenteredScale(final float x, final float y, final float w, final float h, final float f) { glTranslatef(x + w / 2, y + h / 2, 0); glScalef(f, f, 1); glTranslatef(-x - w / 2, -y - h / 2, 0); }

}

Gedanke

Noticing progress

I'm thinking about how the user wants the ESP module's HP bar to shift to the right side. The main code involves Java, with a snippet indicating a single line condition. I'm preparing to replicate this in Russian.

Revisiting the HP bar

I'm shifting the HP bar drawing logic from the left to the right side, focusing on positions and color handling. Adjusting offsets ensures the bar aligns correctly with the new layout.

Mapping the HP bar

OK, let me see. I’m detailing how to position the HP bar on the right side, using the bounding box width and a small offset to ensure it aligns correctly with the new layout.

Rendering the HP bar

I’m setting the HP bar position on the right side, using a slight offset from the bounding box edge, and adapting the drawing logic to this new approach.

Repositioning HP text

I'm piecing together how to shift the HP text to the right side, setting a slight horizontal offset and ensuring it aligns with the corresponding HP bar.

Aligning the layout

I’m working through the HP bar and text position on the right side, setting offsets and ensuring the text aligns with the bar, enhancing consistency across the UI layout.

Translating and adjusting

I'm translating the ESP HP bar code to Russian and placing it on the right. The process involves refining the HP bar logic and rearranging the code layout.

Repositioning elements

OK, let's think it through: shifting the entire HP bar and its text to the right side, preserving the original code structure, and tweaking some variables for better alignment.

Repositioning and improving

OK, let me see: shifting the HP bar and text to the right, tweaking variables like hpOffset and out for alignment, and updating the drawing logic to enhance usability and accuracy.

Reasoned for 19 seconds

Antwort

Ниже приведён полный код класса ESP, в котором полоска здоровья (HP) перенесена с левой стороны на правую. Обратите внимание, что изменился только участок с отрисовкой полоски и текста хп:

java
package cc.alwayswin.modules.impl.visuals; import cc.alwayswin.AlwaysWin; import com.google.common.eventbus.Subscribe; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import cc.alwayswin.command.friends.FriendStorage; import cc.alwayswin.events.EventDisplay; import cc.alwayswin.modules.api.Category; import cc.alwayswin.modules.api.Module; import cc.alwayswin.modules.api.ModuleRegister; import cc.alwayswin.modules.impl.combat.AntiBot; import cc.alwayswin.modules.settings.impl.BooleanSetting; import cc.alwayswin.modules.settings.impl.ModeListSetting; import cc.alwayswin.utils.math.MathUtil; import cc.alwayswin.utils.math.Vector4i; import cc.alwayswin.utils.projections.ProjectionUtil; import cc.alwayswin.utils.render.ColorUtils; import cc.alwayswin.utils.render.DisplayUtils; import cc.alwayswin.utils.render.font.Fonts; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.PointOfView; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectUtils; import net.minecraft.scoreboard.Score; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector2f; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector4f; import net.minecraft.util.text.*; import org.lwjgl.opengl.GL11; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static net.minecraft.client.renderer.WorldRenderer.frustum; import static org.lwjgl.opengl.GL11.glScalef; import static org.lwjgl.opengl.GL11.glTranslatef; @ModuleRegister(name = "ESP", type = Category.Visuals) public class ESP extends Module { public ModeListSetting remove = new ModeListSetting("Убрать", new BooleanSetting("Боксы", false), new BooleanSetting("Полоску хп", false), new BooleanSetting("Текст хп", false), new BooleanSetting("Зачарования", true), new BooleanSetting("Список эффектов", false) ); public ESP() { addSettings(remove); } private final HashMap<Entity, Vector4f> positions = new HashMap<>(); @Subscribe public void onDisplay(EventDisplay e) { if (mc.world == null || e.getType() != EventDisplay.Type.PRE) { return; } positions.clear(); Vector4i colors = new Vector4i(HUD.getColor(0, 1), HUD.getColor(90, 1), HUD.getColor(180, 1), HUD.getColor(270, 1)); Vector4i friendColors = new Vector4i( HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 0, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 90, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 180, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 270, 1) ); boolean box = remove.getValueByName("Боксы").get(); boolean healthLine = remove.getValueByName("Полоску хп").get(); boolean healthText = remove.getValueByName("Текст хп").get(); boolean pots = remove.getValueByName("Список эффектов").get(); for (Entity entity : mc.world.getAllEntities()) { if (!isValid(entity)) continue; if (AntiBot.isBot(entity)) continue; if (!(entity instanceof PlayerEntity || entity instanceof ItemEntity)) continue; if (entity == mc.player && (mc.gameSettings.getPointOfView() == PointOfView.FIRST_PERSON)) continue; double x = MathUtil.interpolate(entity.getPosX(), entity.lastTickPosX, e.getPartialTicks()); double y = MathUtil.interpolate(entity.getPosY(), entity.lastTickPosY, e.getPartialTicks()); double z = MathUtil.interpolate(entity.getPosZ(), entity.lastTickPosZ, e.getPartialTicks()); Vector3d size = new Vector3d( entity.getBoundingBox().maxX - entity.getBoundingBox().minX, entity.getBoundingBox().maxY - entity.getBoundingBox().minY, entity.getBoundingBox().maxZ - entity.getBoundingBox().minZ ); AxisAlignedBB aabb = new AxisAlignedBB( x - size.x / 2f, y, z - size.z / 2f, x + size.x / 2f, y + size.y, z + size.z / 2f ); Vector4f position = null; for (int i = 0; i < 8; i++) { Vector2f vector = ProjectionUtil.project( i % 2 == 0 ? aabb.minX : aabb.maxX, (i / 2) % 2 == 0 ? aabb.minY : aabb.maxY, (i / 4) % 2 == 0 ? aabb.minZ : aabb.maxZ ); if (position == null) { position = new Vector4f(vector.x, vector.y, 1, 1.0f); } else { position.x = Math.min(vector.x, position.x); position.y = Math.min(vector.y, position.y); position.z = Math.max(vector.x, position.z); position.w = Math.max(vector.y, position.w); } } positions.put(entity, position); } RenderSystem.enableBlend(); RenderSystem.disableTexture(); RenderSystem.defaultBlendFunc(); RenderSystem.shadeModel(GL11.GL_SMOOTH); buffer.begin(7, DefaultVertexFormats.POSITION_COLOR); for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Vector4f position = entry.getValue(); if (entry.getKey() instanceof LivingEntity entity) { if (!box) { DisplayUtils.drawBox(position.x - 0.5f, position.y - 0.5f, position.z + 0.5f, position.w + 0.5f, 2, ColorUtils.rgba(0, 0, 0, 128)); DisplayUtils.drawBoxTest(position.x, position.y, position.z, position.w, 1, FriendStorage.isFriend(entity.getName().getString()) ? friendColors : colors); } // --- Изменённый участок: перенос полоски хп на правую сторону --- if (!healthLine) { float hpOffset = 3f; float out = 0.5f; // Задний прямоугольник (чуть шире, чтобы была обводка) DisplayUtils.drawRectBuilding( position.z + hpOffset - out, position.y - out, position.z + hpOffset + 1 + out, position.w + out, ColorUtils.rgba(0, 0, 0, 128) ); // Тонкая чёрная линия под полоской хп DisplayUtils.drawRectBuilding( position.z + hpOffset, position.y, position.z + hpOffset + 1, position.w, ColorUtils.rgba(0, 0, 0, 128) ); // Расчёт текущего хп float entityHealth = fix1000Health(entity, entity.getHealth()); // Закрашиваем часть полоски снизу вверх DisplayUtils.drawMCVerticalBuilding( position.z + hpOffset, position.y + (position.w - position.y) * (1 - MathHelper.clamp(entityHealth / entity.getMaxHealth(), 0, 1)), position.z + hpOffset + 1, position.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.w : colors.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.x : colors.x ); } } } Tessellator.getInstance().draw(); RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.enableTexture(); RenderSystem.disableBlend(); // Отрисовка текста, эффектов и предметов for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Entity entity = entry.getKey(); if (entity instanceof LivingEntity living) { Vector4f position = entry.getValue(); float health = fix1000Health(living, living.getHealth()); float width = position.z - position.x; // --- Изменённый участок: текст хп также справа --- String hpText = (int) health + "HP"; float hpWidth = Fonts.consolas.getWidth(hpText, 6); float hpPercent = MathHelper.clamp(health / living.getMaxHealth(), 0, 1); float hpPosY = position.y + (position.w - position.y) * (1 - hpPercent); // Если галочка "Текст хп" НЕ стоит, рисуем текст if (!remove.getValueByName("Текст хп").get()) { // Ставим текст чуть правее самой полоски float hpOffset = 3f; Fonts.consolas.drawText( e.getMatrixStack(), hpText, position.z + hpOffset + 3, // смещение вправо hpPosY, -1, 6, 0.05f ); } // Отрисовка имени над головой float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); String friendPrefix = FriendStorage.isFriend(entity.getName().getString()) ? TextFormatting.GREEN + "[F] " : ""; TextComponent name = (TextComponent) ITextComponent.getTextComponentOrEmpty(friendPrefix); if ((AlwaysWin.getInstance().getFunctionRegistry().getNameProtect().isState())) { if (FriendStorage.isFriend(entity.getName().getString())) { name.append(new StringTextComponent(TextFormatting.RED + "protected")); } else { name.append(entity.getDisplayName()); } } else { name.append(entity.getDisplayName()); } mc.fontRenderer.func_243246_a(e.getMatrixStack(), name, position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); // Отрисовка эффектов (зелья) if (!remove.getValueByName("Список эффектов").get()) { drawPotions(e.getMatrixStack(), living, position.z + 2, position.y); } // Отрисовка предметов (броня, оружие) drawItems(e.getMatrixStack(), living, (int) (position.x + width / 2f), (int) (position.y - 20)); } else if (entity instanceof ItemEntity) { Vector4f position = entry.getValue(); float width = position.z - position.x; float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); mc.fontRenderer.func_243246_a(e.getMatrixStack(), entity.getDisplayName(), position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); } } } private float fix1000Health(Entity entity, float original) { Score score = mc.world.getScoreboard().getOrCreateScore( entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2) ); return userConnectedToFunTimeAndEntityIsPlayer(entity) ? score.getScorePoints() : original; } private boolean userConnectedToFunTimeAndEntityIsPlayer(Entity entity) { String header = mc.ingameGUI.getTabList().header == null ? " " : mc.ingameGUI.getTabList().header.getString().toLowerCase(); return (mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP.contains("funtime") && (header.contains("анархия") || header.contains("гриферский")) && entity instanceof PlayerEntity); } public boolean isInView(Entity ent) { if (mc.getRenderViewEntity() == null) { return false; } frustum.setCameraPosition( mc.getRenderManager().info.getProjectedView().x, mc.getRenderManager().info.getProjectedView().y, mc.getRenderManager().info.getProjectedView().z ); return frustum.isBoundingBoxInFrustum(ent.getBoundingBox()) || ent.ignoreFrustumCheck; } private void drawPotions(MatrixStack matrixStack, LivingEntity entity, float posX, float posY) { for (EffectInstance pot : entity.getActivePotionEffects()) { int amp = pot.getAmplifier(); String ampStr = ""; if (amp >= 1 && amp <= 9) { ampStr = " " + I18n.format("enchantment.level." + (amp + 1)); } String text = I18n.format(pot.getEffectName()) + ampStr + " - " + EffectUtils.getPotionDurationString(pot, 1); Fonts.consolas.drawText(matrixStack, text, posX, posY, -1, 6, 0.05f); posY += Fonts.consolas.getHeight(6); } } private void drawItems(MatrixStack matrixStack, LivingEntity entity, int posX, int posY) { int size = 8; int padding = 6; float fontHeight = Fonts.consolas.getHeight(6); List<ItemStack> items = new ArrayList<>(); ItemStack mainStack = entity.getHeldItemMainhand(); if (!mainStack.isEmpty()) { items.add(mainStack); } for (ItemStack itemStack : entity.getArmorInventoryList()) { if (!itemStack.isEmpty()) { items.add(itemStack); } } ItemStack offStack = entity.getHeldItemOffhand(); if (!offStack.isEmpty()) { items.add(offStack); } // Центрируем иконки posX -= (items.size() * (size + padding)) / 2f; for (ItemStack itemStack : items) { if (itemStack.isEmpty()) continue; GL11.glPushMatrix(); glCenteredScale(posX, posY, size / 2f, size / 2f, 0.5f); mc.getItemRenderer().renderItemAndEffectIntoGUI(itemStack, posX, posY); mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, posX, posY, null); GL11.glPopMatrix(); // Отрисовка зачарований, если нужно if (itemStack.isEnchanted() && !remove.getValueByName("Зачарования").get()) { int ePosY = (int) (posY - fontHeight); Map<Enchantment, Integer> enchantmentsMap = EnchantmentHelper.getEnchantments(itemStack); for (Enchantment enchantment : enchantmentsMap.keySet()) { int level = enchantmentsMap.get(enchantment); if (level < 1 || !enchantment.canApply(itemStack)) continue; IFormattableTextComponent enchantText = new TranslationTextComponent(enchantment.getName()); String enchText = enchantText.getString().substring(0, 2) + level; Fonts.consolas.drawText(matrixStack, enchText, posX, ePosY, -1, 6, 0.05f); ePosY -= (int) fontHeight; } } posX += size + padding; } } public boolean isValid(Entity e) { return isInView(e); } public void glCenteredScale(final float x, final float y, final float w, final float h, final float f) { glTranslatef(x + w / 2, y + h / 2, 0); glScalef(f, f, 1); glTranslatef(-x - w / 2, -y - h / 2, 0); } }

Основные изменения были внесены в две части:

  1. Перенос самой полоски хп – блок внутри if (!healthLine) { ... } теперь рисует её в районе position.z + hpOffset (вместо position.x - hpOffset).

  2. Перенос текста хп – вывод строки (int) health + "HP" теперь также смещён вправо, рядом с полоской.

Все остальные части кода остались без изменений.

Frage

я значения поменял следующая задача довольна сложная package cc.alwayswin.modules.impl.visuals;

import cc.alwayswin.AlwaysWin;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import cc.alwayswin.command.friends.FriendStorage;
import cc.alwayswin.events.EventDisplay;
import cc.alwayswin.modules.api.Category;
import cc.alwayswin.modules.api.Module;
import cc.alwayswin.modules.api.ModuleRegister;
import cc.alwayswin.modules.impl.combat.AntiBot;
import cc.alwayswin.modules.settings.impl.BooleanSetting;
import cc.alwayswin.modules.settings.impl.ModeListSetting;
import cc.alwayswin.utils.math.MathUtil;
import cc.alwayswin.utils.math.Vector4i;
import cc.alwayswin.utils.projections.ProjectionUtil;
import cc.alwayswin.utils.render.ColorUtils;
import cc.alwayswin.utils.render.DisplayUtils;
import cc.alwayswin.utils.render.font.Fonts;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.PointOfView;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.EffectUtils;
import net.minecraft.scoreboard.Score;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector4f;
import net.minecraft.util.text.*;
import org.lwjgl.opengl.GL11;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static net.minecraft.client.renderer.WorldRenderer.frustum;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef;

@ModuleRegister(name = "ESP", type = Category.Visuals)
public class ESP extends Module {

text
public ModeListSetting remove = new ModeListSetting("Убрать", new BooleanSetting("Боксы", false), new BooleanSetting("Полоску хп", false), new BooleanSetting("Текст хп", false), new BooleanSetting("Зачарования", true), new BooleanSetting("Список эффектов", false) ); public ESP() { addSettings(remove); } private final HashMap<Entity, Vector4f> positions = new HashMap<>(); @Subscribe public void onDisplay(EventDisplay e) { if (mc.world == null || e.getType() != EventDisplay.Type.PRE) { return; } positions.clear(); Vector4i colors = new Vector4i(HUD.getColor(0, 1), HUD.getColor(90, 1), HUD.getColor(180, 1), HUD.getColor(270, 1)); Vector4i friendColors = new Vector4i( HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 0, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 90, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 180, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 270, 1) ); boolean box = remove.getValueByName("Боксы").get(); boolean healthLine = remove.getValueByName("Полоску хп").get(); boolean healthText = remove.getValueByName("Текст хп").get(); boolean pots = remove.getValueByName("Список эффектов").get(); for (Entity entity : mc.world.getAllEntities()) { if (!isValid(entity)) continue; if (AntiBot.isBot(entity)) continue; if (!(entity instanceof PlayerEntity || entity instanceof ItemEntity)) continue; if (entity == mc.player && (mc.gameSettings.getPointOfView() == PointOfView.FIRST_PERSON)) continue; double x = MathUtil.interpolate(entity.getPosX(), entity.lastTickPosX, e.getPartialTicks()); double y = MathUtil.interpolate(entity.getPosY(), entity.lastTickPosY, e.getPartialTicks()); double z = MathUtil.interpolate(entity.getPosZ(), entity.lastTickPosZ, e.getPartialTicks()); Vector3d size = new Vector3d( entity.getBoundingBox().maxX - entity.getBoundingBox().minX, entity.getBoundingBox().maxY - entity.getBoundingBox().minY, entity.getBoundingBox().maxZ - entity.getBoundingBox().minZ ); AxisAlignedBB aabb = new AxisAlignedBB( x - size.x / 2f, y, z - size.z / 2f, x + size.x / 2f, y + size.y, z + size.z / 2f ); Vector4f position = null; for (int i = 0; i < 8; i++) { Vector2f vector = ProjectionUtil.project( i % 2 == 0 ? aabb.minX : aabb.maxX, (i / 2) % 2 == 0 ? aabb.minY : aabb.maxY, (i / 4) % 2 == 0 ? aabb.minZ : aabb.maxZ ); if (position == null) { position = new Vector4f(vector.x, vector.y, 1, 1.0f); } else { position.x = Math.min(vector.x, position.x); position.y = Math.min(vector.y, position.y); position.z = Math.max(vector.x, position.z); position.w = Math.max(vector.y, position.w); } } positions.put(entity, position); } RenderSystem.enableBlend(); RenderSystem.disableTexture(); RenderSystem.defaultBlendFunc(); RenderSystem.shadeModel(GL11.GL_SMOOTH); buffer.begin(7, DefaultVertexFormats.POSITION_COLOR); for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Vector4f position = entry.getValue(); if (entry.getKey() instanceof LivingEntity entity) { if (!box) { DisplayUtils.drawBox(position.x - 0.5f, position.y - 0.5f, position.z + 0.5f, position.w + 0.5f, 2, ColorUtils.rgba(0, 0, 0, 128)); DisplayUtils.drawBoxTest(position.x, position.y, position.z, position.w, 1, FriendStorage.isFriend(entity.getName().getString()) ? friendColors : colors); } // --- Изменённый участок: перенос полоски хп на правую сторону --- if (!healthLine) { float hpOffset = 3f; float out = 0.5f; // Задний прямоугольник (чуть шире, чтобы была обводка) DisplayUtils.drawRectBuilding( position.z + hpOffset - out, position.y - out, position.z + hpOffset + 1 + out, position.w + out, ColorUtils.rgba(0, 0, 0, 128) ); // Тонкая чёрная линия под полоской хп DisplayUtils.drawRectBuilding( position.z + hpOffset, position.y, position.z + hpOffset + 1, position.w, ColorUtils.rgba(0, 0, 0, 128) ); // Расчёт текущего хп float entityHealth = fix1000Health(entity, entity.getHealth()); // Закрашиваем часть полоски снизу вверх DisplayUtils.drawMCVerticalBuilding( position.z + hpOffset, position.y + (position.w - position.y) * (1 - MathHelper.clamp(entityHealth / entity.getMaxHealth(), 0, 1)), position.z + hpOffset + 1, position.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.w : colors.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.x : colors.x ); } } } Tessellator.getInstance().draw(); RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.enableTexture(); RenderSystem.disableBlend(); // Отрисовка текста, эффектов и предметов for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Entity entity = entry.getKey(); if (entity instanceof LivingEntity living) { Vector4f position = entry.getValue(); float health = fix1000Health(living, living.getHealth()); float width = position.z - position.x; // --- Изменённый участок: текст хп также справа --- String hpText = (int) health + ""; float hpWidth = Fonts.sfMedium.getWidth(hpText, 6); float hpPercent = MathHelper.clamp(health / living.getMaxHealth(), 0, 1); float hpPosY = position.y + (position.w - position.y) * (1 - hpPercent); // Если галочка "Текст хп" НЕ стоит, рисуем текст if (!remove.getValueByName("Текст хп").get()) { // Ставим текст чуть правее самой полоски float hpOffset = 3f; Fonts.sfMedium.drawText( e.getMatrixStack(), hpText, position.z + hpOffset + 3, // смещение вправо hpPosY, ColorUtils.rgb(125, 126, 186), 5.1f, 0.05f ); } // Отрисовка имени над головой float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); String friendPrefix = FriendStorage.isFriend(entity.getName().getString()) ? TextFormatting.GREEN + "[F] " : ""; TextComponent name = (TextComponent) ITextComponent.getTextComponentOrEmpty(friendPrefix); if ((AlwaysWin.getInstance().getFunctionRegistry().getNameProtect().isState())) { if (FriendStorage.isFriend(entity.getName().getString())) { name.append(new StringTextComponent(TextFormatting.RED + "protected")); } else { name.append(entity.getDisplayName()); } } else { name.append(entity.getDisplayName()); } mc.fontRenderer.func_243246_a(e.getMatrixStack(), name, position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); // Отрисовка эффектов (зелья) if (!remove.getValueByName("Список эффектов").get()) { drawPotions(e.getMatrixStack(), living, position.z + 2, position.y); } // Отрисовка предметов (броня, оружие) drawItems(e.getMatrixStack(), living, (int) (position.x + width / 2f), (int) (position.y - 20)); } else if (entity instanceof ItemEntity) { Vector4f position = entry.getValue(); float width = position.z - position.x; float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); mc.fontRenderer.func_243246_a(e.getMatrixStack(), entity.getDisplayName(), position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); } } } private float fix1000Health(Entity entity, float original) { Score score = mc.world.getScoreboard().getOrCreateScore( entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2) ); return userConnectedToFunTimeAndEntityIsPlayer(entity) ? score.getScorePoints() : original; } private boolean userConnectedToFunTimeAndEntityIsPlayer(Entity entity) { String header = mc.ingameGUI.getTabList().header == null ? " " : mc.ingameGUI.getTabList().header.getString().toLowerCase(); return (mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP.contains("funtime") && (header.contains("анархия") || header.contains("гриферский")) && entity instanceof PlayerEntity); } public boolean isInView(Entity ent) { if (mc.getRenderViewEntity() == null) { return false; } frustum.setCameraPosition( mc.getRenderManager().info.getProjectedView().x, mc.getRenderManager().info.getProjectedView().y, mc.getRenderManager().info.getProjectedView().z ); return frustum.isBoundingBoxInFrustum(ent.getBoundingBox()) || ent.ignoreFrustumCheck; } private void drawPotions(MatrixStack matrixStack, LivingEntity entity, float posX, float posY) { for (EffectInstance pot : entity.getActivePotionEffects()) { int amp = pot.getAmplifier(); String ampStr = ""; if (amp >= 1 && amp <= 9) { ampStr = " " + I18n.format("enchantment.level." + (amp + 1)); } String text = I18n.format(pot.getEffectName()) + ampStr + " - " + EffectUtils.getPotionDurationString(pot, 1); Fonts.consolas.drawText(matrixStack, text, posX, posY, -1, 6, 0.05f); posY += Fonts.consolas.getHeight(6); } } private void drawItems(MatrixStack matrixStack, LivingEntity entity, int posX, int posY) { int size = 8; int padding = 6; float fontHeight = Fonts.consolas.getHeight(6); List<ItemStack> items = new ArrayList<>(); ItemStack mainStack = entity.getHeldItemMainhand(); if (!mainStack.isEmpty()) { items.add(mainStack); } for (ItemStack itemStack : entity.getArmorInventoryList()) { if (!itemStack.isEmpty()) { items.add(itemStack); } } ItemStack offStack = entity.getHeldItemOffhand(); if (!offStack.isEmpty()) { items.add(offStack); } // Центрируем иконки posX -= (items.size() * (size + padding)) / 2f; for (ItemStack itemStack : items) { if (itemStack.isEmpty()) continue; GL11.glPushMatrix(); glCenteredScale(posX, posY, size / 2f, size / 2f, 0.5f); mc.getItemRenderer().renderItemAndEffectIntoGUI(itemStack, posX, posY); mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, posX, posY, null); GL11.glPopMatrix(); // Отрисовка зачарований, если нужно if (itemStack.isEnchanted() && !remove.getValueByName("Зачарования").get()) { int ePosY = (int) (posY - fontHeight); Map<Enchantment, Integer> enchantmentsMap = EnchantmentHelper.getEnchantments(itemStack); for (Enchantment enchantment : enchantmentsMap.keySet()) { int level = enchantmentsMap.get(enchantment); if (level < 1 || !enchantment.canApply(itemStack)) continue; IFormattableTextComponent enchantText = new TranslationTextComponent(enchantment.getName()); String enchText = enchantText.getString().substring(0, 2) + level; Fonts.consolas.drawText(matrixStack, enchText, posX, ePosY, -1, 6, 0.05f); ePosY -= (int) fontHeight; } } posX += size + padding; } } public boolean isValid(Entity e) { return isInView(e); } public void glCenteredScale(final float x, final float y, final float w, final float h, final float f) { glTranslatef(x + w / 2, y + h / 2, 0); glScalef(f, f, 1); glTranslatef(-x - w / 2, -y - h / 2, 0); }

} на месте где рендерится ник зарендерить под него рект вот пример DisplayUtils.drawRoundedRect(
x,
y,
width,
height,
new Vector4f(10, 10, 10, 10),
new Color(19, 19, 29).getRGB()
); так же создай новую настройку nametags это будет включать или отключать наш новый ник с ректом и пиши полный код

Gedanke

Revisiting the task

I’m considering how to best assist the user in rewriting the ESP health bar to move it to the right side and provide the full code for package cc.al.

Reassessing the task

I’m thinking about how to effectively move the ESP health bar to the right side and provide the complete code for package cc.al, considering the best approach to address the user's request.

Optimizing the setup

I’m pondering how to rearrange the ESP health bar to the right side and craft the entire code for package cc.al, aiming to enhance the user's experience effectively and efficiently.

Shifting the health bar

I’m reassessing the placement of the ESP health bar to the right and preparing to provide the full code for package cc.al, ensuring the user's request is effectively addressed.

Restructuring the health bar

I’m in the process of shifting the ESP health bar to the right side and crafting the full code for package cc.al, aiming to align with the user's request efficiently.

Adjusting my approach

I'm planning to move the ESP health bar to the right and provide the complete code for package cc.al, ensuring it aligns with the user's specific request.

Mapping out the solution

I’m transferring the ESP health bar to the right side and coding package cc.al, ensuring it meets the user's request effectively and efficiently.

Crafting the solution

I’m thinking through the ESP health bar's transition to the right side and detailing the full code for package cc.al, ensuring alignment with the user's specific request.

Reasoned for 8 seconds

Antwort

Для выполнения вашего запроса, нужно добавить новую настройку для управления отображением имени с прямоугольником (ректом). Также необходимо изменить код для рендеринга прямоугольника под именем игрока.

Вот как можно это реализовать:

  1. Добавляем новую настройку nametags для включения/выключения отображения прямоугольника под ником.
  2. Изменяем рендеринг имени, чтобы под ним отображался прямоугольник с округлыми углами.

Вот полный код с внесёнными изменениями:

java
package cc.alwayswin.modules.impl.visuals; import cc.alwayswin.AlwaysWin; import com.google.common.eventbus.Subscribe; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import cc.alwayswin.command.friends.FriendStorage; import cc.alwayswin.events.EventDisplay; import cc.alwayswin.modules.api.Category; import cc.alwayswin.modules.api.Module; import cc.alwayswin.modules.api.ModuleRegister; import cc.alwayswin.modules.settings.impl.BooleanSetting; import cc.alwayswin.modules.settings.impl.ModeListSetting; import cc.alwayswin.utils.math.MathUtil; import cc.alwayswin.utils.math.Vector4i; import cc.alwayswin.utils.projections.ProjectionUtil; import cc.alwayswin.utils.render.ColorUtils; import cc.alwayswin.utils.render.DisplayUtils; import cc.alwayswin.utils.render.font.Fonts; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.PointOfView; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectUtils; import net.minecraft.scoreboard.Score; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector2f; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector4f; import net.minecraft.util.text.*; import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static net.minecraft.client.renderer.WorldRenderer.frustum; import static org.lwjgl.opengl.GL11.glScalef; import static org.lwjgl.opengl.GL11.glTranslatef; @ModuleRegister(name = "ESP", type = Category.Visuals) public class ESP extends Module { public ModeListSetting remove = new ModeListSetting("Убрать", new BooleanSetting("Боксы", false), new BooleanSetting("Полоску хп", false), new BooleanSetting("Текст хп", false), new BooleanSetting("Зачарования", true), new BooleanSetting("Список эффектов", false) ); public BooleanSetting nametags = new BooleanSetting("Отображение имени с ректом", true); public ESP() { addSettings(remove, nametags); // добавляем новую настройку } private final HashMap<Entity, Vector4f> positions = new HashMap<>(); @Subscribe public void onDisplay(EventDisplay e) { if (mc.world == null || e.getType() != EventDisplay.Type.PRE) { return; } positions.clear(); Vector4i colors = new Vector4i(HUD.getColor(0, 1), HUD.getColor(90, 1), HUD.getColor(180, 1), HUD.getColor(270, 1)); Vector4i friendColors = new Vector4i( HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 0, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 90, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 180, 1), HUD.getColor(ColorUtils.rgb(144, 238, 144), ColorUtils.rgb(0, 139, 0), 270, 1) ); boolean box = remove.getValueByName("Боксы").get(); boolean healthLine = remove.getValueByName("Полоску хп").get(); boolean healthText = remove.getValueByName("Текст хп").get(); boolean pots = remove.getValueByName("Список эффектов").get(); for (Entity entity : mc.world.getAllEntities()) { if (!isValid(entity)) continue; if (AntiBot.isBot(entity)) continue; if (!(entity instanceof PlayerEntity || entity instanceof ItemEntity)) continue; if (entity == mc.player && (mc.gameSettings.getPointOfView() == PointOfView.FIRST_PERSON)) continue; double x = MathUtil.interpolate(entity.getPosX(), entity.lastTickPosX, e.getPartialTicks()); double y = MathUtil.interpolate(entity.getPosY(), entity.lastTickPosY, e.getPartialTicks()); double z = MathUtil.interpolate(entity.getPosZ(), entity.lastTickPosZ, e.getPartialTicks()); Vector3d size = new Vector3d( entity.getBoundingBox().maxX - entity.getBoundingBox().minX, entity.getBoundingBox().maxY - entity.getBoundingBox().minY, entity.getBoundingBox().maxZ - entity.getBoundingBox().minZ ); AxisAlignedBB aabb = new AxisAlignedBB( x - size.x / 2f, y, z - size.z / 2f, x + size.x / 2f, y + size.y, z + size.z / 2f ); Vector4f position = null; for (int i = 0; i < 8; i++) { Vector2f vector = ProjectionUtil.project( i % 2 == 0 ? aabb.minX : aabb.maxX, (i / 2) % 2 == 0 ? aabb.minY : aabb.maxY, (i / 4) % 2 == 0 ? aabb.minZ : aabb.maxZ ); if (position == null) { position = new Vector4f(vector.x, vector.y, 1, 1.0f); } else { position.x = Math.min(vector.x, position.x); position.y = Math.min(vector.y, position.y); position.z = Math.max(vector.x, position.z); position.w = Math.max(vector.y, position.w); } } positions.put(entity, position); } RenderSystem.enableBlend(); RenderSystem.disableTexture(); RenderSystem.defaultBlendFunc(); RenderSystem.shadeModel(GL11.GL_SMOOTH); buffer.begin(7, DefaultVertexFormats.POSITION_COLOR); for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Vector4f position = entry.getValue(); if (entry.getKey() instanceof LivingEntity entity) { if (!box) { DisplayUtils.drawBox(position.x - 0.5f, position.y - 0.5f, position.z + 0.5f, position.w + 0.5f, 2, ColorUtils.rgba(0, 0, 0, 128)); DisplayUtils.drawBoxTest(position.x, position.y, position.z, position.w, 1, FriendStorage.isFriend(entity.getName().getString()) ? friendColors : colors); } // --- Изменённый участок: перенос полоски хп на правую сторону --- if (!healthLine) { float hpOffset = 3f; float out = 0.5f; // Задний прямоугольник (чуть шире, чтобы была обводка) DisplayUtils.drawRectBuilding( position.z + hpOffset - out, position.y - out, position.z + hpOffset + 1 + out, position.w + out, ColorUtils.rgba(0, 0, 0, 128) ); // Тонкая чёрная линия под полоской хп DisplayUtils.drawRectBuilding( position.z + hpOffset, position.y, position.z + hpOffset + 1, position.w, ColorUtils.rgba(0, 0, 0, 128) ); // Расчёт текущего хп float entityHealth = fix1000Health(entity, entity.getHealth()); // Закрашиваем часть полоски снизу вверх DisplayUtils.drawMCVerticalBuilding( position.z + hpOffset, position.y + (position.w - position.y) * (1 - MathHelper.clamp(entityHealth / entity.getMaxHealth(), 0, 1)), position.z + hpOffset + 1, position.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.w : colors.w, FriendStorage.isFriend(entity.getName().getString()) ? friendColors.x : colors.x ); } } } Tessellator.getInstance().draw(); RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.enableTexture(); RenderSystem.disableBlend(); // Отрисовка текста, эффектов и предметов for (Map.Entry<Entity, Vector4f> entry : positions.entrySet()) { Entity entity = entry.getKey(); if (entity instanceof LivingEntity living) { Vector4f position = entry.getValue(); float health = fix1000Health(living, living.getHealth()); float width = position.z - position.x; // --- Изменённый участок: текст хп также справа --- String hpText = (int) health + ""; float hpWidth = Fonts.sfMedium.getWidth(hpText, 6); float hpPercent = MathHelper.clamp(health / living.getMaxHealth(), 0, 1); float hpPosY = position.y + (position.w - position.y) * (1 - hpPercent); // Если галочка "Текст хп" НЕ стоит, рисуем текст if (!remove.getValueByName("Текст хп").get()) { // Ставим текст чуть правее самой полоски float hpOffset = 3f; Fonts.sfMedium.drawText( e.getMatrixStack(), hpText, position.z + hpOffset + 3, // смещение вправо hpPosY, ColorUtils.rgb(125, 126, 186), 5.1f, 0.05f ); } // --- Новый участок: Отображение имени с прямоугольником --- if (nametags.get()) { float nameLength = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); float rectWidth = nameLength + 10; // немного шире для отступов float rectHeight = 10f; // Рисуем прямоугольник с округлыми углами DisplayUtils.drawRoundedRect( position.x + width / 2f - rectWidth / 2f, position.y - 15, rectWidth, rectHeight, new Vector4f(10, 10, 10, 10), // Радиус углов new Color(19, 19, 29).getRGB() // Цвет фона ); } // Отрисовка имени над головой float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); String friendPrefix = FriendStorage.isFriend(entity.getName().getString()) ? TextFormatting.GREEN + "[F] " : ""; TextComponent name = (TextComponent) ITextComponent.getTextComponentOrEmpty(friendPrefix); if ((AlwaysWin.getInstance().getFunctionRegistry().getNameProtect().isState())) { if (FriendStorage.isFriend(entity.getName().getString())) { name.append(new StringTextComponent(TextFormatting.RED + "protected")); } else { name.append(entity.getDisplayName()); } } else { name.append(entity.getDisplayName()); } mc.fontRenderer.func_243246_a(e.getMatrixStack(), name, position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); // Отрисовка эффектов (зелья) if (!remove.getValueByName("Список эффектов").get()) { drawPotions(e.getMatrixStack(), living, position.z + 2, position.y); } // Отрисовка предметов (броня, оружие) drawItems(e.getMatrixStack(), living, (int) (position.x + width / 2f), (int) (position.y - 20)); } else if (entity instanceof ItemEntity) { Vector4f position = entry.getValue(); float width = position.z - position.x; float length = mc.fontRenderer.getStringPropertyWidth(entity.getDisplayName()); GL11.glPushMatrix(); glCenteredScale(position.x + width / 2f - length / 2f, position.y - 7, length, 10, 0.5f); mc.fontRenderer.func_243246_a(e.getMatrixStack(), entity.getDisplayName(), position.x + width / 2f - length / 2f, position.y - 7, -1); GL11.glPopMatrix(); } } } private float fix1000Health(Entity entity, float original) { Score score = mc.world.getScoreboard().getOrCreateScore( entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2) ); return userConnectedToFunTimeAndEntityIsPlayer(entity) ? score.getScorePoints() : original; } private boolean userConnectedToFunTimeAndEntityIsPlayer(Entity entity) { String header = mc.ingameGUI.getTabList().header == null ? " " : mc.ingameGUI.getTabList().header.getString().toLowerCase(); return (mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP.contains("funtime") && (header.contains("анархия") || header.contains("гриферский")) && entity instanceof PlayerEntity); } public boolean isInView(Entity ent) { if (mc.getRenderViewEntity() == null) { return false; } frustum.setCameraPosition( mc.getRenderManager().info.getProjectedView().x, mc.getRenderManager().info.getProjectedView().y, mc.getRenderManager().info.getProjectedView().z ); return frustum.isBoundingBoxInFrustum(ent.getBoundingBox()) || ent.ignoreFrustumCheck; } private void drawPotions(MatrixStack matrixStack, LivingEntity entity, float posX, float posY) { for (EffectInstance pot : entity.getActivePotionEffects()) { int amp = pot.getAmplifier(); String ampStr = ""; if (amp >= 1 && amp <= 9) { ampStr = " " + I18n.format("enchantment.level." + (amp + 1)); } String text = I18n.format(pot.getEffectName()) + ampStr + " - " + EffectUtils.getPotionDurationString(pot, 1); Fonts.consolas.drawText(matrixStack, text, posX, posY, -1, 6, 0.05f); posY += Fonts.consolas.getHeight(6); } } private void drawItems(MatrixStack matrixStack, LivingEntity entity, int posX, int posY) { int size = 8; int padding = 6; float fontHeight = Fonts.consolas.getHeight(6); List<ItemStack> items = new ArrayList<>(); ItemStack mainStack = entity.getHeldItemMainhand(); if (!mainStack.isEmpty()) { items.add(mainStack); } for (ItemStack itemStack : entity.getArmorInventoryList()) { if (!itemStack.isEmpty()) { items.add(itemStack); } } ItemStack offStack = entity.getHeldItemOffhand(); if (!offStack.isEmpty()) { items.add(offStack); } // Центрируем иконки posX -= (items.size() * (size + padding)) / 2f; for (ItemStack itemStack : items) { if (itemStack.isEmpty()) continue; GL11.glPushMatrix(); glCenteredScale(posX, posY, size / 2f, size / 2f, 0.5f); mc.getItemRenderer().renderItemAndEffectIntoGUI(itemStack, posX, posY); mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, posX, posY, null); GL11.glPopMatrix(); // Отрисовка зачарований, если нужно if (itemStack.isEnchanted() && !remove.getValueByName("Зачарования").get()) { int ePosY = (int) (posY - fontHeight); Map<Enchantment, Integer> enchantmentsMap = EnchantmentHelper.getEnchantments(itemStack); for (Enchantment enchantment : enchantmentsMap.keySet()) { int level = enchantmentsMap.get(enchantment); if (level < 1 || !enchantment.canApply(itemStack)) continue; IFormattableTextComponent enchantText = new TranslationTextComponent(enchantment.getName()); String enchText = enchantText.getString().substring(0, 2) + level; Fonts.consolas.drawText(matrixStack, enchText, posX, ePosY, -1, 6, 0.05f); ePosY -= (int) fontHeight; } } posX += size + padding; } } public boolean isValid(Entity e) { return isInView(e); } public void glCenteredScale(final float x, final float y, final float w, final float h, final float f) { glTranslatef(x + w / 2, y + h / 2, 0); glScalef(f, f, 1); glTranslatef(-x - w / 2, -y - h / 2, 0); } }

Внесённые изменения:

1

Diesen Q&A teilen