Начинающий
- Статус
- Оффлайн
- Регистрация
- 23 Июн 2025
- Сообщения
- 43
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
Пожалуйста, авторизуйтесь для просмотра ссылки.
Код:
package im.expensive.functions.impl.render;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import im.expensive.Expensive;
import im.expensive.events.EventDisplay;
import im.expensive.events.EventUpdate;
import im.expensive.events.WorldEvent;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.impl.combat.KillAura;
import im.expensive.functions.impl.render.HUD;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.utils.animations.Animation;
import im.expensive.utils.animations.impl.DecelerateAnimation;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.projections.ProjectionUtil;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.WorldVertexBufferUploader;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector2f;
import im.expensive.utils.animations.Direction;
import net.minecraft.util.math.vector.Vector3d;
import org.lwjgl.opengl.GL11;
import static com.mojang.blaze3d.platform.GlStateManager.GL_QUADS;
import static com.mojang.blaze3d.platform.GlStateManager.depthMask;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import static net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_COLOR_TEX;
@FunctionRegister(name = "TargetESP", type = Category.Render)
public class TargetESP extends Function {
private final ModeSetting type = new ModeSetting("Тип", "Ромб", "Ромб", "Ромб", "Кольцо", "Призраки", "Не отображать");
private final Animation alpha = new DecelerateAnimation(600, 255);
private LivingEntity currentTarget;
public static LivingEntity target = null;
private final KillAura killAura;
private double speed;
private double animX, animY, animZ;
private long lastTime = System.currentTimeMillis();
public static long startTime = System.currentTimeMillis();
public TargetESP(KillAura killAura) {
this.killAura = killAura;
addSettings(type);
}
public double getScale(Vector3d position, double size) {
Vector3d cam = mc.getRenderManager().info.getProjectedView();
double distance = cam.distanceTo(position);
double fov = mc.gameRenderer.getFOVModifier(mc.getRenderManager().info, mc.getRenderPartialTicks(), true);
return Math.max(10f, 1000 / distance) * (size / 30f) / (fov == 70 ? 1 : fov / 70.0f);
}
@Subscribe
private void onUpdate(EventUpdate eventUpdate) {
KillAura killAura = Expensive.getInstance().getFunctionRegistry().getKillAura();
if (killAura.getTarget() != null) {
currentTarget = killAura.getTarget();
}
alpha.setDirection(!killAura.isState() || killAura.getTarget() == null ? Direction.BACKWARDS : Direction.FORWARDS);
}
@Subscribe
private void onWorldEvent(WorldEvent e) {
if (this.type.is("Кольцо")) {
EntityRendererManager rm = mc.getRenderManager();
if (killAura.isState() && killAura.getTarget() != null) {
double x = killAura.getTarget().lastTickPosX + (killAura.getTarget().getPosX() - killAura.getTarget().lastTickPosX) * (double) e.getPartialTicks() - rm.info.getProjectedView().getX();
double y = killAura.getTarget().lastTickPosY + (killAura.getTarget().getPosY() - killAura.getTarget().lastTickPosY) * (double) e.getPartialTicks() - rm.info.getProjectedView().getY();
double z = killAura.getTarget().lastTickPosZ + (killAura.getTarget().getPosZ() - killAura.getTarget().lastTickPosZ) * (double) e.getPartialTicks() - rm.info.getProjectedView().getZ();
float height = killAura.getTarget().getHeight();
double duration = 2000.0;
double elapsed = (double) System.currentTimeMillis() % duration;
boolean side = elapsed > duration / 2.0;
double progress = elapsed / (duration / 2.0);
progress = side ? --progress : 1.0 - progress;
progress = progress < 0.5 ? 2.0 * progress * progress : 1.0 - Math.pow(-2.0 * progress + 2.0, 2.0) / 2.0;
double eased = (double) (height / 2.0F) * (progress > 0.5 ? 1.0 - progress : progress) * (double) (side ? -1 : 1);
RenderSystem.pushMatrix();
GL11.glDepthMask(false);
GL11.glEnable(2848);
GL11.glHint(3154, 4354);
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.disableAlphaTest();
RenderSystem.shadeModel(7425);
RenderSystem.disableCull();
RenderSystem.lineWidth(1.5F);
float glowAlpha = 145F;
float coreAlpha = 17.1F;
RenderSystem.color4f(6.0F, 6.0F, 6.0F, glowAlpha);
buffer.begin(8, DefaultVertexFormats.POSITION_COLOR);
float[] colors = null;
int i;
for (i = 0; i <= 360; ++i) {
colors = DisplayUtils.IntColor.rgb(HUD.getColor(0));
buffer.pos(x + cos(Math.toRadians((double) i)) * (double) this.killAura.getTarget().getWidth() * 0.85, y + (double) height * progress, z + sin(Math.toRadians((double) i)) * (double) this.killAura.getTarget().getWidth() * 0.85)
.color(colors[0], colors[1], colors[2], glowAlpha).endVertex();
buffer.pos(x + cos(Math.toRadians((double) i)) * (double) this.killAura.getTarget().getWidth() * 0.85, y + (double) height * progress + eased * 1.5, z + sin(Math.toRadians((double) i)) * (double) this.killAura.getTarget().getWidth() * 0.85)
.color(colors[0], colors[1], colors[2], coreAlpha).endVertex();
}
buffer.finishDrawing();
WorldVertexBufferUploader.draw(buffer);
RenderSystem.color4f(0.5F, 0.5F, 0.5F, coreAlpha);
buffer.begin(2, DefaultVertexFormats.POSITION_COLOR);
for (i = 0; i <= 360; ++i) {
buffer.pos(x + cos(Math.toRadians((double) i)) * (double) this.killAura.getTarget().getWidth() * 0.85, y + (double) height * progress, z + sin(Math.toRadians((double) i)) * (double) this.killAura.getTarget().getWidth() * 0.85)
.color(colors[0], colors[1], colors[2], coreAlpha).endVertex();
}
buffer.finishDrawing();
WorldVertexBufferUploader.draw(buffer);
RenderSystem.enableCull();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
RenderSystem.enableAlphaTest();
GL11.glDepthMask(true);
GL11.glDisable(2848);
GL11.glHint(3154, 4354);
RenderSystem.shadeModel(7424);
RenderSystem.popMatrix();
}
}
// Добавь эти поля в начало класса TargetESP, где все переменные
// Замени блок "Призраки" в onWorldEvent на этот:
if (type.is("Призраки")) {
KillAura killAura = Expensive.getInstance().getFunctionRegistry().getKillAura();
// Проверяем состояние ауры и наличие цели
if (killAura.isState() && killAura.getTarget() != null) {
LivingEntity targetEntity = killAura.getTarget();
net.minecraft.client.renderer.Tessellator tessellator = net.minecraft.client.renderer.Tessellator.getInstance();
net.minecraft.client.renderer.BufferBuilder buffer = tessellator.getBuffer();
MatrixStack ms = new MatrixStack();
RenderSystem.pushMatrix();
RenderSystem.depthMask(false);
RenderSystem.enableBlend();
RenderSystem.shadeModel(7425);
RenderSystem.disableCull();
RenderSystem.disableAlphaTest();
RenderSystem.blendFuncSeparate(770, 1, 0, 1);
// Расчет времени (копия Dick/Nursultan)
float time = (float) ((float) (System.currentTimeMillis() - startTime) / 1500.0F + Math.sin((float) (System.currentTimeMillis() - startTime) / 1500.0F) / 15.0);
// Интерполированная позиция цели (чтобы не дергалось)
Vector3d vector3d = MathUtil.interpolate(targetEntity.getPositionVec(),
new Vector3d(targetEntity.lastTickPosX, targetEntity.lastTickPosY, targetEntity.lastTickPosZ), e.getPartialTicks());
ActiveRenderInfo camera = mc.getRenderManager().info;
// Путь к текстуре (проверь, чтобы файл был!)
mc.getTextureManager().bindTexture(new ResourceLocation("expensive/images/glow.png"));
boolean alternate = true;
for (int iteration = 0; iteration < 3; iteration++) {
// Смещение между слоями чуть меньше для плотности
float offset = (iteration - 1) * 0.5F;
for (float i = time * 360.0F; i < time * 360.0F + 80.0F; i += 2.0F) {
float max = time * 360.0F + 40.0F;
float angleProgress = MathUtil.normalize(i, time * 360.0F, max);
// РАДИУС: Сделал 0.45F (в Dick они летают почти вплотную к хитбоксу)
float radius = 0.75F;
double radians = Math.toRadians(i);
double offsetY = Math.sin(radians * 1.1F) * 0.4F + offset;
// РАЗМЕР: Уменьшил базовый множитель до 1.1F (был 1.4F)
float sizeMultiplier = (!alternate ? 0.22F : 0.12F)
* (Math.max(alternate ? 0.22F : 0.12F, alternate ? angleProgress : (1.0F + (0.4F - angleProgress)) / 2.0F) + 0.4F);
float size = sizeMultiplier * 1.1F;
ms.push();
// Позиция частицы (Центрируем относительно цели)
double x = vector3d.x + Math.cos(radians) * radius - camera.getProjectedView().getX();
double y = vector3d.y + targetEntity.getHeight() / 2.0F + offsetY - camera.getProjectedView().getY();
double z = vector3d.z + Math.sin(radians) * radius - camera.getProjectedView().getZ();
ms.translate(x, y, z);
// Наклон: Полное копирование вращения камеры (Billboard)
ms.rotate(camera.getRotation());
int color = HUD.getColor((int) i);
int alphaVal = (int) (alpha.getOutput());
// Отрисовка
buffer.begin(7, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_COLOR_TEX);
net.minecraft.util.math.vector.Matrix4f matrix = ms.getLast().getMatrix();
buffer.pos(matrix, -size / 2f, -size / 2f, 0).color(ColorUtils.setAlpha(color, alphaVal)).tex(0, 0).endVertex();
buffer.pos(matrix, size / 2f, -size / 2f, 0).color(ColorUtils.setAlpha(color, alphaVal)).tex(1, 0).endVertex();
buffer.pos(matrix, size / 2f, size / 2f, 0).color(ColorUtils.setAlpha(color, alphaVal)).tex(1, 1).endVertex();
buffer.pos(matrix, -size / 2f, size / 2f, 0).color(ColorUtils.setAlpha(color, alphaVal)).tex(0, 1).endVertex();
tessellator.draw();
ms.pop();
}
time *= -1.3F;
alternate = !alternate;
}
RenderSystem.depthMask(true);
RenderSystem.disableBlend();
RenderSystem.popMatrix();
}
}
}
@Subscribe
private void onDisplay(EventDisplay e) {
if (e.getType() != EventDisplay.Type.PRE) {
return;
}
if (currentTarget != null && !alpha.finished(Direction.BACKWARDS) && type.is("Ромб")) {
double sin = sin(System.currentTimeMillis() / 1000.0);
Vector3d interpolated = currentTarget.getPositon(e.getPartialTicks());
float size = (float) getScale(interpolated, 9);
Vector2f pos = ProjectionUtil.project(interpolated.x, interpolated.y + currentTarget.getHeight() / 1.8f, interpolated.z);
GlStateManager.pushMatrix();
GlStateManager.translatef(pos.x, pos.y, 0.0F);
GlStateManager.rotatef((float) sin * 360.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translatef(-pos.x, -pos.y, 0.0F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(770, 1);
int alpha = (int) this.alpha.getOutput();
DisplayUtils.drawImage(new ResourceLocation("expensive/images/target.png"), pos.x - size / 2f, pos.y - size / 2f, size, size, new Vector4i(
ColorUtils.setAlpha(HUD.getColor(0, 1), alpha),
ColorUtils.setAlpha(HUD.getColor(90, 1), alpha),
ColorUtils.setAlpha(HUD.getColor(180, 1), alpha),
ColorUtils.setAlpha(HUD.getColor(270, 1), alpha)
));
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
}
IntColor:
public static class IntColor {
public static float[] rgb(int color) {
return new float[]{(color >> 16 & 0xFF) / 255f, (color >> 8 & 0xFF) / 255f, (color & 0xFF) / 255f, (color >> 24 & 0xFF) / 255f};
}
public static int rgba(int r, int g, int b, int a) {
return a << 24 | r << 16 | g << 8 | b;
}
public static int getRed(int hex) {
return hex >> 16 & 255;
}
public static int getGreen(int hex) {
return hex >> 8 & 255;
}
public static int getBlue(int hex) {
return hex & 255;
}
public static int getAlpha(final int hex) {
return hex >> 24 & 255;
}
}
}
