Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Визуальная часть Targetesp Rockstar 2.0

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
4 Дек 2025
Сообщения
14
Реакции
0
Выберите загрузчик игры
  1. Fabric
короче добавил новые виды таргет есп (маркер,цепи,круги)и функции по мелочи
ss:
новые функции будут тут как и новй опен сурс клиент
Пожалуйста, авторизуйтесь для просмотра ссылки.


self pasta:
Expand Collapse Copy
package moscow.rockstar.systems.modules.modules.visuals;

import com.mojang.blaze3d.platform.GlStateManager.DstFactor;
import com.mojang.blaze3d.platform.GlStateManager.SrcFactor;
import com.mojang.blaze3d.systems.RenderSystem;
import moscow.rockstar.Rockstar;
import moscow.rockstar.systems.event.EventListener;
import moscow.rockstar.systems.event.impl.render.Render3DEvent;
import moscow.rockstar.systems.modules.api.ModuleCategory;
import moscow.rockstar.systems.modules.api.ModuleInfo;
import moscow.rockstar.systems.modules.impl.BaseModule;
import moscow.rockstar.systems.setting.settings.ColorSetting;
import moscow.rockstar.systems.setting.settings.ModeSetting;
import moscow.rockstar.systems.setting.settings.BooleanSetting;
import moscow.rockstar.systems.setting.settings.SliderSetting;
import moscow.rockstar.utility.animation.base.Animation;
import moscow.rockstar.utility.animation.base.Easing;
import moscow.rockstar.utility.colors.ColorRGBA;
import moscow.rockstar.utility.colors.Colors;
import moscow.rockstar.utility.game.EntityUtility;
import moscow.rockstar.utility.math.MathUtility;
import moscow.rockstar.utility.render.CrystalRenderer;
import moscow.rockstar.utility.render.DrawUtility;
import moscow.rockstar.utility.render.RenderUtility;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormat.DrawMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.HitResult.Type;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;
import net.minecraft.world.RaycastContext.FluidHandling;
import net.minecraft.world.RaycastContext.ShapeType;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;

@ModuleInfo(name = "Target ESP", category = ModuleCategory.VISUALS, desc = "Помечает активную цель")
public class TargetESP extends BaseModule {
   private final ModeSetting mode = new ModeSetting(this, "modules.settings.target_esp.mode");
   private final ModeSetting.Value souls = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.souls");
   private final ModeSetting.Value crystals = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.crystals").select();
   private final ModeSetting.Value chains = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.chains");
   private final ModeSetting.Value circles = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.circles");
   private final ModeSetting.Value marker = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.marker");
 
   private final ColorSetting colorTarget = new ColorSetting(this, "color").color(Colors.ACCENT);
   private final BooleanSetting showOnHover = new BooleanSetting(this, "modules.settings.target_esp.show_on_hover");
   private final BooleanSetting changeColorOnDamage = new BooleanSetting(this, "modules.settings.target_esp.change_color_on_damage").enable();
 
   private final SliderSetting speed = new SliderSetting(this, "modules.settings.target_esp.speed").min(0.1f).max(5.0f).step(0.1f).currentValue(0.5f);
   private final SliderSetting size = new SliderSetting(this, "modules.settings.target_esp.size").min(0.5f).max(3.0f).step(0.1f).currentValue(1.5f);
 
   private final SliderSetting ghostCount = new SliderSetting(this, "modules.settings.target_esp.ghost_count", () -> this.souls.isSelected()).min(1.0f).max(50.0f).step(1.0f).currentValue(50.0f);
   private final SliderSetting ghostThickness = new SliderSetting(this, "modules.settings.target_esp.ghost_thickness", () -> this.souls.isSelected()).min(0.1f).max(2.0f).step(0.1f).currentValue(1.7f);
   private final Animation animation = new Animation(300L, 0.0F, Easing.BOTH_CUBIC);
   private final Animation moving = new Animation(70L, 0.0F, Easing.LINEAR);
   private final Animation hurtAnimation = new Animation(200L, 0.0F, Easing.BOTH_CUBIC);
   private final Animation markerRotation = new Animation(50L, 0.0F, Easing.LINEAR);
   private LivingEntity prevTarget;
 
   private float chainRotationAngle = 0f;
   private float prevChainRotationAngle = 0f;
 
   public TargetESP() {
   }
 
   private ColorRGBA getTargetColor() {
      float hitProgress = this.hurtAnimation.getValue();
      ColorRGBA baseColor = this.colorTarget.getColor();
  
      if (this.changeColorOnDamage.isEnabled() && hitProgress > 0) {
         ColorRGBA redColor = new ColorRGBA(255, 0, 0, 255);
         return baseColor.mix(redColor, hitProgress);
      }
  
      return baseColor;
   }
 
   private final EventListener<Render3DEvent> onRender3D = event -> {
      if (EntityUtility.isInGame()) {
         LivingEntity target = null;
    
         if (this.showOnHover.isEnabled()) {
            BaseModule auraModule = Rockstar.getInstance().getModuleManager().getModule("Aura");
            if (auraModule != null && auraModule.isEnabled()) {
               target = Rockstar.getInstance().getTargetManager().getCurrentTarget() instanceof LivingEntity target2 ? target2 : null;
            } else {
               if (mc.crosshairTarget != null && mc.crosshairTarget.getType() == net.minecraft.util.hit.HitResult.Type.ENTITY) {
                  net.minecraft.util.hit.EntityHitResult entityHit = (net.minecraft.util.hit.EntityHitResult) mc.crosshairTarget;
                  if (entityHit.getEntity() instanceof LivingEntity livingEntity && livingEntity != mc.player) {
                     target = livingEntity;
                  }
               }
            }
         } else {
            target = Rockstar.getInstance().getTargetManager().getCurrentTarget() instanceof LivingEntity target2 ? target2 : null;
         }
    
         this.animation.setEasing(Easing.FIGMA_EASE_IN_OUT);
         this.animation.update(target != null);
    
         float speedMultiplier = this.speed.getCurrentValue();
         this.moving.update(this.moving.getValue() + 10.0F * speedMultiplier + 50.0F * speedMultiplier);
         this.markerRotation.update(this.markerRotation.getValue() + 5.0F * speedMultiplier);
    
         this.prevChainRotationAngle = this.chainRotationAngle;
         this.chainRotationAngle += 3.0F * speedMultiplier;
    
         if (target != null && this.prevTarget == target) {
            this.hurtAnimation.update(target.hurtTime > 0);
         } else {
            this.hurtAnimation.update(false);
         }
    
         if (target != null) {
            this.prevTarget = target;
         }

         if (this.prevTarget != null && this.animation.getValue() != 0.0F) {
            MatrixStack ms = event.getMatrices();
            ms.push();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
            RenderSystem.enableDepthTest();
            if (mc.world
                  .raycast(
                     new RaycastContext(mc.gameRenderer.getCamera().getPos(), this.prevTarget.getEyePos(), ShapeType.COLLIDER, FluidHandling.NONE, mc.player)
                  )
                  .getType()
               != Type.MISS) {
               RenderSystem.disableDepthTest();
            }

            RenderSystem.disableCull();
            RenderSystem.depthMask(false);
        
            if (this.chains.isSelected()) {
               this.drawChains(ms, this.prevTarget);
            } else if (this.circles.isSelected()) {
               this.drawCircles(ms, this.prevTarget);
            } else if (this.marker.isSelected()) {
               this.drawMarker(ms, this.prevTarget);
            } else if (this.crystals.isSelected()) {
               this.drawCrystals(ms, this.prevTarget);
            } else {
               this.drawGhosts(ms, this.prevTarget);
            }

            RenderSystem.depthMask(true);
            RenderSystem.setShaderTexture(0, 0);
            RenderSystem.disableBlend();
            RenderSystem.enableCull();
            RenderSystem.disableDepthTest();
            ms.pop();
         }
      }
   };

   private void drawChains(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d targetPos = this.getRenderPos(target);
  
      double centerX = targetPos.x;
      double centerY = targetPos.y + target.getHeight() / 2;
      double centerZ = targetPos.z;
  
      double renderX = centerX - camera.getPos().getX();
      double renderY = centerY - camera.getPos().getY();
      double renderZ = centerZ - camera.getPos().getZ();
  
      this.renderChainCylinder(ms, renderX, renderY, renderZ, 0);
      this.renderChainCylinder(ms, renderX, renderY, renderZ, 90);
   }
 
   private void renderChainCylinder(MatrixStack stack, double x, double y, double z, float offsetAngle) {
      stack.push();
      stack.translate(x, y, z);
  
      float currentAngle = this.chainRotationAngle;
      stack.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Z.rotationDegrees(currentAngle + offsetAngle));
      stack.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_X.rotationDegrees(currentAngle + offsetAngle));
  
      float radius = this.prevTarget.getWidth() * 1.5f * this.size.getCurrentValue();
      int segments = 60;
  
      ColorRGBA blendedColor = this.getTargetColor();
      int alpha = (int)(this.animation.getValue() * 255);
  
      Identifier chainTexture = Rockstar.id("icons/chain.png");
      RenderSystem.setShaderTexture(0, chainTexture);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
  
      Matrix4f matrix = stack.peek().getPositionMatrix();
      BufferBuilder buffer = Tessellator.getInstance().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
  
      float textureRepeat = 4.0f;
      float chainHeight = this.prevTarget.getHeight() * 0.8f * this.size.getCurrentValue();
      float halfHeight = chainHeight / 2;
  
      for (int i = 0; i < segments; i++) {
         float angle1 = (float) (2 * Math.PI * i / segments);
         float angle2 = (float) (2 * Math.PI * (i + 1) / segments);
    
         float x1 = (float) (Math.cos(angle1) * radius);
         float z1 = (float) (Math.sin(angle1) * radius);
         float x2 = (float) (Math.cos(angle2) * radius);
         float z2 = (float) (Math.sin(angle2) * radius);
    
         float u1 = (float) i / segments * textureRepeat;
         float u2 = (float) (i + 1) / segments * textureRepeat;
    
         ColorRGBA color1 = blendedColor.withAlpha(alpha);
         ColorRGBA color2 = blendedColor.withAlpha(alpha);
    
         buffer.vertex(matrix, x1, -halfHeight, z1).texture(u1, 1f).color(color1.getRGB());
         buffer.vertex(matrix, x2, -halfHeight, z2).texture(u2, 1f).color(color2.getRGB());
         buffer.vertex(matrix, x2, halfHeight, z2).texture(u2, 0f).color(color2.getRGB());
         buffer.vertex(matrix, x1, halfHeight, z1).texture(u1, 0f).color(color1.getRGB());
      }
  
      BufferRenderer.drawWithGlobalProgram(buffer.end());
      stack.pop();
   }

   private void drawMarker(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d targetPos = this.getRenderPos(target);
  
      double entX = targetPos.x - camera.getPos().getX();
      double entY = targetPos.y - camera.getPos().getY() + target.getHeight() / 2.0;
      double entZ = targetPos.z - camera.getPos().getZ();
  
      float size = 1.2f * this.size.getCurrentValue();
      float rotationValue = this.markerRotation.getValue();
  
      RenderSystem.enableBlend();
      RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
      RenderSystem.disableDepthTest();
      RenderSystem.disableCull();
  
      ColorRGBA blendedColor = this.getTargetColor();
  
      ms.push();
      ms.translate(entX, entY, entZ);
      ms.multiply(camera.getRotation());
      ms.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Z.rotationDegrees(rotationValue));
  
      int alpha = (int)(this.animation.getValue() * 255 * 0.7f);
      ColorRGBA color = blendedColor.withAlpha(alpha);
  
      Identifier markerTexture = Rockstar.id("icons/marker.png");
  
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
  
      DrawUtility.drawImage(
         ms,
         markerTexture,
         (double)(-size / 2.0f),
         (double)(-size / 2.0f),
         0.0,
         (double)size,
         (double)size,
         color
      );
  
      DrawUtility.drawImage(
         ms,
         markerTexture,
         (double)(-size / 2.0f),
         (double)(-size / 2.0f),
         0.0,
         (double)size,
         (double)size,
         color.withAlpha(alpha * 0.3f)
      );
  
      ms.pop();
  
      RenderSystem.enableDepthTest();
      RenderSystem.enableCull();
      RenderSystem.defaultBlendFunc();
      RenderSystem.disableBlend();
   }

   private void drawCircles(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d cameraPos = camera.getPos();
      Vec3d targetPos = this.getRenderPos(target);
  
      double entX = targetPos.x - cameraPos.getX();
      double entY = targetPos.y - cameraPos.getY();
      double entZ = targetPos.z - cameraPos.getZ();
  
      float movingValue = this.moving.getValue();
      float width = target.getWidth() * 1.45f * this.size.getCurrentValue();
      float baseVal = Math.max(0.5f, 0.7f - 0.1f * this.hurtAnimation.getValue() + 0.1f - 0.1f * this.animation.getValue());
  
      RenderSystem.enableBlend();
      RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
      RenderSystem.disableDepthTest();
      RenderSystem.disableCull();
  
      ColorRGBA blendedColor = this.getTargetColor();
  
      Identifier bloomTexture = Rockstar.id("textures/bloom.png");
      RenderSystem.setShaderTexture(0, bloomTexture);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
  
      int step = 3;
      float size = 0.4f * this.size.getCurrentValue();
      float bigSize = (0.5f + 0.3f) * this.size.getCurrentValue();
  
      for (int i = 0; i < 360; i += step) {
         if ((int)(i / 45.0f) % 2 != 0) {
            double rad = Math.toRadians(i + movingValue);
            float sin = (float)(entX + Math.sin(rad) * width * baseVal);
            float cos = (float)(entZ + Math.cos(rad) * width * baseVal);
        
            double radAngle = Math.toRadians(movingValue);
            float waveValue = (float)((1.0 - Math.cos(radAngle)) / 2.0);
            float yPos = (float)(entY + target.getHeight() * waveValue);
        
            ms.push();
            ms.translate(sin, yPos, cos);
            ms.multiply(camera.getRotation());
        
            int alpha = (int)(this.animation.getValue() * 255);
        
            ColorRGBA color = blendedColor.withAlpha(alpha);
        
            BufferBuilder buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
        
            int bloomAlpha = (int)(alpha * 0.1f);
            ColorRGBA bloomColor = color.withAlpha(bloomAlpha);
        
            DrawUtility.drawImage(
               ms,
               buffer,
               (double)(-bigSize / 2.0f),
               (double)(-bigSize / 2.0f),
               0.0,
               (double)bigSize,
               (double)bigSize,
               bloomColor
            );
        
            BufferRenderer.drawWithGlobalProgram(buffer.end());
        
            buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
        
            DrawUtility.drawImage(
               ms,
               buffer,
               (double)(-size / 2.0f),
               (double)(-size / 2.0f),
               0.0,
               (double)size,
               (double)size,
               color
            );
        
            BufferRenderer.drawWithGlobalProgram(buffer.end());
            ms.pop();
         }
      }
  
      RenderSystem.enableDepthTest();
      RenderSystem.enableCull();
      RenderSystem.defaultBlendFunc();
      RenderSystem.disableBlend();
   }

   private void drawCrystals(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d cameraPos = camera.getPos();
      ColorRGBA color = this.getTargetColor();
      float width = this.prevTarget.getWidth() * 1.5F * this.size.getCurrentValue();
      RenderUtility.prepareMatrices(ms, this.getRenderPos(this.prevTarget));
      BufferBuilder builder = CrystalRenderer.createBuffer();

      for (int i = 0; i < 360; i += 20) {
         float val = 1.2F - 0.5F * this.animation.getValue();
         float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float size = 0.1F * this.size.getCurrentValue();
         ms.push();
         ms.translate(sin, 0.1F + target.getHeight() * Math.abs(MathUtility.sin(i)), cos);
         Vec3d crystalPos = this.getRenderPos(this.prevTarget).add(sin, 1.0, cos);
         Vec3d targetPos = target.getPos().add(0.0, target.getHeight() / 2.0, 0.0);
         Vector3f directionToTarget = new Vector3f(
               (float)(targetPos.x - crystalPos.x), (float)(targetPos.y - crystalPos.y), (float)(targetPos.z - crystalPos.z)
            )
            .normalize();
         Vector3f initialDirection = new Vector3f(0.0F, 1.0F, 0.0F);
         Quaternionf rotation = new Quaternionf().rotationTo(initialDirection, directionToTarget);
         ms.multiply(rotation);
         CrystalRenderer.render(ms, builder, 0.0F, 0.0F, 0.0F, size, color.withAlpha(255.0F * this.animation.getValue()));
         ms.pop();
      }

      BufferRenderer.drawWithGlobalProgram(builder.end());
      Identifier id = Rockstar.id("textures/bloom.png");
      RenderSystem.setShaderTexture(0, id);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
      BufferBuilder buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
      float bigSize = 1.0F;

      for (int i = 0; i < 360; i += 20) {
         float val = 1.2F - 0.5F * this.animation.getValue();
         float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float size = 0.1F;
         ms.push();
         ms.translate(sin, 0.1F + target.getHeight() * Math.abs(MathUtility.sin(i)), cos);
         ms.multiply(camera.getRotation());
         DrawUtility.drawImage(
            ms,
            buffer,
            (double)(-bigSize / 2.0F),
            (double)(-bigSize / 2.0F),
            0.0,
            (double)bigSize,
            (double)bigSize,
            color.withAlpha(255.0F * this.animation.getValue() * 0.2F)
         );
         ms.pop();
      }

      RenderUtility.buildBuffer(buffer);
   }

   private void drawGhosts(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      ColorRGBA color = this.getTargetColor();
      Identifier id = Rockstar.id("textures/bloom.png");
      float width = this.prevTarget.getWidth() * 1.5F * this.size.getCurrentValue();
      RenderSystem.setShaderTexture(0, id);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
      BufferBuilder builder = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
      RenderUtility.prepareMatrices(ms, this.getRenderPos(this.prevTarget));
  
      int step = Math.max(1, 360 / (int)this.ghostCount.getCurrentValue());
      float thicknessMultiplier = this.ghostThickness.getCurrentValue();
  
      int wormTick = 0;
      int wormCD = 0;
      int wormCount = 0;

      for (int i = 0; i < 360; i += step) {
         float size = (0.13F + 0.005F * wormTick) * thicknessMultiplier;
         float bigSize = (0.7F + 0.005F * wormTick) * thicknessMultiplier;
         if (wormCD > 0) {
            wormCD -= step;
         } else {
            wormTick += step;
            if (wormTick > 50) {
               wormCD = 100;
               wormTick = 0;
               wormCount++;
            } else {
               float val = Math.max(0.5F, 1.2F - 0.5F * this.animation.getValue());
               float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 1.0F)) * width * val);
               float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 1.0F)) * width * val);
               ms.push();
               ms.translate(
                  sin,
                  this.prevTarget.getHeight() / 1.5F
                     + this.prevTarget.getHeight() / 3.0F * MathUtility.sin(Math.toRadians(i / 2.0F + this.moving.getValue() / 5.0F)),
                  cos
               );
               ms.multiply(camera.getRotation());
               DrawUtility.drawImage(
                  ms,
                  builder,
                  (double)(-bigSize / 2.0F),
                  (double)(-bigSize / 2.0F),
                  (double)(-size / 2.0F),
                  (double)bigSize,
                  (double)bigSize,
                  color.withAlpha(color.getAlpha() * this.animation.getValue() * 0.05F)
               );
               DrawUtility.drawImage(
                  ms,
                  builder,
                  (double)(-size / 2.0F),
                  (double)(-size / 2.0F),
                  (double)(-size / 2.0F),
                  (double)size,
                  (double)size,
                  color.withAlpha(color.getAlpha() * this.animation.getValue())
               );
               ms.pop();
            }
         }
      }

      BufferRenderer.drawWithGlobalProgram(builder.end());
   }

   private Vec3d getRenderPos(LivingEntity target) {
      float tickDelta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
      return new Vec3d(
         MathHelper.lerp(tickDelta, target.prevX, target.getX()),
         MathHelper.lerp(tickDelta, target.prevY, target.getY()),
         MathHelper.lerp(tickDelta, target.prevZ, target.getZ())
      );
   }

   @Override
   public void tick() {
      super.tick();
   }
}
 

Вложения

  • marker.png
    marker.png
    248.9 KB · Просмотры: 169
  • chain.png
    chain.png
    10.3 KB · Просмотры: 171
Последнее редактирование:
короче добавил новые виды таргет есп (маркер,цепи,круги)и функции по мелочи
ss:


self pasta:
Expand Collapse Copy
package moscow.rockstar.systems.modules.modules.visuals;

import com.mojang.blaze3d.platform.GlStateManager.DstFactor;
import com.mojang.blaze3d.platform.GlStateManager.SrcFactor;
import com.mojang.blaze3d.systems.RenderSystem;
import moscow.rockstar.Rockstar;
import moscow.rockstar.systems.event.EventListener;
import moscow.rockstar.systems.event.impl.render.Render3DEvent;
import moscow.rockstar.systems.modules.api.ModuleCategory;
import moscow.rockstar.systems.modules.api.ModuleInfo;
import moscow.rockstar.systems.modules.impl.BaseModule;
import moscow.rockstar.systems.setting.settings.ColorSetting;
import moscow.rockstar.systems.setting.settings.ModeSetting;
import moscow.rockstar.systems.setting.settings.BooleanSetting;
import moscow.rockstar.systems.setting.settings.SliderSetting;
import moscow.rockstar.utility.animation.base.Animation;
import moscow.rockstar.utility.animation.base.Easing;
import moscow.rockstar.utility.colors.ColorRGBA;
import moscow.rockstar.utility.colors.Colors;
import moscow.rockstar.utility.game.EntityUtility;
import moscow.rockstar.utility.math.MathUtility;
import moscow.rockstar.utility.render.CrystalRenderer;
import moscow.rockstar.utility.render.DrawUtility;
import moscow.rockstar.utility.render.RenderUtility;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormat.DrawMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.HitResult.Type;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;
import net.minecraft.world.RaycastContext.FluidHandling;
import net.minecraft.world.RaycastContext.ShapeType;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;

@ModuleInfo(name = "Target ESP", category = ModuleCategory.VISUALS, desc = "Помечает активную цель")
public class TargetESP extends BaseModule {
   private final ModeSetting mode = new ModeSetting(this, "modules.settings.target_esp.mode");
   private final ModeSetting.Value souls = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.souls");
   private final ModeSetting.Value crystals = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.crystals").select();
   private final ModeSetting.Value chains = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.chains");
   private final ModeSetting.Value circles = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.circles");
   private final ModeSetting.Value marker = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.marker");
 
   private final ColorSetting colorTarget = new ColorSetting(this, "color").color(Colors.ACCENT);
   private final BooleanSetting showOnHover = new BooleanSetting(this, "modules.settings.target_esp.show_on_hover");
   private final BooleanSetting changeColorOnDamage = new BooleanSetting(this, "modules.settings.target_esp.change_color_on_damage").enable();
 
   private final SliderSetting speed = new SliderSetting(this, "modules.settings.target_esp.speed").min(0.1f).max(5.0f).step(0.1f).currentValue(0.5f);
   private final SliderSetting size = new SliderSetting(this, "modules.settings.target_esp.size").min(0.5f).max(3.0f).step(0.1f).currentValue(1.5f);
 
   private final SliderSetting ghostCount = new SliderSetting(this, "modules.settings.target_esp.ghost_count", () -> this.souls.isSelected()).min(1.0f).max(50.0f).step(1.0f).currentValue(50.0f);
   private final SliderSetting ghostThickness = new SliderSetting(this, "modules.settings.target_esp.ghost_thickness", () -> this.souls.isSelected()).min(0.1f).max(2.0f).step(0.1f).currentValue(1.7f);
   private final Animation animation = new Animation(300L, 0.0F, Easing.BOTH_CUBIC);
   private final Animation moving = new Animation(70L, 0.0F, Easing.LINEAR);
   private final Animation hurtAnimation = new Animation(200L, 0.0F, Easing.BOTH_CUBIC);
   private final Animation markerRotation = new Animation(50L, 0.0F, Easing.LINEAR);
   private LivingEntity prevTarget;
 
   private float chainRotationAngle = 0f;
   private float prevChainRotationAngle = 0f;
 
   public TargetESP() {
   }
 
   private ColorRGBA getTargetColor() {
      float hitProgress = this.hurtAnimation.getValue();
      ColorRGBA baseColor = this.colorTarget.getColor();
  
      if (this.changeColorOnDamage.isEnabled() && hitProgress > 0) {
         ColorRGBA redColor = new ColorRGBA(255, 0, 0, 255);
         return baseColor.mix(redColor, hitProgress);
      }
  
      return baseColor;
   }
 
   private final EventListener<Render3DEvent> onRender3D = event -> {
      if (EntityUtility.isInGame()) {
         LivingEntity target = null;
    
         if (this.showOnHover.isEnabled()) {
            BaseModule auraModule = Rockstar.getInstance().getModuleManager().getModule("Aura");
            if (auraModule != null && auraModule.isEnabled()) {
               target = Rockstar.getInstance().getTargetManager().getCurrentTarget() instanceof LivingEntity target2 ? target2 : null;
            } else {
               if (mc.crosshairTarget != null && mc.crosshairTarget.getType() == net.minecraft.util.hit.HitResult.Type.ENTITY) {
                  net.minecraft.util.hit.EntityHitResult entityHit = (net.minecraft.util.hit.EntityHitResult) mc.crosshairTarget;
                  if (entityHit.getEntity() instanceof LivingEntity livingEntity && livingEntity != mc.player) {
                     target = livingEntity;
                  }
               }
            }
         } else {
            target = Rockstar.getInstance().getTargetManager().getCurrentTarget() instanceof LivingEntity target2 ? target2 : null;
         }
    
         this.animation.setEasing(Easing.FIGMA_EASE_IN_OUT);
         this.animation.update(target != null);
    
         float speedMultiplier = this.speed.getCurrentValue();
         this.moving.update(this.moving.getValue() + 10.0F * speedMultiplier + 50.0F * speedMultiplier);
         this.markerRotation.update(this.markerRotation.getValue() + 5.0F * speedMultiplier);
    
         this.prevChainRotationAngle = this.chainRotationAngle;
         this.chainRotationAngle += 3.0F * speedMultiplier;
    
         if (target != null && this.prevTarget == target) {
            this.hurtAnimation.update(target.hurtTime > 0);
         } else {
            this.hurtAnimation.update(false);
         }
    
         if (target != null) {
            this.prevTarget = target;
         }

         if (this.prevTarget != null && this.animation.getValue() != 0.0F) {
            MatrixStack ms = event.getMatrices();
            ms.push();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
            RenderSystem.enableDepthTest();
            if (mc.world
                  .raycast(
                     new RaycastContext(mc.gameRenderer.getCamera().getPos(), this.prevTarget.getEyePos(), ShapeType.COLLIDER, FluidHandling.NONE, mc.player)
                  )
                  .getType()
               != Type.MISS) {
               RenderSystem.disableDepthTest();
            }

            RenderSystem.disableCull();
            RenderSystem.depthMask(false);
        
            if (this.chains.isSelected()) {
               this.drawChains(ms, this.prevTarget);
            } else if (this.circles.isSelected()) {
               this.drawCircles(ms, this.prevTarget);
            } else if (this.marker.isSelected()) {
               this.drawMarker(ms, this.prevTarget);
            } else if (this.crystals.isSelected()) {
               this.drawCrystals(ms, this.prevTarget);
            } else {
               this.drawGhosts(ms, this.prevTarget);
            }

            RenderSystem.depthMask(true);
            RenderSystem.setShaderTexture(0, 0);
            RenderSystem.disableBlend();
            RenderSystem.enableCull();
            RenderSystem.disableDepthTest();
            ms.pop();
         }
      }
   };

   private void drawChains(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d targetPos = this.getRenderPos(target);
  
      double centerX = targetPos.x;
      double centerY = targetPos.y + target.getHeight() / 2;
      double centerZ = targetPos.z;
  
      double renderX = centerX - camera.getPos().getX();
      double renderY = centerY - camera.getPos().getY();
      double renderZ = centerZ - camera.getPos().getZ();
  
      this.renderChainCylinder(ms, renderX, renderY, renderZ, 0);
      this.renderChainCylinder(ms, renderX, renderY, renderZ, 90);
   }
 
   private void renderChainCylinder(MatrixStack stack, double x, double y, double z, float offsetAngle) {
      stack.push();
      stack.translate(x, y, z);
  
      float currentAngle = this.chainRotationAngle;
      stack.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Z.rotationDegrees(currentAngle + offsetAngle));
      stack.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_X.rotationDegrees(currentAngle + offsetAngle));
  
      float radius = this.prevTarget.getWidth() * 1.5f * this.size.getCurrentValue();
      int segments = 60;
  
      ColorRGBA blendedColor = this.getTargetColor();
      int alpha = (int)(this.animation.getValue() * 255);
  
      Identifier chainTexture = Rockstar.id("icons/chain.png");
      RenderSystem.setShaderTexture(0, chainTexture);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
  
      Matrix4f matrix = stack.peek().getPositionMatrix();
      BufferBuilder buffer = Tessellator.getInstance().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
  
      float textureRepeat = 4.0f;
      float chainHeight = this.prevTarget.getHeight() * 0.8f * this.size.getCurrentValue();
      float halfHeight = chainHeight / 2;
  
      for (int i = 0; i < segments; i++) {
         float angle1 = (float) (2 * Math.PI * i / segments);
         float angle2 = (float) (2 * Math.PI * (i + 1) / segments);
    
         float x1 = (float) (Math.cos(angle1) * radius);
         float z1 = (float) (Math.sin(angle1) * radius);
         float x2 = (float) (Math.cos(angle2) * radius);
         float z2 = (float) (Math.sin(angle2) * radius);
    
         float u1 = (float) i / segments * textureRepeat;
         float u2 = (float) (i + 1) / segments * textureRepeat;
    
         ColorRGBA color1 = blendedColor.withAlpha(alpha);
         ColorRGBA color2 = blendedColor.withAlpha(alpha);
    
         buffer.vertex(matrix, x1, -halfHeight, z1).texture(u1, 1f).color(color1.getRGB());
         buffer.vertex(matrix, x2, -halfHeight, z2).texture(u2, 1f).color(color2.getRGB());
         buffer.vertex(matrix, x2, halfHeight, z2).texture(u2, 0f).color(color2.getRGB());
         buffer.vertex(matrix, x1, halfHeight, z1).texture(u1, 0f).color(color1.getRGB());
      }
  
      BufferRenderer.drawWithGlobalProgram(buffer.end());
      stack.pop();
   }

   private void drawMarker(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d targetPos = this.getRenderPos(target);
  
      double entX = targetPos.x - camera.getPos().getX();
      double entY = targetPos.y - camera.getPos().getY() + target.getHeight() / 2.0;
      double entZ = targetPos.z - camera.getPos().getZ();
  
      float size = 1.2f * this.size.getCurrentValue();
      float rotationValue = this.markerRotation.getValue();
  
      RenderSystem.enableBlend();
      RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
      RenderSystem.disableDepthTest();
      RenderSystem.disableCull();
  
      ColorRGBA blendedColor = this.getTargetColor();
  
      ms.push();
      ms.translate(entX, entY, entZ);
      ms.multiply(camera.getRotation());
      ms.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Z.rotationDegrees(rotationValue));
  
      int alpha = (int)(this.animation.getValue() * 255 * 0.7f);
      ColorRGBA color = blendedColor.withAlpha(alpha);
  
      Identifier markerTexture = Rockstar.id("icons/marker.png");
  
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
  
      DrawUtility.drawImage(
         ms,
         markerTexture,
         (double)(-size / 2.0f),
         (double)(-size / 2.0f),
         0.0,
         (double)size,
         (double)size,
         color
      );
  
      DrawUtility.drawImage(
         ms,
         markerTexture,
         (double)(-size / 2.0f),
         (double)(-size / 2.0f),
         0.0,
         (double)size,
         (double)size,
         color.withAlpha(alpha * 0.3f)
      );
  
      ms.pop();
  
      RenderSystem.enableDepthTest();
      RenderSystem.enableCull();
      RenderSystem.defaultBlendFunc();
      RenderSystem.disableBlend();
   }

   private void drawCircles(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d cameraPos = camera.getPos();
      Vec3d targetPos = this.getRenderPos(target);
  
      double entX = targetPos.x - cameraPos.getX();
      double entY = targetPos.y - cameraPos.getY();
      double entZ = targetPos.z - cameraPos.getZ();
  
      float movingValue = this.moving.getValue();
      float width = target.getWidth() * 1.45f * this.size.getCurrentValue();
      float baseVal = Math.max(0.5f, 0.7f - 0.1f * this.hurtAnimation.getValue() + 0.1f - 0.1f * this.animation.getValue());
  
      RenderSystem.enableBlend();
      RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
      RenderSystem.disableDepthTest();
      RenderSystem.disableCull();
  
      ColorRGBA blendedColor = this.getTargetColor();
  
      Identifier bloomTexture = Rockstar.id("textures/bloom.png");
      RenderSystem.setShaderTexture(0, bloomTexture);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
  
      int step = 3;
      float size = 0.4f * this.size.getCurrentValue();
      float bigSize = (0.5f + 0.3f) * this.size.getCurrentValue();
  
      for (int i = 0; i < 360; i += step) {
         if ((int)(i / 45.0f) % 2 != 0) {
            double rad = Math.toRadians(i + movingValue);
            float sin = (float)(entX + Math.sin(rad) * width * baseVal);
            float cos = (float)(entZ + Math.cos(rad) * width * baseVal);
        
            double radAngle = Math.toRadians(movingValue);
            float waveValue = (float)((1.0 - Math.cos(radAngle)) / 2.0);
            float yPos = (float)(entY + target.getHeight() * waveValue);
        
            ms.push();
            ms.translate(sin, yPos, cos);
            ms.multiply(camera.getRotation());
        
            int alpha = (int)(this.animation.getValue() * 255);
        
            ColorRGBA color = blendedColor.withAlpha(alpha);
        
            BufferBuilder buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
        
            int bloomAlpha = (int)(alpha * 0.1f);
            ColorRGBA bloomColor = color.withAlpha(bloomAlpha);
        
            DrawUtility.drawImage(
               ms,
               buffer,
               (double)(-bigSize / 2.0f),
               (double)(-bigSize / 2.0f),
               0.0,
               (double)bigSize,
               (double)bigSize,
               bloomColor
            );
        
            BufferRenderer.drawWithGlobalProgram(buffer.end());
        
            buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
        
            DrawUtility.drawImage(
               ms,
               buffer,
               (double)(-size / 2.0f),
               (double)(-size / 2.0f),
               0.0,
               (double)size,
               (double)size,
               color
            );
        
            BufferRenderer.drawWithGlobalProgram(buffer.end());
            ms.pop();
         }
      }
  
      RenderSystem.enableDepthTest();
      RenderSystem.enableCull();
      RenderSystem.defaultBlendFunc();
      RenderSystem.disableBlend();
   }

   private void drawCrystals(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d cameraPos = camera.getPos();
      ColorRGBA color = this.getTargetColor();
      float width = this.prevTarget.getWidth() * 1.5F * this.size.getCurrentValue();
      RenderUtility.prepareMatrices(ms, this.getRenderPos(this.prevTarget));
      BufferBuilder builder = CrystalRenderer.createBuffer();

      for (int i = 0; i < 360; i += 20) {
         float val = 1.2F - 0.5F * this.animation.getValue();
         float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float size = 0.1F * this.size.getCurrentValue();
         ms.push();
         ms.translate(sin, 0.1F + target.getHeight() * Math.abs(MathUtility.sin(i)), cos);
         Vec3d crystalPos = this.getRenderPos(this.prevTarget).add(sin, 1.0, cos);
         Vec3d targetPos = target.getPos().add(0.0, target.getHeight() / 2.0, 0.0);
         Vector3f directionToTarget = new Vector3f(
               (float)(targetPos.x - crystalPos.x), (float)(targetPos.y - crystalPos.y), (float)(targetPos.z - crystalPos.z)
            )
            .normalize();
         Vector3f initialDirection = new Vector3f(0.0F, 1.0F, 0.0F);
         Quaternionf rotation = new Quaternionf().rotationTo(initialDirection, directionToTarget);
         ms.multiply(rotation);
         CrystalRenderer.render(ms, builder, 0.0F, 0.0F, 0.0F, size, color.withAlpha(255.0F * this.animation.getValue()));
         ms.pop();
      }

      BufferRenderer.drawWithGlobalProgram(builder.end());
      Identifier id = Rockstar.id("textures/bloom.png");
      RenderSystem.setShaderTexture(0, id);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
      BufferBuilder buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
      float bigSize = 1.0F;

      for (int i = 0; i < 360; i += 20) {
         float val = 1.2F - 0.5F * this.animation.getValue();
         float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float size = 0.1F;
         ms.push();
         ms.translate(sin, 0.1F + target.getHeight() * Math.abs(MathUtility.sin(i)), cos);
         ms.multiply(camera.getRotation());
         DrawUtility.drawImage(
            ms,
            buffer,
            (double)(-bigSize / 2.0F),
            (double)(-bigSize / 2.0F),
            0.0,
            (double)bigSize,
            (double)bigSize,
            color.withAlpha(255.0F * this.animation.getValue() * 0.2F)
         );
         ms.pop();
      }

      RenderUtility.buildBuffer(buffer);
   }

   private void drawGhosts(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      ColorRGBA color = this.getTargetColor();
      Identifier id = Rockstar.id("textures/bloom.png");
      float width = this.prevTarget.getWidth() * 1.5F * this.size.getCurrentValue();
      RenderSystem.setShaderTexture(0, id);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
      BufferBuilder builder = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
      RenderUtility.prepareMatrices(ms, this.getRenderPos(this.prevTarget));
  
      int step = Math.max(1, 360 / (int)this.ghostCount.getCurrentValue());
      float thicknessMultiplier = this.ghostThickness.getCurrentValue();
  
      int wormTick = 0;
      int wormCD = 0;
      int wormCount = 0;

      for (int i = 0; i < 360; i += step) {
         float size = (0.13F + 0.005F * wormTick) * thicknessMultiplier;
         float bigSize = (0.7F + 0.005F * wormTick) * thicknessMultiplier;
         if (wormCD > 0) {
            wormCD -= step;
         } else {
            wormTick += step;
            if (wormTick > 50) {
               wormCD = 100;
               wormTick = 0;
               wormCount++;
            } else {
               float val = Math.max(0.5F, 1.2F - 0.5F * this.animation.getValue());
               float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 1.0F)) * width * val);
               float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 1.0F)) * width * val);
               ms.push();
               ms.translate(
                  sin,
                  this.prevTarget.getHeight() / 1.5F
                     + this.prevTarget.getHeight() / 3.0F * MathUtility.sin(Math.toRadians(i / 2.0F + this.moving.getValue() / 5.0F)),
                  cos
               );
               ms.multiply(camera.getRotation());
               DrawUtility.drawImage(
                  ms,
                  builder,
                  (double)(-bigSize / 2.0F),
                  (double)(-bigSize / 2.0F),
                  (double)(-size / 2.0F),
                  (double)bigSize,
                  (double)bigSize,
                  color.withAlpha(color.getAlpha() * this.animation.getValue() * 0.05F)
               );
               DrawUtility.drawImage(
                  ms,
                  builder,
                  (double)(-size / 2.0F),
                  (double)(-size / 2.0F),
                  (double)(-size / 2.0F),
                  (double)size,
                  (double)size,
                  color.withAlpha(color.getAlpha() * this.animation.getValue())
               );
               ms.pop();
            }
         }
      }

      BufferRenderer.drawWithGlobalProgram(builder.end());
   }

   private Vec3d getRenderPos(LivingEntity target) {
      float tickDelta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
      return new Vec3d(
         MathHelper.lerp(tickDelta, target.prevX, target.getX()),
         MathHelper.lerp(tickDelta, target.prevY, target.getY()),
         MathHelper.lerp(tickDelta, target.prevZ, target.getZ())
      );
   }

   @Override
   public void tick() {
      super.tick();
   }
}
Бро пофикси пж души там пропадает режим на душ типо ширина и длина их
 
короче добавил новые виды таргет есп (маркер,цепи,круги)и функции по мелочи
ss:
новые функции будут тут как и новй опен сурс клиент
Пожалуйста, авторизуйтесь для просмотра ссылки.


self pasta:
Expand Collapse Copy
package moscow.rockstar.systems.modules.modules.visuals;

import com.mojang.blaze3d.platform.GlStateManager.DstFactor;
import com.mojang.blaze3d.platform.GlStateManager.SrcFactor;
import com.mojang.blaze3d.systems.RenderSystem;
import moscow.rockstar.Rockstar;
import moscow.rockstar.systems.event.EventListener;
import moscow.rockstar.systems.event.impl.render.Render3DEvent;
import moscow.rockstar.systems.modules.api.ModuleCategory;
import moscow.rockstar.systems.modules.api.ModuleInfo;
import moscow.rockstar.systems.modules.impl.BaseModule;
import moscow.rockstar.systems.setting.settings.ColorSetting;
import moscow.rockstar.systems.setting.settings.ModeSetting;
import moscow.rockstar.systems.setting.settings.BooleanSetting;
import moscow.rockstar.systems.setting.settings.SliderSetting;
import moscow.rockstar.utility.animation.base.Animation;
import moscow.rockstar.utility.animation.base.Easing;
import moscow.rockstar.utility.colors.ColorRGBA;
import moscow.rockstar.utility.colors.Colors;
import moscow.rockstar.utility.game.EntityUtility;
import moscow.rockstar.utility.math.MathUtility;
import moscow.rockstar.utility.render.CrystalRenderer;
import moscow.rockstar.utility.render.DrawUtility;
import moscow.rockstar.utility.render.RenderUtility;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormat.DrawMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.HitResult.Type;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;
import net.minecraft.world.RaycastContext.FluidHandling;
import net.minecraft.world.RaycastContext.ShapeType;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;

@ModuleInfo(name = "Target ESP", category = ModuleCategory.VISUALS, desc = "Помечает активную цель")
public class TargetESP extends BaseModule {
   private final ModeSetting mode = new ModeSetting(this, "modules.settings.target_esp.mode");
   private final ModeSetting.Value souls = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.souls");
   private final ModeSetting.Value crystals = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.crystals").select();
   private final ModeSetting.Value chains = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.chains");
   private final ModeSetting.Value circles = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.circles");
   private final ModeSetting.Value marker = new ModeSetting.Value(this.mode, "modules.settings.target_esp.mode.marker");
 
   private final ColorSetting colorTarget = new ColorSetting(this, "color").color(Colors.ACCENT);
   private final BooleanSetting showOnHover = new BooleanSetting(this, "modules.settings.target_esp.show_on_hover");
   private final BooleanSetting changeColorOnDamage = new BooleanSetting(this, "modules.settings.target_esp.change_color_on_damage").enable();
 
   private final SliderSetting speed = new SliderSetting(this, "modules.settings.target_esp.speed").min(0.1f).max(5.0f).step(0.1f).currentValue(0.5f);
   private final SliderSetting size = new SliderSetting(this, "modules.settings.target_esp.size").min(0.5f).max(3.0f).step(0.1f).currentValue(1.5f);
 
   private final SliderSetting ghostCount = new SliderSetting(this, "modules.settings.target_esp.ghost_count", () -> this.souls.isSelected()).min(1.0f).max(50.0f).step(1.0f).currentValue(50.0f);
   private final SliderSetting ghostThickness = new SliderSetting(this, "modules.settings.target_esp.ghost_thickness", () -> this.souls.isSelected()).min(0.1f).max(2.0f).step(0.1f).currentValue(1.7f);
   private final Animation animation = new Animation(300L, 0.0F, Easing.BOTH_CUBIC);
   private final Animation moving = new Animation(70L, 0.0F, Easing.LINEAR);
   private final Animation hurtAnimation = new Animation(200L, 0.0F, Easing.BOTH_CUBIC);
   private final Animation markerRotation = new Animation(50L, 0.0F, Easing.LINEAR);
   private LivingEntity prevTarget;
 
   private float chainRotationAngle = 0f;
   private float prevChainRotationAngle = 0f;
 
   public TargetESP() {
   }
 
   private ColorRGBA getTargetColor() {
      float hitProgress = this.hurtAnimation.getValue();
      ColorRGBA baseColor = this.colorTarget.getColor();
 
      if (this.changeColorOnDamage.isEnabled() && hitProgress > 0) {
         ColorRGBA redColor = new ColorRGBA(255, 0, 0, 255);
         return baseColor.mix(redColor, hitProgress);
      }
 
      return baseColor;
   }
 
   private final EventListener<Render3DEvent> onRender3D = event -> {
      if (EntityUtility.isInGame()) {
         LivingEntity target = null;
   
         if (this.showOnHover.isEnabled()) {
            BaseModule auraModule = Rockstar.getInstance().getModuleManager().getModule("Aura");
            if (auraModule != null && auraModule.isEnabled()) {
               target = Rockstar.getInstance().getTargetManager().getCurrentTarget() instanceof LivingEntity target2 ? target2 : null;
            } else {
               if (mc.crosshairTarget != null && mc.crosshairTarget.getType() == net.minecraft.util.hit.HitResult.Type.ENTITY) {
                  net.minecraft.util.hit.EntityHitResult entityHit = (net.minecraft.util.hit.EntityHitResult) mc.crosshairTarget;
                  if (entityHit.getEntity() instanceof LivingEntity livingEntity && livingEntity != mc.player) {
                     target = livingEntity;
                  }
               }
            }
         } else {
            target = Rockstar.getInstance().getTargetManager().getCurrentTarget() instanceof LivingEntity target2 ? target2 : null;
         }
   
         this.animation.setEasing(Easing.FIGMA_EASE_IN_OUT);
         this.animation.update(target != null);
   
         float speedMultiplier = this.speed.getCurrentValue();
         this.moving.update(this.moving.getValue() + 10.0F * speedMultiplier + 50.0F * speedMultiplier);
         this.markerRotation.update(this.markerRotation.getValue() + 5.0F * speedMultiplier);
   
         this.prevChainRotationAngle = this.chainRotationAngle;
         this.chainRotationAngle += 3.0F * speedMultiplier;
   
         if (target != null && this.prevTarget == target) {
            this.hurtAnimation.update(target.hurtTime > 0);
         } else {
            this.hurtAnimation.update(false);
         }
   
         if (target != null) {
            this.prevTarget = target;
         }

         if (this.prevTarget != null && this.animation.getValue() != 0.0F) {
            MatrixStack ms = event.getMatrices();
            ms.push();
            RenderSystem.enableBlend();
            RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
            RenderSystem.enableDepthTest();
            if (mc.world
                  .raycast(
                     new RaycastContext(mc.gameRenderer.getCamera().getPos(), this.prevTarget.getEyePos(), ShapeType.COLLIDER, FluidHandling.NONE, mc.player)
                  )
                  .getType()
               != Type.MISS) {
               RenderSystem.disableDepthTest();
            }

            RenderSystem.disableCull();
            RenderSystem.depthMask(false);
       
            if (this.chains.isSelected()) {
               this.drawChains(ms, this.prevTarget);
            } else if (this.circles.isSelected()) {
               this.drawCircles(ms, this.prevTarget);
            } else if (this.marker.isSelected()) {
               this.drawMarker(ms, this.prevTarget);
            } else if (this.crystals.isSelected()) {
               this.drawCrystals(ms, this.prevTarget);
            } else {
               this.drawGhosts(ms, this.prevTarget);
            }

            RenderSystem.depthMask(true);
            RenderSystem.setShaderTexture(0, 0);
            RenderSystem.disableBlend();
            RenderSystem.enableCull();
            RenderSystem.disableDepthTest();
            ms.pop();
         }
      }
   };

   private void drawChains(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d targetPos = this.getRenderPos(target);
 
      double centerX = targetPos.x;
      double centerY = targetPos.y + target.getHeight() / 2;
      double centerZ = targetPos.z;
 
      double renderX = centerX - camera.getPos().getX();
      double renderY = centerY - camera.getPos().getY();
      double renderZ = centerZ - camera.getPos().getZ();
 
      this.renderChainCylinder(ms, renderX, renderY, renderZ, 0);
      this.renderChainCylinder(ms, renderX, renderY, renderZ, 90);
   }
 
   private void renderChainCylinder(MatrixStack stack, double x, double y, double z, float offsetAngle) {
      stack.push();
      stack.translate(x, y, z);
 
      float currentAngle = this.chainRotationAngle;
      stack.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Z.rotationDegrees(currentAngle + offsetAngle));
      stack.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_X.rotationDegrees(currentAngle + offsetAngle));
 
      float radius = this.prevTarget.getWidth() * 1.5f * this.size.getCurrentValue();
      int segments = 60;
 
      ColorRGBA blendedColor = this.getTargetColor();
      int alpha = (int)(this.animation.getValue() * 255);
 
      Identifier chainTexture = Rockstar.id("icons/chain.png");
      RenderSystem.setShaderTexture(0, chainTexture);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
 
      Matrix4f matrix = stack.peek().getPositionMatrix();
      BufferBuilder buffer = Tessellator.getInstance().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
 
      float textureRepeat = 4.0f;
      float chainHeight = this.prevTarget.getHeight() * 0.8f * this.size.getCurrentValue();
      float halfHeight = chainHeight / 2;
 
      for (int i = 0; i < segments; i++) {
         float angle1 = (float) (2 * Math.PI * i / segments);
         float angle2 = (float) (2 * Math.PI * (i + 1) / segments);
   
         float x1 = (float) (Math.cos(angle1) * radius);
         float z1 = (float) (Math.sin(angle1) * radius);
         float x2 = (float) (Math.cos(angle2) * radius);
         float z2 = (float) (Math.sin(angle2) * radius);
   
         float u1 = (float) i / segments * textureRepeat;
         float u2 = (float) (i + 1) / segments * textureRepeat;
   
         ColorRGBA color1 = blendedColor.withAlpha(alpha);
         ColorRGBA color2 = blendedColor.withAlpha(alpha);
   
         buffer.vertex(matrix, x1, -halfHeight, z1).texture(u1, 1f).color(color1.getRGB());
         buffer.vertex(matrix, x2, -halfHeight, z2).texture(u2, 1f).color(color2.getRGB());
         buffer.vertex(matrix, x2, halfHeight, z2).texture(u2, 0f).color(color2.getRGB());
         buffer.vertex(matrix, x1, halfHeight, z1).texture(u1, 0f).color(color1.getRGB());
      }
 
      BufferRenderer.drawWithGlobalProgram(buffer.end());
      stack.pop();
   }

   private void drawMarker(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d targetPos = this.getRenderPos(target);
 
      double entX = targetPos.x - camera.getPos().getX();
      double entY = targetPos.y - camera.getPos().getY() + target.getHeight() / 2.0;
      double entZ = targetPos.z - camera.getPos().getZ();
 
      float size = 1.2f * this.size.getCurrentValue();
      float rotationValue = this.markerRotation.getValue();
 
      RenderSystem.enableBlend();
      RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
      RenderSystem.disableDepthTest();
      RenderSystem.disableCull();
 
      ColorRGBA blendedColor = this.getTargetColor();
 
      ms.push();
      ms.translate(entX, entY, entZ);
      ms.multiply(camera.getRotation());
      ms.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Z.rotationDegrees(rotationValue));
 
      int alpha = (int)(this.animation.getValue() * 255 * 0.7f);
      ColorRGBA color = blendedColor.withAlpha(alpha);
 
      Identifier markerTexture = Rockstar.id("icons/marker.png");
 
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
 
      DrawUtility.drawImage(
         ms,
         markerTexture,
         (double)(-size / 2.0f),
         (double)(-size / 2.0f),
         0.0,
         (double)size,
         (double)size,
         color
      );
 
      DrawUtility.drawImage(
         ms,
         markerTexture,
         (double)(-size / 2.0f),
         (double)(-size / 2.0f),
         0.0,
         (double)size,
         (double)size,
         color.withAlpha(alpha * 0.3f)
      );
 
      ms.pop();
 
      RenderSystem.enableDepthTest();
      RenderSystem.enableCull();
      RenderSystem.defaultBlendFunc();
      RenderSystem.disableBlend();
   }

   private void drawCircles(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d cameraPos = camera.getPos();
      Vec3d targetPos = this.getRenderPos(target);
 
      double entX = targetPos.x - cameraPos.getX();
      double entY = targetPos.y - cameraPos.getY();
      double entZ = targetPos.z - cameraPos.getZ();
 
      float movingValue = this.moving.getValue();
      float width = target.getWidth() * 1.45f * this.size.getCurrentValue();
      float baseVal = Math.max(0.5f, 0.7f - 0.1f * this.hurtAnimation.getValue() + 0.1f - 0.1f * this.animation.getValue());
 
      RenderSystem.enableBlend();
      RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE);
      RenderSystem.disableDepthTest();
      RenderSystem.disableCull();
 
      ColorRGBA blendedColor = this.getTargetColor();
 
      Identifier bloomTexture = Rockstar.id("textures/bloom.png");
      RenderSystem.setShaderTexture(0, bloomTexture);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
 
      int step = 3;
      float size = 0.4f * this.size.getCurrentValue();
      float bigSize = (0.5f + 0.3f) * this.size.getCurrentValue();
 
      for (int i = 0; i < 360; i += step) {
         if ((int)(i / 45.0f) % 2 != 0) {
            double rad = Math.toRadians(i + movingValue);
            float sin = (float)(entX + Math.sin(rad) * width * baseVal);
            float cos = (float)(entZ + Math.cos(rad) * width * baseVal);
       
            double radAngle = Math.toRadians(movingValue);
            float waveValue = (float)((1.0 - Math.cos(radAngle)) / 2.0);
            float yPos = (float)(entY + target.getHeight() * waveValue);
       
            ms.push();
            ms.translate(sin, yPos, cos);
            ms.multiply(camera.getRotation());
       
            int alpha = (int)(this.animation.getValue() * 255);
       
            ColorRGBA color = blendedColor.withAlpha(alpha);
       
            BufferBuilder buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
       
            int bloomAlpha = (int)(alpha * 0.1f);
            ColorRGBA bloomColor = color.withAlpha(bloomAlpha);
       
            DrawUtility.drawImage(
               ms,
               buffer,
               (double)(-bigSize / 2.0f),
               (double)(-bigSize / 2.0f),
               0.0,
               (double)bigSize,
               (double)bigSize,
               bloomColor
            );
       
            BufferRenderer.drawWithGlobalProgram(buffer.end());
       
            buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
       
            DrawUtility.drawImage(
               ms,
               buffer,
               (double)(-size / 2.0f),
               (double)(-size / 2.0f),
               0.0,
               (double)size,
               (double)size,
               color
            );
       
            BufferRenderer.drawWithGlobalProgram(buffer.end());
            ms.pop();
         }
      }
 
      RenderSystem.enableDepthTest();
      RenderSystem.enableCull();
      RenderSystem.defaultBlendFunc();
      RenderSystem.disableBlend();
   }

   private void drawCrystals(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      Vec3d cameraPos = camera.getPos();
      ColorRGBA color = this.getTargetColor();
      float width = this.prevTarget.getWidth() * 1.5F * this.size.getCurrentValue();
      RenderUtility.prepareMatrices(ms, this.getRenderPos(this.prevTarget));
      BufferBuilder builder = CrystalRenderer.createBuffer();

      for (int i = 0; i < 360; i += 20) {
         float val = 1.2F - 0.5F * this.animation.getValue();
         float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float size = 0.1F * this.size.getCurrentValue();
         ms.push();
         ms.translate(sin, 0.1F + target.getHeight() * Math.abs(MathUtility.sin(i)), cos);
         Vec3d crystalPos = this.getRenderPos(this.prevTarget).add(sin, 1.0, cos);
         Vec3d targetPos = target.getPos().add(0.0, target.getHeight() / 2.0, 0.0);
         Vector3f directionToTarget = new Vector3f(
               (float)(targetPos.x - crystalPos.x), (float)(targetPos.y - crystalPos.y), (float)(targetPos.z - crystalPos.z)
            )
            .normalize();
         Vector3f initialDirection = new Vector3f(0.0F, 1.0F, 0.0F);
         Quaternionf rotation = new Quaternionf().rotationTo(initialDirection, directionToTarget);
         ms.multiply(rotation);
         CrystalRenderer.render(ms, builder, 0.0F, 0.0F, 0.0F, size, color.withAlpha(255.0F * this.animation.getValue()));
         ms.pop();
      }

      BufferRenderer.drawWithGlobalProgram(builder.end());
      Identifier id = Rockstar.id("textures/bloom.png");
      RenderSystem.setShaderTexture(0, id);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
      BufferBuilder buffer = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
      float bigSize = 1.0F;

      for (int i = 0; i < 360; i += 20) {
         float val = 1.2F - 0.5F * this.animation.getValue();
         float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 0.3F)) * width * val);
         float size = 0.1F;
         ms.push();
         ms.translate(sin, 0.1F + target.getHeight() * Math.abs(MathUtility.sin(i)), cos);
         ms.multiply(camera.getRotation());
         DrawUtility.drawImage(
            ms,
            buffer,
            (double)(-bigSize / 2.0F),
            (double)(-bigSize / 2.0F),
            0.0,
            (double)bigSize,
            (double)bigSize,
            color.withAlpha(255.0F * this.animation.getValue() * 0.2F)
         );
         ms.pop();
      }

      RenderUtility.buildBuffer(buffer);
   }

   private void drawGhosts(MatrixStack ms, LivingEntity target) {
      Camera camera = mc.gameRenderer.getCamera();
      ColorRGBA color = this.getTargetColor();
      Identifier id = Rockstar.id("textures/bloom.png");
      float width = this.prevTarget.getWidth() * 1.5F * this.size.getCurrentValue();
      RenderSystem.setShaderTexture(0, id);
      RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
      BufferBuilder builder = RenderSystem.renderThreadTesselator().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
      RenderUtility.prepareMatrices(ms, this.getRenderPos(this.prevTarget));
 
      int step = Math.max(1, 360 / (int)this.ghostCount.getCurrentValue());
      float thicknessMultiplier = this.ghostThickness.getCurrentValue();
 
      int wormTick = 0;
      int wormCD = 0;
      int wormCount = 0;

      for (int i = 0; i < 360; i += step) {
         float size = (0.13F + 0.005F * wormTick) * thicknessMultiplier;
         float bigSize = (0.7F + 0.005F * wormTick) * thicknessMultiplier;
         if (wormCD > 0) {
            wormCD -= step;
         } else {
            wormTick += step;
            if (wormTick > 50) {
               wormCD = 100;
               wormTick = 0;
               wormCount++;
            } else {
               float val = Math.max(0.5F, 1.2F - 0.5F * this.animation.getValue());
               float sin = (float)(MathUtility.sin((float)Math.toRadians(i + this.moving.getValue() * 1.0F)) * width * val);
               float cos = (float)(MathUtility.cos((float)Math.toRadians(i + this.moving.getValue() * 1.0F)) * width * val);
               ms.push();
               ms.translate(
                  sin,
                  this.prevTarget.getHeight() / 1.5F
                     + this.prevTarget.getHeight() / 3.0F * MathUtility.sin(Math.toRadians(i / 2.0F + this.moving.getValue() / 5.0F)),
                  cos
               );
               ms.multiply(camera.getRotation());
               DrawUtility.drawImage(
                  ms,
                  builder,
                  (double)(-bigSize / 2.0F),
                  (double)(-bigSize / 2.0F),
                  (double)(-size / 2.0F),
                  (double)bigSize,
                  (double)bigSize,
                  color.withAlpha(color.getAlpha() * this.animation.getValue() * 0.05F)
               );
               DrawUtility.drawImage(
                  ms,
                  builder,
                  (double)(-size / 2.0F),
                  (double)(-size / 2.0F),
                  (double)(-size / 2.0F),
                  (double)size,
                  (double)size,
                  color.withAlpha(color.getAlpha() * this.animation.getValue())
               );
               ms.pop();
            }
         }
      }

      BufferRenderer.drawWithGlobalProgram(builder.end());
   }

   private Vec3d getRenderPos(LivingEntity target) {
      float tickDelta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
      return new Vec3d(
         MathHelper.lerp(tickDelta, target.prevX, target.getX()),
         MathHelper.lerp(tickDelta, target.prevY, target.getY()),
         MathHelper.lerp(tickDelta, target.prevZ, target.getZ())
      );
   }

   @Override
   public void tick() {
      super.tick();
   }
}
нормас
 
Назад
Сверху Снизу