package dev.jeklout.module.modules.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 dev.jeklout.events.EventDisplay;
import dev.jeklout.events.EventRenderer3D;
import dev.jeklout.module.api.Category;
import dev.jeklout.module.api.Module;
import dev.jeklout.module.api.ModuleAnnotation;
import dev.jeklout.module.modules.combat.KillAura;
import dev.jeklout.module.settings.impl.ModeSetting;
import dev.jeklout.module.settings.impl.SliderSetting;
import dev.jeklout.utils.math.MathUtil;
import dev.jeklout.utils.math.Vector4i;
import dev.jeklout.utils.projections.ProjectionUtil;
import dev.jeklout.utils.render.ColorUtils;
import dev.jeklout.utils.render.DisplayUtils;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
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 net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
import org.lwjgl.opengl.GL11;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
@ModuleAnnotation(name = "TargetESP", type = Category.Render, discript = "")
public class TargetESP extends Module {
private final KillAura killAura;
private final ModeSetting targetMode = new ModeSetting("Таргет", "Аура", "Аура", "Аура + Наводка");
public ModeSetting mode = new ModeSetting("Режим", "Ромб", "Ромб", "Души", "Круг", "Кристаллы");
private final SliderSetting crystalDistance = new SliderSetting("Дистанция кристаллов", 0.45f, 0.0f, 1.5f, 0.05f).setVisible(() -> mode.getIndex() == 3);
public TargetESP(KillAura killAura) {
this.killAura = killAura;
addSettings(targetMode, mode, crystalDistance);
}
@Subscribe
private void onDisplay(EventDisplay e) {
if (e.getType() != EventDisplay.Type.PRE) return;
if (!killAura.isState() || killAura.target() == null) {
if (getRenderTarget() != null && mode.getIndex() == 0) {
renderDiamond(e);
}
return;
}
if (killAura.isState() && killAura.target() != null && mode.is("Ромб")) {
renderDiamond(e);
}
}
@Subscribe
private void onRender3D(EventRenderer3D e) {
if (!killAura.isState() || killAura.target() == null) {
if (getRenderTarget() == null) return;
if (mode.getIndex() == 1) {
drawSoulEffect(e.getStack(), e);
} else if (mode.getIndex() == 2) {
drawRingEffect(e.getStack(), e);
} else if (mode.getIndex() == 3) {
drawCrystalEsp(e.getStack(), e);
}
return;
}
if (!killAura.isState() || killAura.target() == null) return;
if (mode.is("Души")) {
drawSoulEffect(e.getStack(), e);
} else if (mode.is("Круг")) {
drawRingEffect(e.getStack(), e);
} else if (mode.is("Кристаллы")) {
drawCrystalEsp(e.getStack(), e);
}
}
private void renderDiamond(EventDisplay e) {
LivingEntity target = getRenderTarget();
if (target == null) {
return;
}
float skoros = 1000;
double sin = Math.sin((double) System.currentTimeMillis() / skoros);
Vector3d interpolated = target.getPositon(e.getPartialTicks());
float size = (float) getScale(interpolated, 13);
boolean isDamaged = target.hurtTime > 0;
int color = isDamaged ? 0xf73b3b : Interface.getColor(0, 1);
int color1 = isDamaged ? 0xf73b3b : ColorUtils.rgb(111, 111, 111);
Vector2f pos = ProjectionUtil.project(interpolated.x, interpolated.y + (double) (target.getHeight() / 1.95F), interpolated.z);
MatrixStack ms = new MatrixStack();
ms.push();
ms.translate(pos.x, pos.y, 0);
ms.rotate(new Quaternion(new Vector3f(0, 0, 1), (float) -sin * 360.0F, true));
ms.translate(-pos.x, -pos.y, 0);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
int alpha = 255;
DisplayUtils.drawImage(new ResourceLocation("expensive/images/target.png"), pos.x - size / 2.0F, pos.y - size / 2.0F, size, size, new Vector4i(
ColorUtils.setAlpha(color1, alpha),
ColorUtils.setAlpha(color1, alpha),
ColorUtils.setAlpha(color1, alpha),
ColorUtils.setAlpha(color1, alpha)
));
DisplayUtils.drawImage(new ResourceLocation("expensive/images/target.png"), pos.x - size / 2.0F, pos.y - size / 2.0F, size, size, new Vector4i(
ColorUtils.setAlpha(color, alpha),
ColorUtils.setAlpha(color, alpha),
ColorUtils.setAlpha(color, alpha),
ColorUtils.setAlpha(color, alpha)
));
RenderSystem.disableBlend();
ms.pop();
}
private void drawCrystalEsp(MatrixStack stack, EventRenderer3D event) {
LivingEntity target = getRenderTarget();
if (target == null) {
return;
}
float tProgress = 1.0f;
double targetX = MathUtil.interpolate(target.getBoundingBox().getCenter().x, target.lastTickPosX, event.getPartialTicks());
double targetY = MathUtil.interpolate(target.getPosY(), target.lastTickPosY, event.getPartialTicks()) + 0.08;
double targetZ = MathUtil.interpolate(target.getBoundingBox().getCenter().z, target.lastTickPosZ, event.getPartialTicks());
Vector3d camPos = mc.getRenderManager().info.getProjectedView();
int baseColor = Interface.getColor(0, 1);
int secondColor = ColorUtils.interpolate(baseColor, ColorUtils.rgb(255, 255, 255), 0.5f);
float width = Math.max(target.getWidth() * 0.92f, 0.56f) + crystalDistance.get();
float timeOffset = (System.currentTimeMillis() % 4000) / 4000f * 360f;
GL11.glPushMatrix();
GL11.glTranslated(targetX - camPos.x, targetY - camPos.y, targetZ - camPos.z);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
RenderSystem.disableCull();
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_DEPTH_TEST);
RenderSystem.disableTexture();
int numLayers = 4;
int crystalsPerLayer = 6;
float speed = 2.5f;
int crystalIdx = 0;
for (int layer = 0; layer < numLayers; layer++) {
float baseHeight = target.getHeight() * ((layer + 0.35f) / numLayers);
int step = Math.max(1, 360 / crystalsPerLayer);
for (int i = 0; i < 360; i += step) {
float val = 0.9f - 0.25f * tProgress;
float angle = i + (layer * 25f) + timeOffset * speed;
float sinVal = (float) (Math.sin(Math.toRadians(angle)) * (width * val));
float cosVal = (float) (Math.cos(Math.toRadians(angle)) * (width * val));
float crystalAppearProgress = Math.max(0.0f, Math.min(1.0f, (tProgress - (crystalIdx * 0.03f)) / (1.0f - (crystalIdx * 0.03f))));
if (crystalAppearProgress >= 0.01f) {
float size = 0.12f * crystalAppearProgress;
float heightOffset = baseHeight + ((1.0f - crystalAppearProgress) * -0.18f);
float spin = (angle * 2.0f) + (System.currentTimeMillis() % 3600L) / 10.0f;
int currentCrystalColor = ColorUtils.interpolate(baseColor, secondColor, (float) (Math.sin(Math.toRadians(angle) + crystalIdx) * 0.5f + 0.5f));
GL11.glPushMatrix();
GL11.glTranslatef(sinVal, heightOffset, cosVal);
GL11.glRotatef(spin, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
drawSolidCrystalGl(size, ColorUtils.setAlpha(currentCrystalColor, (int) (255 * tProgress * crystalAppearProgress)));
GL11.glPopMatrix();
}
crystalIdx++;
}
}
mc.getTextureManager().bindTexture(new ResourceLocation("expensive/images/glow.png"));
RenderSystem.enableTexture();
crystalIdx = 0;
for (int layer = 0; layer < numLayers; layer++) {
float baseHeight = target.getHeight() * ((layer + 0.35f) / numLayers);
int step = Math.max(1, 360 / crystalsPerLayer);
for (int i = 0; i < 360; i += step) {
float angle = i + (layer * 25f) + timeOffset * speed;
float sinVal = (float) (Math.sin(Math.toRadians(angle)) * (width * (0.9f - 0.25f * tProgress)));
float cosVal = (float) (Math.cos(Math.toRadians(angle)) * (width * (0.9f - 0.25f * tProgress)));
float crystalAppearProgress = Math.max(0.0f, Math.min(1.0f, (tProgress - (crystalIdx * 0.03f)) / (1.0f - (crystalIdx * 0.03f))));
if (crystalAppearProgress >= 0.01f) {
float heightOffset = baseHeight + ((1.0f - crystalAppearProgress) * -0.18f);
int currentGlowColor = ColorUtils.interpolate(baseColor, secondColor, (float) (Math.sin(Math.toRadians(angle) + crystalIdx) * 0.5f + 0.5f));
float bloomAlpha = tProgress * crystalAppearProgress * (0.35f + 0.1f * (float) Math.sin(System.currentTimeMillis() / 300.0 + crystalIdx * 0.5));
float hs = (0.12f * 6.5f * crystalAppearProgress) / 2.0f;
int color = ColorUtils.setAlpha(currentGlowColor, (int) (255 * bloomAlpha));
GL11.glPushMatrix();
GL11.glTranslatef(sinVal, heightOffset, cosVal);
GL11.glRotatef(-mc.getRenderManager().info.getYaw(), 0.0f, 1.0f, 0.0f);
GL11.glRotatef(mc.getRenderManager().info.getPitch(), 1.0f, 0.0f, 0.0f);
drawGlowQuadGl(hs, color);
GL11.glPopMatrix();
}
crystalIdx++;
}
}
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
RenderSystem.enableCull();
GL11.glPopMatrix();
}
private void drawSoulEffect(MatrixStack stack, EventRenderer3D e) {
LivingEntity target = getRenderTarget();
if (target == null) return;
GL11.glPushMatrix();
RenderSystem.disableLighting();
GL11.glDepthMask(false);
RenderSystem.enableBlend();
RenderSystem.shadeModel(7425);
RenderSystem.disableCull();
RenderSystem.disableAlphaTest();
RenderSystem.blendFuncSeparate(770, 1, 0, 1);
double radius = 0.7f;
float speed = 30;
float size = 0.8f;
double distance = 25;
int maxAlpha = 255;
int alphaFactor = 20;
int length = 7;
ActiveRenderInfo camera = mc.getRenderManager().info;
Vector3d renderPos = camera.getProjectedView();
double x = MathUtil.interpolate(target.getPosX(), target.lastTickPosX, e.getPartialTicks());
double y = MathUtil.interpolate(target.getPosY(), target.lastTickPosY, e.getPartialTicks());
double z = MathUtil.interpolate(target.getPosZ(), target.lastTickPosZ, e.getPartialTicks());
GL11.glTranslated(x - renderPos.x + 0.2f, y - renderPos.y + 0.75f + 0.5f, z - renderPos.z);
mc.getTextureManager().bindTexture(new ResourceLocation("expensive/images/glow.png"));
MatrixStack localStack = new MatrixStack();
localStack.push();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
for (int j = 0; j < 3; j++) {
for (int i = 0; i < length; i++) {
Quaternion r = camera.getRotation().copy();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX);
double angle = 0.15f * (System.currentTimeMillis() - (i * distance)) / speed;
double s = sin(angle) * radius;
double c = cos(angle) * radius;
switch (j) {
case 0: localStack.translate(s, c, -c); break;
case 1: localStack.translate(-s, s, -c); break;
case 2: localStack.translate(s, -c, -c); break;
}
localStack.translate(-size / 2f, -size / 2f, 0);
localStack.rotate(r);
localStack.translate(size / 2f, size / 2f, 0);
int color = Interface.getColor(i, 1);
int alpha = MathHelper.clamp(maxAlpha - (i * alphaFactor), 0, maxAlpha);
int colorWithAlpha = ColorUtils.setAlpha(color, alpha);
buffer.pos(localStack.getLast().getMatrix(), 0, -size, 0).color(colorWithAlpha).tex(0, 0).endVertex();
buffer.pos(localStack.getLast().getMatrix(), -size, -size, 0).color(colorWithAlpha).tex(0, 1).endVertex();
buffer.pos(localStack.getLast().getMatrix(), -size, 0, 0).color(colorWithAlpha).tex(1, 1).endVertex();
buffer.pos(localStack.getLast().getMatrix(), 0, 0, 0).color(colorWithAlpha).tex(1, 0).endVertex();
tessellator.draw();
localStack.translate(-size / 2f, -size / 2f, 0);
r.conjugate();
localStack.rotate(r);
localStack.translate(size / 2f, size / 2f, 0);
switch (j) {
case 0: localStack.translate(-s, -c, c); break;
case 1: localStack.translate(s, -s, c); break;
case 2: localStack.translate(-s, c, c); break;
}
}
}
localStack.pop();
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
RenderSystem.enableCull();
RenderSystem.enableAlphaTest();
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
private void drawRingEffect(MatrixStack stack, EventRenderer3D e) {
LivingEntity target = getRenderTarget();
if (target == null) return;
Vector3d renderPos = mc.getRenderManager().info.getProjectedView();
double x = MathUtil.interpolate(target.getPosX(), target.lastTickPosX, e.getPartialTicks());
double y = MathUtil.interpolate(target.getPosY(), target.lastTickPosY, e.getPartialTicks());
double z = MathUtil.interpolate(target.getPosZ(), target.lastTickPosZ, e.getPartialTicks());
x -= renderPos.x;
y -= renderPos.y;
z -= renderPos.z;
float height = target.getHeight();
double duration = 2000;
double elapsed = (System.currentTimeMillis() % duration);
boolean side = elapsed > (duration / 2);
double progress = elapsed / (duration / 2);
if (side) progress -= 1;
else progress = 1 - progress;
progress = (progress < 0.5) ? 2 * progress * progress : 1 - Math.pow((-2 * progress + 2), 2) / 2;
double eased = (height / 1.2) * ((progress > 0.5) ? 1 - progress : progress) * ((side) ? -1 : 1);
RenderSystem.pushMatrix();
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
RenderSystem.disableAlphaTest();
RenderSystem.shadeModel(GL11.GL_SMOOTH);
RenderSystem.disableCull();
RenderSystem.lineWidth(1.5f);
RenderSystem.color4f(-1f, -1f, -1f, -1f);
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
buffer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_COLOR);
for (int i = 0; i <= 360; i++) {
buffer.pos(x + cos(Math.toRadians(i)) * target.getWidth() * 0.8,
y + (height * progress),
z + sin(Math.toRadians(i)) * target.getWidth() * 0.8)
.color(ColorUtils.setAlpha(Interface.getColor(0, 1), 225)).endVertex();
buffer.pos(x + cos(Math.toRadians(i)) * target.getWidth() * 0.8,
y + (height * progress) + eased,
z + sin(Math.toRadians(i)) * target.getWidth() * 0.8)
.color(ColorUtils.setAlpha(Interface.getColor(0, 1), 1)).endVertex();
}
Tessellator.getInstance().draw();
RenderSystem.color4f(-1f, -1f, -1f, -1f);
buffer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR);
for (int i = 0; i <= 360; i++) {
buffer.pos(x + cos(Math.toRadians(i)) * target.getWidth() * 0.8,
y + (height * progress),
z + sin(Math.toRadians(i)) * target.getWidth() * 0.8)
.color(ColorUtils.setAlpha(Interface.getColor(0, 1), 1)).endVertex();
}
Tessellator.getInstance().draw();
RenderSystem.enableCull();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
RenderSystem.enableAlphaTest();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
RenderSystem.shadeModel(GL11.GL_FLAT);
RenderSystem.popMatrix();
}
private void drawSolidCrystalGl(float size, int color) {
float w = size / 2f;
float h = size;
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int bCol = color & 0xFF;
int a = (color >> 24) & 0xFF;
int darkColor = (((int) (r * 0.6f)) << 16) | (((int) (g * 0.6f)) << 8) | ((int) (bCol * 0.6f)) | (a << 24);
GL11.glBegin(GL11.GL_TRIANGLES);
ColorUtils.setColor(color);
GL11.glVertex3f(0, h, 0); GL11.glVertex3f(-w, 0, -w); GL11.glVertex3f(w, 0, -w);
ColorUtils.setColor(darkColor);
GL11.glVertex3f(0, h, 0); GL11.glVertex3f(w, 0, -w); GL11.glVertex3f(w, 0, w);
ColorUtils.setColor(color);
GL11.glVertex3f(0, h, 0); GL11.glVertex3f(w, 0, w); GL11.glVertex3f(-w, 0, w);
ColorUtils.setColor(darkColor);
GL11.glVertex3f(0, h, 0); GL11.glVertex3f(-w, 0, w); GL11.glVertex3f(-w, 0, -w);
ColorUtils.setColor(darkColor);
GL11.glVertex3f(0, -h, 0); GL11.glVertex3f(w, 0, -w); GL11.glVertex3f(-w, 0, -w);
ColorUtils.setColor(color);
GL11.glVertex3f(0, -h, 0); GL11.glVertex3f(w, 0, w); GL11.glVertex3f(w, 0, -w);
ColorUtils.setColor(darkColor);
GL11.glVertex3f(0, -h, 0); GL11.glVertex3f(-w, 0, w); GL11.glVertex3f(w, 0, w);
ColorUtils.setColor(color);
GL11.glVertex3f(0, -h, 0); GL11.glVertex3f(-w, 0, -w); GL11.glVertex3f(-w, 0, w);
GL11.glEnd();
}
private void drawGlowQuadGl(float hs, int color) {
ColorUtils.setColor(color);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0.0f, 0.0f);
GL11.glVertex3f(-hs, -hs, 0.0f);
GL11.glTexCoord2f(0.0f, 1.0f);
GL11.glVertex3f(-hs, hs, 0.0f);
GL11.glTexCoord2f(1.0f, 1.0f);
GL11.glVertex3f(hs, hs, 0.0f);
GL11.glTexCoord2f(1.0f, 0.0f);
GL11.glVertex3f(hs, -hs, 0.0f);
GL11.glEnd();
}
private Vector3d interpolateTarget(LivingEntity entity, float partialTicks) {
return MathUtil.interpolate(
entity.getPositionVec(),
new Vector3d(entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ),
partialTicks
);
}
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(10.0, 1000.0 / distance) * (size / 30.0) / (fov == 70.0 ? 1.0 : fov / 70.0);
}
private LivingEntity getRenderTarget() {
LivingEntity auraTarget = killAura.target();
if (targetMode.getIndex() == 0) {
return killAura.isState() ? auraTarget : null;
}
if (killAura.isState() && auraTarget != null) {
return auraTarget;
}
Entity pointedEntity = mc.pointedEntity;
if (!(pointedEntity instanceof LivingEntity)) {
return null;
}
LivingEntity livingEntity = (LivingEntity) pointedEntity;
if (livingEntity == mc.player || livingEntity instanceof ArmorStandEntity || !livingEntity.isAlive()) {
return null;
}
return livingEntity;
}
}
от сюда возми кристалы себе