| 1 | /*
|
| 2 | * This file is part of the Combatant Client distribution.
|
| 3 | * Copyright (c) 2026 pivosos2007.
|
| 4 | *
|
| 5 | * Licensed under the GNU General Public License v3.0.
|
| 6 | */
|
| 7 |
|
| 8 | package combatant.client.features.module.modules.visuals;
|
| 9 |
|
| 10 | import net.minecraft.client.Minecraft;
|
| 11 | import net.minecraft.resources.Identifier;
|
| 12 | import net.minecraft.util.Mth;
|
| 13 | import net.minecraft.world.entity.Entity;
|
| 14 | import net.minecraft.world.entity.LivingEntity;
|
| 15 | import net.minecraft.world.entity.player.Player;
|
| 16 | import net.minecraft.world.phys.Vec3;
|
| 17 | import org.joml.Quaternionf;
|
| 18 | import org.joml.Vector3f;
|
| 19 | import combatant.client.config.common.CommonSettingSchemas;
|
| 20 | import combatant.client.config.values.BooleanValue;
|
| 21 | import combatant.client.config.values.ModeValue;
|
| 22 | import combatant.client.config.values.NumberValue;
|
| 23 | import combatant.client.config.values.RGBAColorValue;
|
| 24 | import combatant.client.features.module.Module;
|
| 25 | import combatant.client.features.module.ModuleCategory;
|
| 26 | import combatant.client.features.module.ModuleInfo;
|
| 27 | import combatant.client.features.module.WorldPhase;
|
| 28 | import combatant.client.features.relations.CategoryService;
|
| 29 | import combatant.client.mixininterface.IEntity;
|
| 30 | import combatant.client.render.engine.RenderState;
|
| 31 | import combatant.client.render.engine.TextureStorage;
|
| 32 | import combatant.client.render.engine.animation.AnimationUtility;
|
| 33 | import combatant.client.render.engine.animation.AnimatedRenderColors;
|
| 34 | import combatant.client.render.engine.math.RenderMath;
|
| 35 | import combatant.client.render.engine.pipeline.CombatantRenderPipelines;
|
| 36 | import combatant.client.render.engine.renderer.Renderer3D;
|
| 37 | import combatant.client.render.effects.particle.ParticleLayoutDescriptor;
|
| 38 | import combatant.client.render.effects.particle.ParticleLayoutEvaluator;
|
| 39 | import combatant.client.render.effects.particle.ParticleLayoutSample;
|
| 40 | import combatant.client.render.engine.uniform.MeshBuilder;
|
| 41 | import combatant.client.util.target.TargetingUtil;
|
| 42 |
|
| 43 | import java.util.ArrayList;
|
| 44 | import java.util.List;
|
| 45 | import java.util.function.IntFunction;
|
| 46 |
|
| 47 | //todo Description
|
| 48 | @ModuleInfo(id = "targetesp", displayName = "TargetESP", aliases = {"target", "targetrender"}, category = ModuleCategory.VISUALS)
|
| 49 | public class TargetESP extends Module {
|
| 50 |
|
| 51 | private static final String SETTING_MODE = "mode";
|
| 52 | private static final String SETTING_COLOR = "color";
|
| 53 | private static final String SETTING_COLOR_MODE = "color_mode";
|
| 54 | private static final String SETTING_COLOR_SPEED = "color_speed";
|
| 55 | private static final String SETTING_COLOR_PHASE = "color_phase";
|
| 56 | private static final String SETTING_COLOR_SPREAD = "color_spread";
|
| 57 | private static final String SETTING_COLOR2 = "color2";
|
| 58 | private static final String SETTING_USE_RELATION_COLORS = "use_relation_colors";
|
| 59 | private static final String SETTING_RELATION_COLOR_MIX = "relation_color_mix";
|
| 60 | private static final String SETTING_PLAYERS_ONLY = "players_only";
|
| 61 | private static final String SETTING_CROSSHAIR_TARGETS = "crosshair_targets";
|
| 62 | private static final String SETTING_ALPHA_ANIMATION_SPEED = "alpha_animation_speed";
|
| 63 | private static final String SETTING_ESP_LENGTH = "esp_length";
|
| 64 | private static final String SETTING_ESP_FACTOR = "esp_factor";
|
| 65 | private static final String SETTING_ESP_SHAKING = "esp_shaking";
|
| 66 | private static final String SETTING_ESP_AMPLITUDE = "esp_amplitude";
|
| 67 | private static final String SETTING_CAPTURE_SPIN_SPEED = "capture_spin_speed";
|
| 68 | private static final String SETTING_CRYSTAL_HIT_RED = "crystal_hit_red";
|
| 69 | private static final String SETTING_LAYOUT_DENSITY = "layout_density";
|
| 70 | private static final String SETTING_LAYOUT_SCALE = "layout_scale";
|
| 71 | private static final String SETTING_LAYOUT_SPEED = "layout_speed";
|
| 72 | private static final String SETTING_LAYOUT_RADIUS_SCALE = "layout_radius_scale";
|
| 73 | private static final Identifier GHOST_PARTICLE_TEXTURE = TextureStorage.FIRE_FLY;
|
| 74 | private static final Identifier CAPTURE_MARK_TEXTURE = TextureStorage.CAPTURE;
|
| 75 | private static final Identifier CRYSTAL_BLOOM = TextureStorage.BLOOM;
|
| 76 | private static final float CRYSTAL_BASE_SIZE = 0.05f;
|
| 77 | private static final int CRYSTAL_SIDES = 8;
|
| 78 | private static final float ALPHA_TICK_DT = 1.0f / 20.0f;
|
| 79 | private static final float ALPHA_SNAP_EPSILON = 0.02f;
|
| 80 | private static float prevCircleStep;
|
| 81 | private static float circleStep;
|
| 82 | private static double captureValue = 1.0;
|
| 83 | private static double prevCaptureValue;
|
| 84 | private static double captureSpeed = 1.0;
|
| 85 | private static double captureSpeedScale = 1.0;
|
| 86 | private static boolean captureFlipSpeed;
|
| 87 | private final Minecraft mc = Minecraft.getInstance();
|
| 88 | private final ModeValue espMode = modeSetting(
|
| 89 | "targetEspMode",
|
| 90 | SETTING_MODE,
|
| 91 | "ghosts",
|
| 92 | "ghosts", "ring", "capture_mark", "crystals", "helix", "orbit", "runes", "lightning", "pulse"
|
| 93 | );
|
| 94 | private final RGBAColorValue colorValue = color("targetEspColor", SETTING_COLOR, "#FFFF5555");
|
| 95 | private final ModeValue colorMode = visibleWhen(modeSetting(
|
| 96 | "targetEspColorMode",
|
| 97 | SETTING_COLOR_MODE,
|
| 98 | "Static",
|
| 99 | "Static", "Rainbow", "LightRainbow", "Sky", "Fade", "DoubleColor", "Analogous", "Theme"
|
| 100 | ), () -> true);
|
| 101 | private final NumberValue<Integer> colorSpeed =
|
| 102 | visibleWhen(num("targetEspColorSpeed", SETTING_COLOR_SPEED, 18, 2, 54), () -> true);
|
| 103 | private final NumberValue<Integer> colorPhase =
|
| 104 | num("targetEspColorPhase", SETTING_COLOR_PHASE, 0, 0, 360);
|
| 105 | private final NumberValue<Integer> colorSpread =
|
| 106 | num("targetEspColorSpread", SETTING_COLOR_SPREAD, 90, -720, 720);
|
| 107 | private final RGBAColorValue colorValue2 =
|
| 108 | visibleWhen(color("targetEspColor2", SETTING_COLOR2, "#FF55FFFF"), this::usesSecondaryColor);
|
| 109 | private final BooleanValue useRelationColors =
|
| 110 | boolCommon("targetEspUseRelationColors", SETTING_USE_RELATION_COLORS, CommonSettingSchemas.PLAYER_USE_RELATIONS, false);
|
| 111 | private final NumberValue<Float> relationColorMix =
|
| 112 | visibleWhen(num("targetEspRelationColorMix", SETTING_RELATION_COLOR_MIX, 1.0f, 0.0f, 1.0f), useRelationColors::get);
|
| 113 | private final BooleanValue playersOnly =
|
| 114 | bool("targetEspPlayersOnly", SETTING_PLAYERS_ONLY, false);
|
| 115 | private final BooleanValue crosshairTargets =
|
| 116 | bool("targetEspCrosshairTargets", SETTING_CROSSHAIR_TARGETS, true);
|
| 117 | private final NumberValue<Float> alphaAnimationSpeed =
|
| 118 | num("targetEspAlphaAnimationSpeed", SETTING_ALPHA_ANIMATION_SPEED, 8.0f, 2.0f, 10.0f);
|
| 119 | private final NumberValue<Integer> espLength =
|
| 120 | visibleWhen(num("targetEspLength", SETTING_ESP_LENGTH, 14, 1, 40), this::isGhostMode);
|
| 121 | private final NumberValue<Integer> espFactor =
|
| 122 | visibleWhen(num("targetEspFactor", SETTING_ESP_FACTOR, 8, 1, 20), this::isGhostMode);
|
| 123 | private final NumberValue<Float> espShaking =
|
| 124 | visibleWhen(num("targetEspShaking", SETTING_ESP_SHAKING, 1.8f, 1.5f, 10f), this::isGhostMode);
|
| 125 | private final NumberValue<Float> espAmplitude =
|
| 126 | visibleWhen(num("targetEspAmplitude", SETTING_ESP_AMPLITUDE, 3f, 0.1f, 8f), this::isGhostMode);
|
| 127 | private final NumberValue<Float> captureSpinSpeed =
|
| 128 | visibleWhen(num("targetEspCaptureSpinSpeed", SETTING_CAPTURE_SPIN_SPEED, 1.0f, 0.2f, 4.0f), this::isCaptureMarkMode);
|
| 129 | private final BooleanValue crystalHitRed =
|
| 130 | visibleWhen(bool("targetEspCrystalHitRed", SETTING_CRYSTAL_HIT_RED, true), this::isCrystalsMode);
|
| 131 | private final NumberValue<Integer> layoutDensity =
|
| 132 | visibleWhen(num("targetEspLayoutDensity", SETTING_LAYOUT_DENSITY, 72, 24, 192), this::isProceduralLayoutMode);
|
| 133 | private final NumberValue<Float> layoutScale =
|
| 134 | visibleWhen(num("targetEspLayoutScale", SETTING_LAYOUT_SCALE, 0.095f, 0.03f, 0.24f), this::isProceduralLayoutMode);
|
| 135 | private final NumberValue<Float> layoutSpeed =
|
| 136 | visibleWhen(num("targetEspLayoutSpeed", SETTING_LAYOUT_SPEED, 1.0f, 0.1f, 4.0f), this::isProceduralLayoutMode);
|
| 137 | private final NumberValue<Float> layoutRadiusScale =
|
| 138 | visibleWhen(num("targetEspLayoutRadiusScale", SETTING_LAYOUT_RADIUS_SCALE, 1.45f, 0.6f, 2.8f), this::isProceduralLayoutMode);
|
| 139 | private final List<CrystalInstance> crystalList = new ArrayList<>();
|
| 140 | private LivingEntity target;
|
| 141 | private LivingEntity renderTarget;
|
| 142 | private float targetAlpha;
|
| 143 | private Entity lastCrystalTarget;
|
| 144 | private float crystalRotationAngle;
|
| 145 |
|
| 146 | private static void tickTargetEsp() {
|
| 147 | prevCircleStep = circleStep;
|
| 148 | circleStep += 0.15f;
|
| 149 |
|
| 150 | prevCaptureValue = captureValue;
|
| 151 | captureValue += captureSpeed * captureSpeedScale;
|
| 152 | if (captureSpeed > 25.0) captureFlipSpeed = true;
|
| 153 | if (captureSpeed < -25.0) captureFlipSpeed = false;
|
| 154 | captureSpeed = captureFlipSpeed
|
| 155 | ? captureSpeed - 0.5 * captureSpeedScale
|
| 156 | : captureSpeed + 0.5 * captureSpeedScale;
|
| 157 | }
|
| 158 |
|
| 159 | private static void setCaptureSpeedScale(float scale) {
|
| 160 | if (scale <= 0f) {
|
| 161 | captureSpeedScale = 0.05;
|
| 162 | } else {
|
| 163 | captureSpeedScale = scale;
|
| 164 | }
|
| 165 | }
|
| 166 |
|
| 167 | private static void drawOldTargetEsp(Renderer3D renderer, Entity target, float tickDelta, IntFunction<Integer> palette) {
|
| 168 | if (renderer == null || target == null) return;
|
| 169 | double cs = prevCircleStep + (circleStep - prevCircleStep) * tickDelta;
|
| 170 | double prevSinAnim = absSinAnimation(cs - 0.45f);
|
| 171 | double sinAnim = absSinAnimation(cs);
|
| 172 | Vec3 pos = RenderMath.getLerpedPos(target, tickDelta);
|
| 173 | double x = pos.x;
|
| 174 | double y = pos.y + prevSinAnim * target.getBbHeight();
|
| 175 | double z = pos.z;
|
| 176 | double nextY = pos.y + sinAnim * target.getBbHeight();
|
| 177 |
|
| 178 | MeshBuilder mesh = renderer.tris();
|
| 179 |
|
| 180 | final int segments = 96;
|
| 181 | final double step = Math.PI * 2.0 / segments;
|
| 182 | final double radius = target.getBbWidth() * 0.8;
|
| 183 |
|
| 184 | for (int i = 0; i < segments; i++) {
|
| 185 | double a0 = i * step;
|
| 186 | double a1 = (i + 1) * step;
|
| 187 | float cos = (float) (x + Math.cos(a0) * radius);
|
| 188 | float sin = (float) (z + Math.sin(a0) * radius);
|
| 189 | float cosNext = (float) (x + Math.cos(a1) * radius);
|
| 190 | float sinNext = (float) (z + Math.sin(a1) * radius);
|
| 191 |
|
| 192 | int idx0 = (int) Math.round(i * (360.0 / segments));
|
| 193 | int idx1 = (int) Math.round((i + 1) * (360.0 / segments));
|
| 194 | int cTop0 = applyOpacity(palette.apply(idx0), 170.0f / 255.0f);
|
| 195 | int cTop1 = applyOpacity(palette.apply(idx1), 170.0f / 255.0f);
|
| 196 | int cBottom0 = applyOpacity(palette.apply(idx0), 0.0f);
|
| 197 | int cBottom1 = applyOpacity(palette.apply(idx1), 0.0f);
|
| 198 |
|
| 199 | mesh.ensureQuadCapacity();
|
| 200 | int i1 = addVertex(mesh, cos, nextY, sin, cTop0);
|
| 201 | int i2 = addVertex(mesh, cosNext, nextY, sinNext, cTop1);
|
| 202 | int i3 = addVertex(mesh, cosNext, y, sinNext, cBottom1);
|
| 203 | int i4 = addVertex(mesh, cos, y, sin, cBottom0);
|
| 204 | mesh.quad(i1, i2, i3, i4);
|
| 205 | }
|
| 206 |
|
| 207 | }
|
| 208 |
|
| 209 | private static void renderGhosts(Renderer3D renderer,
|
| 210 | int espLength, int factor, float shaking, float amplitude,
|
| 211 | Entity target, float tickDelta, IntFunction<Integer> palette) {
|
| 212 | Minecraft mc = Minecraft.getInstance();
|
| 213 | if (renderer == null || mc == null || mc.player == null) return;
|
| 214 |
|
| 215 | Vec3 pos = RenderMath.getLerpedPos(target, tickDelta);
|
| 216 | double tPosX = pos.x;
|
| 217 | double tPosY = pos.y;
|
| 218 | double tPosZ = pos.z;
|
| 219 | float iAge = (float) interpolate(target.tickCount - 1, target.tickCount, tickDelta);
|
| 220 |
|
| 221 | MeshBuilder mesh = renderer.batchTextured(
|
| 222 | CombatantRenderPipelines.WORLD_TEXTURED_ADDITIVE,
|
| 223 | GHOST_PARTICLE_TEXTURE,
|
| 224 | Renderer3D.DepthMode.MAIN
|
| 225 | );
|
| 226 | if (mesh == null) return;
|
| 227 |
|
| 228 | for (int j = 0; j < 3; j++) {
|
| 229 | for (int i = 0; i <= espLength; i++) {
|
| 230 | double radians = Math.toRadians((((float) i / 1.5f + iAge) * factor + (j * 120)) % (factor * 360));
|
| 231 | double sinQuad = Math.sin(Math.toRadians(iAge * 2.5f + i * (j + 1)) * amplitude) / shaking;
|
| 232 |
|
| 233 | float offset = ((float) i / espLength);
|
| 234 | int color = applyOpacity(palette.apply((int) (180 * offset)), offset);
|
| 235 | float scale = Math.max(0.24f * (offset), 0.2f);
|
| 236 |
|
| 237 | double cx = tPosX + Math.cos(radians) * target.getBbWidth();
|
| 238 | double cy = tPosY + 1 + sinQuad;
|
| 239 | double cz = tPosZ + Math.sin(radians) * target.getBbWidth();
|
| 240 |
|
| 241 | addBillboardQuad(mesh, cx, cy, cz, scale, color);
|
| 242 | }
|
| 243 | }
|
| 244 | }
|
| 245 |
|
| 246 | private static void renderCaptureMark(Renderer3D renderer,
|
| 247 | Entity target,
|
| 248 | float tickDelta,
|
| 249 | IntFunction<Integer> palette) {
|
| 250 | if (renderer == null) return;
|
| 251 | Vec3 pos = RenderMath.getLerpedPos(target, tickDelta);
|
| 252 | double tPosX = pos.x;
|
| 253 | double tPosY = pos.y;
|
| 254 | double tPosZ = pos.z;
|
| 255 |
|
| 256 | MeshBuilder mesh = renderer.batchTextured(
|
| 257 | CombatantRenderPipelines.WORLD_TEXTURED_ADDITIVE,
|
| 258 | CAPTURE_MARK_TEXTURE,
|
| 259 | Renderer3D.DepthMode.MAIN
|
| 260 | );
|
| 261 | if (mesh == null) return;
|
| 262 |
|
| 263 | float angle = interpolateFloat((float) prevCaptureValue, (float) captureValue, tickDelta);
|
| 264 | float size = 0.75f;
|
| 265 |
|
| 266 | double cy = tPosY + target.getEyeHeight(target.getPose()) / 2f;
|
| 267 |
|
| 268 | addRotatedBillboard(mesh, tPosX, cy, tPosZ, size, angle, palette);
|
| 269 | }
|
| 270 |
|
| 271 | private static void appendCrystalGeometry(MeshBuilder mesh,
|
| 272 | Vec3 targetPos,
|
| 273 | CrystalInstance crystal,
|
| 274 | float orbitYawRad,
|
| 275 | float scale,
|
| 276 | int argb,
|
| 277 | boolean filled) {
|
| 278 | if (mesh == null || crystal == null || targetPos == null) {
|
| 279 | return;
|
| 280 | }
|
| 281 |
|
| 282 | float s = CRYSTAL_BASE_SIZE * scale;
|
| 283 | float hPrism = s;
|
| 284 | float hPyramid = s * 1.5f;
|
| 285 |
|
| 286 | Vector3f[] topVertices = new Vector3f[CRYSTAL_SIDES];
|
| 287 | Vector3f[] bottomVertices = new Vector3f[CRYSTAL_SIDES];
|
| 288 | for (int i = 0; i < CRYSTAL_SIDES; i++) {
|
| 289 | float angle = (float) (2.0 * Math.PI * i / CRYSTAL_SIDES);
|
| 290 | float x = (float) (s * Math.cos(angle));
|
| 291 | float z = (float) (s * Math.sin(angle));
|
| 292 | topVertices[i] = new Vector3f(x, hPrism * 0.5f, z);
|
| 293 | bottomVertices[i] = new Vector3f(x, -hPrism * 0.5f, z);
|
| 294 | }
|
| 295 |
|
| 296 | Vector3f topPeak = new Vector3f(0.0f, hPrism * 0.5f + hPyramid, 0.0f);
|
| 297 | Vector3f bottomPeak = new Vector3f(0.0f, -hPrism * 0.5f - hPyramid, 0.0f);
|
| 298 |
|
| 299 | if (filled) {
|
| 300 | for (int i = 0; i < CRYSTAL_SIDES; i++) {
|
| 301 | Vector3f v1 = transformCrystalVertex(bottomVertices[i], crystal, orbitYawRad, targetPos);
|
| 302 | Vector3f v2 = transformCrystalVertex(bottomVertices[(i + 1) % CRYSTAL_SIDES], crystal, orbitYawRad, targetPos);
|
| 303 | Vector3f v3 = transformCrystalVertex(topVertices[(i + 1) % CRYSTAL_SIDES], crystal, orbitYawRad, targetPos);
|
| 304 | Vector3f v4 = transformCrystalVertex(topVertices[i], crystal, orbitYawRad, targetPos);
|
| 305 | addTriangle(mesh, v1, v2, v3, argb);
|
| 306 | addTriangle(mesh, v1, v3, v4, argb);
|
| 307 | }
|
| 308 | for (int i = 0; i < CRYSTAL_SIDES; i++) {
|
| 309 | Vector3f v1 = transformCrystalVertex(topPeak, crystal, orbitYawRad, targetPos);
|
| 310 | Vector3f v2 = transformCrystalVertex(topVertices[i], crystal, orbitYawRad, targetPos);
|
| 311 | Vector3f v3 = transformCrystalVertex(topVertices[(i + 1) % CRYSTAL_SIDES], crystal, orbitYawRad, targetPos);
|
| 312 | addTriangle(mesh, v1, v2, v3, argb);
|
| 313 | }
|
| 314 | for (int i = 0; i < CRYSTAL_SIDES; i++) {
|
| 315 | Vector3f v1 = transformCrystalVertex(bottomPeak, crystal, orbitYawRad, targetPos);
|
| 316 | Vector3f v2 = transformCrystalVertex(bottomVertices[(i + 1) % CRYSTAL_SIDES], crystal, orbitYawRad, targetPos);
|
| 317 | Vector3f v3 = transformCrystalVertex(bottomVertices[i], crystal, orbitYawRad, targetPos);
|
| 318 | addTriangle(mesh, v1, v2, v3, argb);
|
| 319 | }
|
| 320 | return;
|
| 321 | }
|
| 322 |
|
| 323 | for (int i = 0; i < CRYSTAL_SIDES; i++) {
|
| 324 | Vector3f bottomA = transformCrystalVertex(bottomVertices[i], crystal, orbitYawRad, targetPos);
|
| 325 | Vector3f bottomB = transformCrystalVertex(bottomVertices[(i + 1) % CRYSTAL_SIDES], crystal, orbitYawRad, targetPos);
|
| 326 | Vector3f topA = transformCrystalVertex(topVertices[i], crystal, orbitYawRad, targetPos);
|
| 327 | Vector3f topB = transformCrystalVertex(topVertices[(i + 1) % CRYSTAL_SIDES], crystal, orbitYawRad, targetPos);
|
| 328 | addLine(mesh, bottomA, bottomB, argb);
|
| 329 | addLine(mesh, topA, topB, argb);
|
| 330 | addLine(mesh, bottomA, topA, argb);
|
| 331 | addLine(mesh, transformCrystalVertex(topPeak, crystal, orbitYawRad, targetPos), topA, argb);
|
| 332 | addLine(mesh, transformCrystalVertex(bottomPeak, crystal, orbitYawRad, targetPos), bottomA, argb);
|
| 333 | }
|
| 334 | }
|
| 335 |
|
| 336 | private static Vector3f transformCrystalVertex(Vector3f vertex,
|
| 337 | CrystalInstance crystal,
|
| 338 | float orbitYawRad,
|
| 339 | Vec3 targetPos) {
|
| 340 | Vector3f transformed = new Vector3f(vertex).mul(crystal.pulsation());
|
| 341 | transformed.rotateX((float) Math.toRadians(crystal.rotation.x));
|
| 342 | transformed.rotateY((float) Math.toRadians(crystal.rotation.y + crystal.selfRotationDeg()));
|
| 343 | transformed.rotateZ((float) Math.toRadians(crystal.rotation.z));
|
| 344 | transformed.add((float) crystal.position.x, (float) crystal.position.y, (float) crystal.position.z);
|
| 345 | transformed.rotateY(orbitYawRad);
|
| 346 | transformed.add((float) targetPos.x, (float) targetPos.y, (float) targetPos.z);
|
| 347 | return transformed;
|
| 348 | }
|
| 349 |
|
| 350 | private static void appendBloomSphere(MeshBuilder mesh,
|
| 351 | Vec3 targetPos,
|
| 352 | CrystalInstance crystal,
|
| 353 | float orbitYawRad,
|
| 354 | int argb) {
|
| 355 | if (mesh == null || crystal == null || targetPos == null) {
|
| 356 | return;
|
| 357 | }
|
| 358 |
|
| 359 | Vector3f center = new Vector3f((float) crystal.position.x, (float) crystal.position.y, (float) crystal.position.z);
|
| 360 | center.rotateY(orbitYawRad);
|
| 361 | center.add((float) targetPos.x, (float) targetPos.y, (float) targetPos.z);
|
| 362 |
|
| 363 | float size = CRYSTAL_BASE_SIZE * 13.0f;
|
| 364 | Quaternionf camRot = RenderState.cameraRotation;
|
| 365 | float yaw = orbitYawRad;
|
| 366 | int bloomColor = applyOpacity(argb, (0.4f * 25.0f) / 255.0f);
|
| 367 |
|
| 368 | for (int i = 0; i < 6; i++) {
|
| 369 | float angle = (360.0f / 6.0f) * i;
|
| 370 | Quaternionf rotation = new Quaternionf()
|
| 371 | .rotateY((float) Math.toRadians(angle))
|
| 372 | .rotateY(yaw)
|
| 373 | .mul(camRot);
|
| 374 | addTexturedBillboard(mesh, center.x, center.y, center.z, size, rotation, bloomColor);
|
| 375 | }
|
| 376 |
|
| 377 | for (int i = 0; i < 6; i++) {
|
| 378 | float angle = (360.0f / 6.0f) * i;
|
| 379 | Quaternionf rotation = new Quaternionf()
|
| 380 | .rotateX((float) Math.toRadians(90.0f))
|
| 381 | .rotateY((float) Math.toRadians(angle))
|
| 382 | .rotateY(yaw)
|
| 383 | .mul(camRot);
|
| 384 | addTexturedBillboard(mesh, center.x, center.y, center.z, size, rotation, bloomColor);
|
| 385 | }
|
| 386 | }
|
| 387 |
|
| 388 | private static void addTexturedBillboard(MeshBuilder mesh,
|
| 389 | double cx, double cy, double cz,
|
| 390 | float size, Quaternionf rotation, int argb) {
|
| 391 | Vector3f right = new Vector3f(1.0f, 0.0f, 0.0f).rotate(rotation).mul(size * 0.5f);
|
| 392 | Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f).rotate(rotation).mul(size * 0.5f);
|
| 393 | addBillboardVertices(mesh, cx, cy, cz, right, up, argb, argb, argb, argb);
|
| 394 | }
|
| 395 |
|
| 396 | private static void addTriangle(MeshBuilder mesh, Vector3f v1, Vector3f v2, Vector3f v3, int argb) {
|
| 397 | mesh.ensureTriCapacity();
|
| 398 | int i1 = addVertex(mesh, v1.x, v1.y, v1.z, argb);
|
| 399 | int i2 = addVertex(mesh, v2.x, v2.y, v2.z, argb);
|
| 400 | int i3 = addVertex(mesh, v3.x, v3.y, v3.z, argb);
|
| 401 | mesh.triangle(i1, i2, i3);
|
| 402 | }
|
| 403 |
|
| 404 | private static void addLine(MeshBuilder mesh, Vector3f v1, Vector3f v2, int argb) {
|
| 405 | mesh.ensureLineCapacity();
|
| 406 | int i1 = addVertex(mesh, v1.x, v1.y, v1.z, argb);
|
| 407 | int i2 = addVertex(mesh, v2.x, v2.y, v2.z, argb);
|
| 408 | mesh.line(i1, i2);
|
| 409 | }
|
| 410 |
|
| 411 | private static void addRotatedBillboard(MeshBuilder mesh, double cx, double cy, double cz,
|
| 412 | float size, float angle, IntFunction<Integer> palette) {
|
| 413 | Quaternionf camRot = RenderState.cameraRotation;
|
| 414 | Vector3f right = new Vector3f(1, 0, 0).rotate(camRot);
|
| 415 | Vector3f up = new Vector3f(0, 1, 0).rotate(camRot);
|
| 416 |
|
| 417 | Vector3f r = new Vector3f(right).mul(size);
|
| 418 | Vector3f u = new Vector3f(up).mul(size);
|
| 419 |
|
| 420 | float sin = Mth.sin((float) Math.toRadians(angle));
|
| 421 | float cos = Mth.cos((float) Math.toRadians(angle));
|
| 422 |
|
| 423 | Vector3f rRot = new Vector3f(
|
| 424 | r.x() * cos - u.x() * sin,
|
| 425 | r.y() * cos - u.y() * sin,
|
| 426 | r.z() * cos - u.z() * sin
|
| 427 | );
|
| 428 | Vector3f uRot = new Vector3f(
|
| 429 | r.x() * sin + u.x() * cos,
|
| 430 | r.y() * sin + u.y() * cos,
|
| 431 | r.z() * sin + u.z() * cos
|
| 432 | );
|
| 433 |
|
| 434 | addBillboardVertices(mesh, cx, cy, cz, rRot, uRot,
|
| 435 | palette.apply(90),
|
| 436 | palette.apply(0),
|
| 437 | palette.apply(180),
|
| 438 | palette.apply(270));
|
| 439 | }
|
| 440 |
|
| 441 | private static void addBillboardQuad(MeshBuilder mesh,
|
| 442 | double cx, double cy, double cz,
|
| 443 | float size, int argb) {
|
| 444 | Quaternionf camRot = RenderState.cameraRotation;
|
| 445 | Vector3f right = new Vector3f(1, 0, 0).rotate(camRot).mul(size);
|
| 446 | Vector3f up = new Vector3f(0, 1, 0).rotate(camRot).mul(size);
|
| 447 | addBillboardVertices(mesh, cx, cy, cz, right, up, argb, argb, argb, argb);
|
| 448 | }
|
| 449 |
|
| 450 | private static void addBillboardVertices(MeshBuilder mesh, double cx, double cy, double cz,
|
| 451 | Vector3f right, Vector3f up,
|
| 452 | int c1, int c2, int c3, int c4) {
|
| 453 | double p1x = cx - right.x() - up.x();
|
| 454 | double p1y = cy - right.y() - up.y();
|
| 455 | double p1z = cz - right.z() - up.z();
|
| 456 | double p2x = cx + right.x() - up.x();
|
| 457 | double p2y = cy + right.y() - up.y();
|
| 458 | double p2z = cz + right.z() - up.z();
|
| 459 | double p3x = cx + right.x() + up.x();
|
| 460 | double p3y = cy + right.y() + up.y();
|
| 461 | double p3z = cz + right.z() + up.z();
|
| 462 | double p4x = cx - right.x() + up.x();
|
| 463 | double p4y = cy - right.y() + up.y();
|
| 464 | double p4z = cz - right.z() + up.z();
|
| 465 |
|
| 466 | mesh.ensureQuadCapacity();
|
| 467 | int i1 = addVertex(mesh, p1x, p1y, p1z, 0, 1, c1);
|
| 468 | int i2 = addVertex(mesh, p2x, p2y, p2z, 1, 1, c2);
|
| 469 | int i3 = addVertex(mesh, p3x, p3y, p3z, 1, 0, c3);
|
| 470 | int i4 = addVertex(mesh, p4x, p4y, p4z, 0, 0, c4);
|
| 471 | mesh.quad(i1, i2, i3, i4);
|
| 472 | }
|
| 473 |
|
| 474 | private static int applyOpacity(int argb, float opacity) {
|
| 475 | opacity = Math.min(1f, Math.max(0f, opacity));
|
| 476 | int baseA = (argb >>> 24) & 0xFF;
|
| 477 | int a = Mth.clamp((int) (baseA * opacity), 0, 255);
|
| 478 | return (a << 24) | (argb & 0x00FFFFFF);
|
| 479 | }
|
| 480 |
|
| 481 | private static int addVertex(MeshBuilder mesh, double x, double y, double z, int argb) {
|
| 482 | int a = (argb >>> 24) & 0xFF;
|
| 483 | int r = (argb >>> 16) & 0xFF;
|
| 484 | int g = (argb >>> 8) & 0xFF;
|
| 485 | int b = argb & 0xFF;
|
| 486 | mesh.vec3(x, y, z).color(r, g, b, a);
|
| 487 | return mesh.next();
|
| 488 | }
|
| 489 |
|
| 490 | private static int addVertex(MeshBuilder mesh, double x, double y, double z, double u, double v, int argb) {
|
| 491 | int a = (argb >>> 24) & 0xFF;
|
| 492 | int r = (argb >>> 16) & 0xFF;
|
| 493 | int g = (argb >>> 8) & 0xFF;
|
| 494 | int b = argb & 0xFF;
|
| 495 | mesh.vec3(x, y, z).vec2(u, v).color(r, g, b, a);
|
| 496 | return mesh.next();
|
| 497 | }
|
| 498 |
|
| 499 | private static double absSinAnimation(double input) {
|
| 500 | return Math.abs(1 + Math.sin(input)) / 2;
|
| 501 | }
|
| 502 |
|
| 503 | private static double interpolate(double oldValue, double newValue, double interpolationValue) {
|
| 504 | return (oldValue + (newValue - oldValue) * interpolationValue);
|
| 505 | }
|
| 506 |
|
| 507 | private static float interpolateFloat(float oldValue, float newValue, double interpolationValue) {
|
| 508 | return (float) interpolate(oldValue, newValue, interpolationValue);
|
| 509 | }
|
| 510 |
|
| 511 | @Override
|
| 512 | public void onDisable() {
|
| 513 | target = null;
|
| 514 | renderTarget = null;
|
| 515 | targetAlpha = 0.0f;
|
| 516 | crystalList.clear();
|
| 517 | lastCrystalTarget = null;
|
| 518 | }
|
| 519 |
|
| 520 | @Override
|
| 521 | public void onTick() {
|
| 522 | if (!isEnabled() || mc.level == null) {
|
| 523 | target = null;
|
| 524 | updateRenderTarget(null);
|
| 525 | crystalList.clear();
|
| 526 | lastCrystalTarget = null;
|
| 527 | return;
|
| 528 | }
|
| 529 | target = TargetingUtil.resolveManagedTarget(crosshairTargets.get(), playersOnly.get());
|
| 530 | updateRenderTarget(target);
|
| 531 | if (renderTarget == null) {
|
| 532 | crystalList.clear();
|
| 533 | lastCrystalTarget = null;
|
| 534 | }
|
| 535 |
|
| 536 | setCaptureSpeedScale(isCaptureMarkMode() ? captureSpinSpeed.get() : 1.0f);
|
| 537 |
|
| 538 | if (renderTarget != null && targetAlpha > 0.0f) {
|
| 539 | tickTargetEsp();
|
| 540 | }
|
| 541 | }
|
| 542 |
|
| 543 | @Override
|
| 544 | public WorldPhase getWorldPhase() {
|
| 545 | return WorldPhase.AFTER_POST_PROCESS;
|
| 546 | }
|
| 547 |
|
| 548 | @Override
|
| 549 | public void onRenderWorldEngine(Renderer3D renderer, Renderer3D depthRenderer, float tickDelta) {
|
| 550 | if (!isEnabled() || renderTarget == null || targetAlpha <= 0.001f) return;
|
| 551 | Renderer3D.CullOptions cull = resolveCullOptions(renderTarget);
|
| 552 | if (!Renderer3D.Culling.shouldRender(renderTarget, tickDelta, cull)) return;
|
| 553 |
|
| 554 | IntFunction<Integer> palette = index -> AnimatedRenderColors.scaleAlpha(getColorArgb(index), targetAlpha);
|
| 555 |
|
| 556 | String mode = espMode.get();
|
| 557 | if ("ring".equals(mode)) {
|
| 558 | drawOldTargetEsp(renderer, renderTarget, tickDelta, palette);
|
| 559 | } else if ("ghosts".equals(mode)) {
|
| 560 | renderGhosts(
|
| 561 | renderer,
|
| 562 | espLength.get(),
|
| 563 | espFactor.get(),
|
| 564 | espShaking.get(),
|
| 565 | espAmplitude.get(),
|
| 566 | renderTarget,
|
| 567 | tickDelta,
|
| 568 | palette
|
| 569 | );
|
| 570 | } else if ("capture_mark".equals(mode)) {
|
| 571 | renderCaptureMark(renderer, renderTarget, tickDelta, palette);
|
| 572 | } else if ("crystals".equals(mode)) {
|
| 573 | renderCrystals(renderer, renderTarget, tickDelta);
|
| 574 | } else if (isProceduralLayoutMode(mode)) {
|
| 575 | renderProceduralLayout(renderer, renderTarget, tickDelta, palette, mode);
|
| 576 | }
|
| 577 | }
|
| 578 |
|
| 579 | private void updateRenderTarget(LivingEntity next) {
|
| 580 | float dt = Math.max(AnimationUtility.deltaTime(), ALPHA_TICK_DT);
|
| 581 | float speed = alphaAnimationSpeed.get();
|
| 582 | if (next != null) {
|
| 583 | if (renderTarget == null) {
|
| 584 | renderTarget = next;
|
| 585 | targetAlpha = AnimationUtility.snap(
|
| 586 | AnimationUtility.approach(targetAlpha, 1.0f, dt, speed),
|
| 587 | 1.0f,
|
| 588 | ALPHA_SNAP_EPSILON
|
| 589 | );
|
| 590 | return;
|
| 591 | }
|
| 592 | if (renderTarget != next) {
|
| 593 | renderTarget = next;
|
| 594 | targetAlpha = 1.0f;
|
| 595 | crystalList.clear();
|
| 596 | lastCrystalTarget = null;
|
| 597 | return;
|
| 598 | }
|
| 599 | targetAlpha = AnimationUtility.snap(
|
| 600 | AnimationUtility.approach(targetAlpha, 1.0f, dt, speed),
|
| 601 | 1.0f,
|
| 602 | ALPHA_SNAP_EPSILON
|
| 603 | );
|
| 604 | return;
|
| 605 | }
|
| 606 |
|
| 607 | targetAlpha = AnimationUtility.snap(
|
| 608 | AnimationUtility.approach(targetAlpha, 0.0f, dt, speed),
|
| 609 | 0.0f,
|
| 610 | ALPHA_SNAP_EPSILON
|
| 611 | );
|
| 612 | if (targetAlpha <= 0.0f) {
|
| 613 | renderTarget = null;
|
| 614 | crystalList.clear();
|
| 615 | lastCrystalTarget = null;
|
| 616 | }
|
| 617 | }
|
| 618 |
|
| 619 | private Renderer3D.CullOptions resolveCullOptions(LivingEntity target) {
|
| 620 | if (target == null || mc.player == null) {
|
| 621 | return Renderer3D.CullOptions.SMART_TARGET;
|
| 622 | }
|
| 623 | // Allow rendering through walls if the current target is already selected,
|
| 624 | // so raycast-based targeting doesn't get culled by line-of-sight checks.
|
| 625 | if (!mc.player.hasLineOfSight(target)) {
|
| 626 | return Renderer3D.CullOptions.FRUSTUM_LOOK;
|
| 627 | }
|
| 628 | return Renderer3D.CullOptions.SMART_TARGET;
|
| 629 | }
|
| 630 |
|
| 631 | private Vec3 obtainEntityLerpedPos(Entity e, float f) {
|
| 632 | try {
|
| 633 | return e.getPosition(f);
|
| 634 | } catch (NoSuchMethodError ex) {
|
| 635 | if (e instanceof IEntity access) {
|
| 636 | Vec3 last = access.get$InstantRenderPos();
|
| 637 | return last.lerp(e.position(), f);
|
| 638 | }
|
| 639 | return e.position();
|
| 640 | }
|
| 641 | }
|
| 642 |
|
| 643 | private void renderProceduralLayout(Renderer3D renderer,
|
| 644 | LivingEntity target,
|
| 645 | float tickDelta,
|
| 646 | IntFunction<Integer> palette,
|
| 647 | String mode) {
|
| 648 | if (renderer == null || target == null || palette == null) return;
|
| 649 |
|
| 650 | int count = Math.max(8, layoutDensity.get());
|
| 651 | float baseScale = Math.max(0.01f, layoutScale.get());
|
| 652 | float speed = Math.max(0.01f, layoutSpeed.get());
|
| 653 | float radius = Math.max(0.42f, target.getBbWidth() * layoutRadiusScale.get());
|
| 654 | float height = Math.max(0.75f, target.getBbHeight() * 0.94f);
|
| 655 | float time = (target.tickCount - 1 + tickDelta) / 20.0f;
|
| 656 | long seed = ((long) target.getId() * 0x9E3779B97F4A7C15L) ^ mode.hashCode();
|
| 657 |
|
| 658 | ParticleLayoutDescriptor descriptor = switch (mode) {
|
| 659 | case "helix" -> new ParticleLayoutDescriptor.Helix(
|
| 660 | radius,
|
| 661 | height,
|
| 662 | 2.15f,
|
| 663 | 2,
|
| 664 | speed * 2.15f,
|
| 665 | height * 0.035f
|
| 666 | );
|
| 667 | case "orbit" -> new ParticleLayoutDescriptor.Orbit(
|
| 668 | radius,
|
| 669 | height * 0.48f,
|
| 670 | 3,
|
| 671 | 0.72f,
|
| 672 | speed * 1.8f
|
| 673 | );
|
| 674 | case "runes" -> new ParticleLayoutDescriptor.Runes(
|
| 675 | radius * 1.06f,
|
| 676 | height,
|
| 677 | 8,
|
| 678 | Math.max(0.15f, radius * 0.28f),
|
| 679 | speed * 0.52f
|
| 680 | );
|
| 681 | case "pulse" -> new ParticleLayoutDescriptor.Pulse(
|
| 682 | radius * 0.72f,
|
| 683 | radius * 0.31f,
|
| 684 | height * 0.45f,
|
| 685 | 3,
|
| 686 | speed * 2.35f
|
| 687 | );
|
| 688 | default -> new ParticleLayoutDescriptor.LightningPath(
|
| 689 | radius * 0.86f,
|
| 690 | height,
|
| 691 | 3,
|
| 692 | 0.58f,
|
| 693 | 2.1f,
|
| 694 | speed * 0.72f
|
| 695 | );
|
| 696 | };
|
| 697 |
|
| 698 | if (descriptor instanceof ParticleLayoutDescriptor.Runes runes) {
|
| 699 | count = Math.max(count, runes.runeCount() * 8);
|
| 700 | }
|
| 701 | if (descriptor instanceof ParticleLayoutDescriptor.LightningPath lightning) {
|
| 702 | count = Math.max(count, lightning.branches() * 12);
|
| 703 | }
|
| 704 |
|
| 705 | Vec3 center = RenderMath.getLerpedPos(target, tickDelta).add(0.0, target.getBbHeight() * 0.5, 0.0);
|
| 706 | MeshBuilder particleMesh = renderer.batchTextured(
|
| 707 | CombatantRenderPipelines.WORLD_TEXTURED_ADDITIVE,
|
| 708 | GHOST_PARTICLE_TEXTURE,
|
| 709 | Renderer3D.DepthMode.MAIN
|
| 710 | );
|
| 711 | if (particleMesh == null) return;
|
| 712 |
|
| 713 | Vec3[] previous = descriptor instanceof ParticleLayoutDescriptor.LightningPath lightning
|
| 714 | ? new Vec3[lightning.branches()]
|
| 715 | : null;
|
| 716 | int[] previousColor = previous != null ? new int[previous.length] : null;
|
| 717 |
|
| 718 | for (int i = 0; i < count; i++) {
|
| 719 | ParticleLayoutSample sample = ParticleLayoutEvaluator.sample(descriptor, i, count, time, seed);
|
| 720 | Vec3 world = center.add(sample.offset());
|
| 721 | int color = applyOpacity(palette.apply(sample.colorPhase()), sample.alpha());
|
| 722 | float sampleScale = baseScale * Math.max(0.25f, sample.scale());
|
| 723 | addBillboardQuad(particleMesh, world.x, world.y, world.z, sampleScale, color);
|
| 724 |
|
| 725 | if (previous != null) {
|
| 726 | int branch = i % previous.length;
|
| 727 | Vec3 prev = previous[branch];
|
| 728 | if (prev != null) {
|
| 729 | renderer.lineGradient(prev.x, prev.y, prev.z, world.x, world.y, world.z,
|
| 730 | applyOpacity(previousColor[branch], 0.72f),
|
| 731 | applyOpacity(color, 0.72f));
|
| 732 | }
|
| 733 | previous[branch] = world;
|
| 734 | previousColor[branch] = color;
|
| 735 | }
|
| 736 | }
|
| 737 | }
|
| 738 |
|
| 739 | private void renderCrystals(Renderer3D renderer, LivingEntity target, float tickDelta) {
|
| 740 | if (renderer == null || target == null) {
|
| 741 | return;
|
| 742 | }
|
| 743 | if (crystalList.isEmpty() || target != lastCrystalTarget) {
|
| 744 | createCrystals(target);
|
| 745 | lastCrystalTarget = target;
|
| 746 | }
|
| 747 | if (crystalList.isEmpty()) {
|
| 748 | return;
|
| 749 | }
|
| 750 |
|
| 751 | crystalRotationAngle = (crystalRotationAngle + 0.5f) % 360.0f;
|
| 752 | float orbitYawRad = (float) Math.toRadians(crystalRotationAngle);
|
| 753 | float red = crystalHitRed.get()
|
| 754 | ? Mth.clamp((target.hurtTime - tickDelta) / 20.0f, 0.0f, 1.0f)
|
| 755 | : 0.0f;
|
| 756 |
|
| 757 | Renderer3D.DepthMode depthMode = Renderer3D.DepthMode.PRE_DEPTH;
|
| 758 | MeshBuilder additiveMesh = renderer.batch(
|
| 759 | CombatantRenderPipelines.WORLD_COLORED_ADDITIVE_DEPTH,
|
| 760 | depthMode
|
| 761 | );
|
| 762 | MeshBuilder fillMesh = renderer.batch(
|
| 763 | CombatantRenderPipelines.WORLD_COLORED_DEPTH,
|
| 764 | depthMode
|
| 765 | );
|
| 766 | MeshBuilder lineMesh = renderer.batch(
|
| 767 | CombatantRenderPipelines.WORLD_COLORED_LINES_DEPTH,
|
| 768 | depthMode
|
| 769 | );
|
| 770 | MeshBuilder bloomMesh = renderer.batchTextured(
|
| 771 | CombatantRenderPipelines.WORLD_TEXTURED_ADDITIVE_DEPTH,
|
| 772 | CRYSTAL_BLOOM,
|
| 773 | depthMode
|
| 774 | );
|
| 775 | if (additiveMesh == null || fillMesh == null || lineMesh == null || bloomMesh == null) {
|
| 776 | return;
|
| 777 | }
|
| 778 |
|
| 779 | float prevWidth = RenderState.lineWidth;
|
| 780 | RenderState.lineWidth = 1.0f;
|
| 781 | try {
|
| 782 | Vec3 targetPos = obtainEntityLerpedPos(target, tickDelta);
|
| 783 | for (int i = 0; i < crystalList.size(); i++) {
|
| 784 | CrystalInstance crystal = crystalList.get(i);
|
| 785 | int baseColor = getCrystalColor(i, red);
|
| 786 | crystal.append(additiveMesh, fillMesh, lineMesh, bloomMesh, targetPos, orbitYawRad, baseColor);
|
| 787 | }
|
| 788 | } finally {
|
| 789 | RenderState.lineWidth = prevWidth;
|
| 790 | }
|
| 791 | }
|
| 792 |
|
| 793 | private int getCrystalColor(int index, float redFactor) {
|
| 794 | int baseArgb = getColorArgb(index);
|
| 795 | int out;
|
| 796 | if (redFactor <= 0.0f) {
|
| 797 | out = baseArgb;
|
| 798 | } else {
|
| 799 | int redArgb = (baseArgb & 0xFF000000) | 0x00FF0000;
|
| 800 | out = AnimatedRenderColors.mixArgb(baseArgb, redArgb, redFactor);
|
| 801 | }
|
| 802 | return AnimatedRenderColors.scaleAlpha(out, targetAlpha);
|
| 803 | }
|
| 804 |
|
| 805 | private void createCrystals(Entity target) {
|
| 806 | crystalList.clear();
|
| 807 | if (target == null) {
|
| 808 | return;
|
| 809 | }
|
| 810 | crystalList.add(new CrystalInstance(new Vec3(0, 0.85, 0.8), new Vec3(-49, 0, 40)));
|
| 811 | crystalList.add(new CrystalInstance(new Vec3(0.2, 0.85, -0.675), new Vec3(35, 0, -30)));
|
| 812 | crystalList.add(new CrystalInstance(new Vec3(0.6, 1.35, 0.6), new Vec3(-30, 0, 35)));
|
| 813 | crystalList.add(new CrystalInstance(new Vec3(-0.74, 1.05, 0.4), new Vec3(-25, 0, -30)));
|
| 814 | crystalList.add(new CrystalInstance(new Vec3(0.74, 0.95, -0.4), new Vec3(0, 0, 0)));
|
| 815 | crystalList.add(new CrystalInstance(new Vec3(-0.475, 0.85, -0.375), new Vec3(30, 0, -25)));
|
| 816 | crystalList.add(new CrystalInstance(new Vec3(0, 1.35, -0.6), new Vec3(45, 0, 0)));
|
| 817 | crystalList.add(new CrystalInstance(new Vec3(0.85, 0.7, 0.1), new Vec3(-30, 0, 30)));
|
| 818 | crystalList.add(new CrystalInstance(new Vec3(-0.7, 1.35, -0.3), new Vec3(0, 0, 0)));
|
| 819 | crystalList.add(new CrystalInstance(new Vec3(-0.3, 1.35, 0.55), new Vec3(0, 0, 0)));
|
| 820 | crystalList.add(new CrystalInstance(new Vec3(-0.5, 0.7, 0.7), new Vec3(0, 0, 0)));
|
| 821 | crystalList.add(new CrystalInstance(new Vec3(0.5, 0.7, 0.7), new Vec3(0, 0, 0)));
|
| 822 | crystalList.add(new CrystalInstance(new Vec3(-0.7, 0.75, 0), new Vec3(0, 0, 0)));
|
| 823 | crystalList.add(new CrystalInstance(new Vec3(-0.2, 0.65, -0.7), new Vec3(0, 0, 0)));
|
| 824 | }
|
| 825 |
|
| 826 | private boolean isGhostMode() {
|
| 827 | return "ghosts".equals(espMode.get());
|
| 828 | }
|
| 829 |
|
| 830 | private boolean isCaptureMarkMode() {
|
| 831 | return "capture_mark".equals(espMode.get());
|
| 832 | }
|
| 833 |
|
| 834 | private boolean isCrystalsMode() {
|
| 835 | return "crystals".equals(espMode.get());
|
| 836 | }
|
| 837 |
|
| 838 | private boolean isProceduralLayoutMode() {
|
| 839 | return isProceduralLayoutMode(espMode.get());
|
| 840 | }
|
| 841 |
|
| 842 | private static boolean isProceduralLayoutMode(String mode) {
|
| 843 | return "helix".equals(mode)
|
| 844 | || "orbit".equals(mode)
|
| 845 | || "runes".equals(mode)
|
| 846 | || "lightning".equals(mode)
|
| 847 | || "pulse".equals(mode);
|
| 848 | }
|
| 849 |
|
| 850 | private boolean usesSecondaryColor() {
|
| 851 | return AnimatedRenderColors.usesSecondary(animatedColorMode());
|
| 852 | }
|
| 853 |
|
| 854 | private int getColorArgb(int count) {
|
| 855 | int phase = colorPhase.get() + Math.round(count * colorSpread.get() / 90.0f);
|
| 856 | int animated = AnimatedRenderColors.resolve(
|
| 857 | animatedColorMode(),
|
| 858 | colorSpeed.get(),
|
| 859 | phase,
|
| 860 | colorValue.getArgb(),
|
| 861 | colorValue2.getArgb(),
|
| 862 | true
|
| 863 | );
|
| 864 | if (!useRelationColors.get() || renderTarget == null) {
|
| 865 | return animated;
|
| 866 | }
|
| 867 |
|
| 868 | int relation = relationColor(renderTarget, animated);
|
| 869 | relation = AnimatedRenderColors.withAlpha(relation, (animated >>> 24) & 0xFF);
|
| 870 | return AnimatedRenderColors.mixArgb(animated, relation, relationColorMix.get());
|
| 871 | }
|
| 872 |
|
| 873 | private int relationColor(LivingEntity entity, int fallback) {
|
| 874 | if (entity instanceof Player player) {
|
| 875 | return CategoryService.getColor(player);
|
| 876 | }
|
| 877 | String name = entity.getName() != null ? entity.getName().getString() : null;
|
| 878 | if (name == null || name.isBlank()) {
|
| 879 | return fallback;
|
| 880 | }
|
| 881 | return CategoryService.getColor(name);
|
| 882 | }
|
| 883 |
|
| 884 | private AnimatedRenderColors.Mode animatedColorMode() {
|
| 885 | return switch (colorMode.get()) {
|
| 886 | case "Rainbow" -> AnimatedRenderColors.Mode.RAINBOW;
|
| 887 | case "LightRainbow" -> AnimatedRenderColors.Mode.LIGHT_RAINBOW;
|
| 888 | case "Sky" -> AnimatedRenderColors.Mode.SKY;
|
| 889 | case "Fade" -> AnimatedRenderColors.Mode.FADE;
|
| 890 | case "DoubleColor" -> AnimatedRenderColors.Mode.DOUBLE_COLOR;
|
| 891 | case "Analogous" -> AnimatedRenderColors.Mode.ANALOGOUS;
|
| 892 | case "Theme" -> AnimatedRenderColors.Mode.THEME;
|
| 893 | default -> AnimatedRenderColors.Mode.STATIC;
|
| 894 | };
|
| 895 | }
|
| 896 |
|
| 897 | private static final class CrystalInstance {
|
| 898 | private final Vec3 position;
|
| 899 | private final Vec3 rotation;
|
| 900 | private final float rotationSpeed;
|
| 901 |
|
| 902 | private CrystalInstance(Vec3 position, Vec3 rotation) {
|
| 903 | this.position = position;
|
| 904 | this.rotation = rotation;
|
| 905 | this.rotationSpeed = 0.5f + (float) (Math.random() * 1.5f);
|
| 906 | }
|
| 907 |
|
| 908 | private float selfRotationDeg() {
|
| 909 | return (System.currentTimeMillis() % 36000L) / 100.0f * rotationSpeed;
|
| 910 | }
|
| 911 |
|
| 912 | private float pulsation() {
|
| 913 | return 1.0f + (float) (Math.sin(System.currentTimeMillis() / 500.0) * 0.1f);
|
| 914 | }
|
| 915 |
|
| 916 | private void append(MeshBuilder additiveMesh,
|
| 917 | MeshBuilder fillMesh,
|
| 918 | MeshBuilder lineMesh,
|
| 919 | MeshBuilder bloomMesh,
|
| 920 | Vec3 targetPos,
|
| 921 | float orbitYawRad,
|
| 922 | int baseColor) {
|
| 923 | appendCrystalGeometry(additiveMesh, targetPos, this, orbitYawRad, 1.0f, applyOpacity(baseColor, 0.2f), true);
|
| 924 | appendCrystalGeometry(fillMesh, targetPos, this, orbitYawRad, 1.0f, applyOpacity(baseColor, 0.3f), true);
|
| 925 | appendCrystalGeometry(lineMesh, targetPos, this, orbitYawRad, 1.0f, applyOpacity(baseColor, 0.8f), false);
|
| 926 | appendCrystalGeometry(additiveMesh, targetPos, this, orbitYawRad, 1.2f, applyOpacity(baseColor, 0.3f), true);
|
| 927 | appendBloomSphere(bloomMesh, targetPos, this, orbitYawRad, baseColor);
|
| 928 | }
|
| 929 | }
|
| 930 | }
|
| 931 |
|