package fun.ellant.modules.impl.render;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import fun.ellant.events.WorldEvent;
import fun.ellant.modules.main.Category;
import fun.ellant.modules.main.Module;
import fun.ellant.modules.impl.hud.HUD;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import fun.ellant.events.EventDisplay;
import fun.ellant.events.EventDisplay.Type;
import fun.ellant.modules.impl.combat.Aura;
import fun.ellant.modules.settings.Setting;
import fun.ellant.modules.settings.impl.ModeSetting;
import fun.ellant.modules.settings.impl.SliderSetting;
import fun.ellant.utils.math.Vector4i;
import fun.ellant.utils.projections.ProjectionUtil;
import fun.ellant.utils.render.ColorUtils;
import fun.ellant.utils.render.DisplayUtils;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3f;
import net.optifine.shaders.Shaders;
import org.lwjgl.opengl.GL11;
import static com.mojang.blaze3d.systems.RenderSystem.depthMask;
import static org.joml.Math.toRadians;
public class TargetESP extends Module {
private final Aura killAura;
public ModeSetting mod = new ModeSetting("Мод", "Призраки", new String[]{"Client", "Wild", "Star", "Призраки"});
public SliderSetting speed = new SliderSetting("Скорость", 3.0F, 0.7F, 9.0F, 1.0F).setVisible(() -> mod.is("Призраки"));
public TargetESP(Aura killAura) {
super("TargetESP", Category.RENDER, "", "", "", 0);
this.killAura = killAura;
this.addSettings(new Setting[]{mod, speed});
}
@Subscribe
private void onDisplay(EventDisplay e) {
if (this.mod.is("Star")) {
if (e.getType() != Type.PRE) {
return;
}
if (this.killAura.isState() && this.killAura.getTarget() != null) {
double sin = Math.sin((double) System.currentTimeMillis() / 1000.0);
float size = 70.0F;
Vector3d interpolated = this.killAura.getTarget().getPositon(e.getPartialTicks());
Vector2f pos = ProjectionUtil.project(interpolated.x, interpolated.y + (double) (this.killAura.getTarget().getHeight() / 2.0F), 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);
DisplayUtils.drawImage(new ResourceLocation("expensive/images/star.png"), pos.x - size / 2.0F, pos.y - size / 2.0F, size, size, new Vector4i(ColorUtils.rgb(255, 255, 255), ColorUtils.setAlpha(HUD.getColor(90, 1.0F), 220), ColorUtils.setAlpha(HUD.getColor(180, 1.0F), 220), ColorUtils.setAlpha(HUD.getColor(270, 1.0F), 220)));
GlStateManager.popMatrix();
}
}
if (this.mod.is("Wild")) {
if (e.getType() != Type.PRE) {
return;
}
if (this.killAura.isState() && this.killAura.getTarget() != null) {
double sin = Math.sin((double) System.currentTimeMillis() / 1000.0);
float size = 70.0F;
Vector3d interpolated = this.killAura.getTarget().getPositon(e.getPartialTicks());
Vector2f pos = ProjectionUtil.project(interpolated.x, interpolated.y + (double) (this.killAura.getTarget().getHeight() / 2.0F), 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);
DisplayUtils.drawImage(new ResourceLocation("expensive/images/target1.png"), pos.x - size / 2.0F, pos.y - size / 2.0F, size, size, new Vector4i(ColorUtils.rgb(255, 255, 255), ColorUtils.setAlpha(HUD.getColor(90, 1.0F), 220), ColorUtils.setAlpha(HUD.getColor(180, 1.0F), 220), ColorUtils.setAlpha(HUD.getColor(270, 1.0F), 220)));
GlStateManager.popMatrix();
}
}
if (this.mod.is("Client")) {
if (e.getType() != Type.PRE) {
return;
}
if (this.killAura.isState() && this.killAura.getTarget() != null) {
double sin = Math.sin((double) System.currentTimeMillis() / 1000.0);
float size = 70.0F;
Vector3d interpolated = this.killAura.getTarget().getPositon(e.getPartialTicks());
Vector2f pos = ProjectionUtil.project(interpolated.x, interpolated.y + (double) (this.killAura.getTarget().getHeight() / 2.0F), 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);
DisplayUtils.drawImage(new ResourceLocation("expensive/images/target.png"), pos.x - size / 2.0F, pos.y - size / 2.0F, size, size, new Vector4i(ColorUtils.rgb(255, 255, 255), ColorUtils.setAlpha(HUD.getColor(90, 1.0F), 220), ColorUtils.setAlpha(HUD.getColor(180, 1.0F), 220), ColorUtils.setAlpha(HUD.getColor(270, 1.0F), 220)));
GlStateManager.popMatrix();
}
}
}
public static float normalize(float value, float min, float max) {
return (value - min) / (max - min);
}
private LivingEntity target;
public static long startTime = System.currentTimeMillis();
@Subscribe
private void onWorldEvent(WorldEvent e) {
if (mod.is("Призраки")) {
float speedi = (Float) speed.get();
MatrixStack stack = new MatrixStack();
EntityRendererManager rm = mc.getRenderManager();
double speed = (double) speedi;
float c = (float) ((((System.currentTimeMillis() - startTime) / 1500F / speed)) + (Math.sin((((System.currentTimeMillis() - startTime) / 1500F))) / 10f));
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 alpha = Shaders.shaderPackLoaded ? 1f : 0.5f;
alpha *= 0.2F;
float pl = 0;
boolean fa = true;
for (int b = 0; b < 3; b++) {
for (float i = c * 360; i < c * 360 + 70; i += 2) {
float cur = i;
float min = c * 360;
float max = c * 360 + 70;
float dc = MathHelper.normalize(cur, c * 360 - 45, max);
float degrees = i;
int color = HUD.getColor(0);
int color2 = HUD.getColor(90);
float rf = 0.7f;
double radians = Math.toRadians(degrees);
double plY = pl + Math.sin(radians * 1.2f) * 0.1f;
stack.push();
stack.translate(x, y, z);
//stack.rotate(rm.info.getRotation());
//stack.rotate(mc.getRenderManager().info.getRotation());
stack.rotate(Vector3f.YP.rotationDegrees(-rm.info.getYaw()));
depthMask(false);
float q = (!fa ? 0.15f : 0.15f) * (Math.max(fa ? 0.15f : 0.15f, fa ? dc : (1f - -(0.4f - dc)) / 2f) + 0.45f);
float w = q * (2f + ((0.5f - alpha) * 2));
//GL11.glDisable(GL11.GL_DEPTH_TEST);
RenderHelper.drawImage1(stack,
new ResourceLocation("expensive/images/glow.png"),
Math.cos(radians) * rf - w / 2f,
plY + 1 - 0.7,
Math.sin(radians) * rf - w / 2f, w, w,
color,
color2,
color2,
color);
GL11.glEnable(GL11.GL_DEPTH_TEST);
depthMask(true);
stack.pop();
}
c *= -1.25f;
fa = !fa;
pl += 0.45f;
}
}
}
}