TazikHat module

TazikHat: Minecraft 26.3 cheat module, full source for every implementation (1 client: Combatant).

1 implementationVISUALS

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

CombatantVISUALSsrc/main/java/combatant/client/features/module/modules/visuals/TazikHat.javaJava · 855 lines · 28.7 KB
Settingsrender_targetuse_relationsprimary_colorcolor_modesecondary_colorcolor_speedscaledepth_testrim_colorhelmet_scalehead_top_offsethead_forward_offsethead_right_offsetwobble_strengthdeath_flightdeath_flight_power
TazikHat.javaJava · Minecraft 26.2 · 855 lines · 28.7 KB · complete file, verbatimOriginal ↗
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.core.BlockPos;
12
import net.minecraft.util.Mth;
13
import net.minecraft.world.entity.EquipmentSlot;
14
import net.minecraft.world.entity.player.Player;
15
import net.minecraft.world.item.ItemStack;
16
import net.minecraft.world.item.Items;
17
import net.minecraft.world.phys.Vec3;
18
import combatant.client.config.common.CommonSettingSchemas;
19
import combatant.client.config.values.BooleanValue;
20
import combatant.client.config.values.EnumValue;
21
import combatant.client.config.values.NumberValue;
22
import combatant.client.config.values.RGBAColorValue;
23
import combatant.client.features.module.Module;
24
import combatant.client.features.module.ModuleCategory;
25
import combatant.client.features.module.ModuleInfo;
26
import combatant.client.features.module.WorldPhase;
27
import combatant.client.features.relations.CategoryService;
28
import combatant.client.render.engine.animation.AnimationUtility;
29
import combatant.client.render.engine.animation.AnimatedRenderColors;
30
import combatant.client.render.engine.pipeline.CombatantRenderPipelines;
31
import combatant.client.render.engine.renderer.Renderer3D;
32
import combatant.client.render.engine.uniform.MeshBuilder;
33
import combatant.client.render.helpers.HeadAnchor;
34
35
import java.util.HashMap;
36
import java.util.Iterator;
37
import java.util.Map;
38
import java.util.Random;
39
40
//todo Description
41
@ModuleInfo(
42
        id = "tazikhat",
43
        displayName = "TazikHat",
44
        category = ModuleCategory.VISUALS
45
)
46
public final class TazikHat extends Module {
47
48
    private static final int SEGMENTS = 56;
49
    private static final long DEATH_LIFE_MS = 3600L;
50
    private static final double RAINBOW_SPATIAL_SCALE = 12.0;
51
52
    private static final float BOWL_RIM_RADIUS = 0.42f;
53
    private static final float BOWL_TOP_RADIUS = 0.245f;
54
    private static final float BOWL_HEIGHT = 0.18f;
55
    private static final float BOWL_RIM_WIDTH = 0.052f;
56
    private final Minecraft mc = Minecraft.getInstance();
57
    private final Random random = new Random();
58
    private final EnumValue<RenderTarget> renderTarget =
59
            enumMode(
60
                    "render_target",
61
                    RenderTarget.BOTH,
62
                    RenderTarget.values()
63
            );
64
    private final BooleanValue useRelations =
65
            boolCommon(
66
                    "use_relations",
67
                    "use_relations",
68
                    CommonSettingSchemas.PLAYER_USE_RELATIONS,
69
                    true
70
            );
71
    private final RGBAColorValue primaryColor =
72
            visibleWhen(common(
73
                    color(
74
                            "primary_color",
75
                            "#CC17C765"
76
                    ),
77
                    CommonSettingSchemas.RENDER_PRIMARY_COLOR.commonI18nKey()
78
            ), () -> !useRelations.get());
79
    private final EnumValue<ColorMode> colorMode =
80
            enumCommon(
81
                    "color_mode",
82
                    "color_mode",
83
                    CommonSettingSchemas.RENDER_COLOR_MODE,
84
                    ColorMode.STATIC,
85
                    ColorMode.values()
86
            );
87
    private final RGBAColorValue secondaryColor =
88
            visibleWhen(common(
89
                    color(
90
                            "secondary_color",
91
                            "#AA079C46"
92
                    ),
93
                    CommonSettingSchemas.RENDER_SECONDARY_COLOR.commonI18nKey()
94
            ), this::usesSecondaryManualColor);
95
    private final NumberValue<Integer> colorSpeed =
96
            numCommon(
97
                    "color_speed",
98
                    "color_speed",
99
                    CommonSettingSchemas.RENDER_COLOR_SPEED,
100
                    18,
101
                    2,
102
                    54
103
            );
104
    private final NumberValue<Float> scale =
105
            numCommon(
106
                    "scale",
107
                    "scale",
108
                    CommonSettingSchemas.RENDER_SCALE,
109
                    1.15f,
110
                    0.45f,
111
                    2.0f
112
            );
113
    private final BooleanValue depthTest =
114
            boolCommon(
115
                    "depth_test",
116
                    "depth_test",
117
                    CommonSettingSchemas.RENDER_DEPTH_TEST,
118
                    true
119
            );
120
    private final RGBAColorValue rimColor =
121
            visibleWhen(color(
122
                    "rim_color",
123
                    "#EE52FFA0"
124
            ), () -> !useRelations.get());
125
    private final NumberValue<Float> helmetScale =
126
            num(
127
                    "helmet_scale",
128
                    1.16f,
129
                    1.0f,
130
                    1.45f
131
            );
132
    private final NumberValue<Float> headTopOffset =
133
            num(
134
                    "head_top_offset",
135
                    0.255f,
136
                    0.05f,
137
                    0.45f
138
            );
139
    private final NumberValue<Float> headForwardOffset =
140
            num(
141
                    "head_forward_offset",
142
                    0.0f,
143
                    -0.25f,
144
                    0.25f
145
            );
146
    private final NumberValue<Float> headRightOffset =
147
            num(
148
                    "head_right_offset",
149
                    0.0f,
150
                    -0.25f,
151
                    0.25f
152
            );
153
    private final NumberValue<Float> wobbleStrength =
154
            num(
155
                    "wobble_strength",
156
                    1.0f,
157
                    0.0f,
158
                    2.5f
159
            );
160
    private final BooleanValue deathFlight =
161
            bool(
162
                    "death_flight",
163
                    true
164
            );
165
    private final NumberValue<Float> deathFlightPower =
166
            visibleWhen(num(
167
                    "death_flight_power",
168
                    1.0f,
169
                    0.25f,
170
                    3.0f
171
            ), deathFlight::get);
172
    private final Map<Integer, Long> handledDeaths = new HashMap<>();
173
    private final Map<Integer, FlyingTazik> flying = new HashMap<>();
174
175
    private static void quadGradient(MeshBuilder mesh,
176
                                     Vec3 p1, int c1,
177
                                     Vec3 p2, int c2,
178
                                     Vec3 p3, int c3,
179
                                     Vec3 p4, int c4) {
180
        mesh.ensureQuadCapacity();
181
182
        putColorVertex(mesh, p1, c1);
183
        int i1 = mesh.next();
184
185
        putColorVertex(mesh, p2, c2);
186
        int i2 = mesh.next();
187
188
        putColorVertex(mesh, p3, c3);
189
        int i3 = mesh.next();
190
191
        putColorVertex(mesh, p4, c4);
192
        int i4 = mesh.next();
193
194
        mesh.quad(i1, i2, i3, i4);
195
    }
196
197
    private static void triangle(MeshBuilder mesh,
198
                                 Vec3 p1,
199
                                 Vec3 p2,
200
                                 Vec3 p3,
201
                                 int argb) {
202
        mesh.ensureTriCapacity();
203
204
        putColorVertex(mesh, p1, argb);
205
        int i1 = mesh.next();
206
207
        putColorVertex(mesh, p2, argb);
208
        int i2 = mesh.next();
209
210
        putColorVertex(mesh, p3, argb);
211
        int i3 = mesh.next();
212
213
        mesh.triangle(i1, i2, i3);
214
    }
215
216
    private static void lineGradient(MeshBuilder mesh,
217
                                     Vec3 p1,
218
                                     Vec3 p2,
219
                                     int c1,
220
                                     int c2) {
221
        mesh.ensureLineCapacity();
222
223
        putColorVertex(mesh, p1, c1);
224
        int i1 = mesh.next();
225
226
        putColorVertex(mesh, p2, c2);
227
        int i2 = mesh.next();
228
229
        mesh.line(i1, i2);
230
    }
231
232
    private static void putColorVertex(MeshBuilder mesh, Vec3 p, int argb) {
233
        mesh.vec3(p.x, p.y, p.z).color(red(argb), green(argb), blue(argb), alpha(argb));
234
    }
235
236
    private static int mix(int a, int b, float t) {
237
        float clamped = AnimationUtility.clamp01(t);
238
239
        int aa = alpha(a);
240
        int ar = red(a);
241
        int ag = green(a);
242
        int ab = blue(a);
243
244
        int ba = alpha(b);
245
        int br = red(b);
246
        int bg = green(b);
247
        int bb = blue(b);
248
249
        int ca = Math.round(AnimationUtility.lerp(aa, ba, clamped));
250
        int cr = Math.round(AnimationUtility.lerp(ar, br, clamped));
251
        int cg = Math.round(AnimationUtility.lerp(ag, bg, clamped));
252
        int cb = Math.round(AnimationUtility.lerp(ab, bb, clamped));
253
254
        return (ca << 24) | (cr << 16) | (cg << 8) | cb;
255
    }
256
257
    private static int multiplyRgb(int argb, float factor) {
258
        int a = alpha(argb);
259
        int r = Mth.clamp(Math.round(red(argb) * factor), 0, 255);
260
        int g = Mth.clamp(Math.round(green(argb) * factor), 0, 255);
261
        int b = Mth.clamp(Math.round(blue(argb) * factor), 0, 255);
262
        return (a << 24) | (r << 16) | (g << 8) | b;
263
    }
264
265
    private static int brighten(int argb, float factor) {
266
        return multiplyRgb(argb, factor);
267
    }
268
269
    private static int withAlpha(int argb, int alpha) {
270
        int a = Mth.clamp(alpha, 0, 255);
271
        return (a << 24) | (argb & 0x00FFFFFF);
272
    }
273
274
    private static int red(int argb) {
275
        return (argb >>> 16) & 255;
276
    }
277
278
    private static int green(int argb) {
279
        return (argb >>> 8) & 255;
280
    }
281
282
    private static int blue(int argb) {
283
        return argb & 255;
284
    }
285
286
    private static int alpha(int argb) {
287
        return (argb >>> 24) & 255;
288
    }
289
290
    private static int alphaOr(int argb, int fallback) {
291
        int alpha = alpha(argb);
292
        return alpha <= 0 ? Mth.clamp(fallback, 0, 255) : alpha;
293
    }
294
295
    @Override
296
    public WorldPhase getWorldPhase() {
297
        return WorldPhase.BEFORE_TRANSLUCENT;
298
    }
299
300
    @Override
301
    public void onTick() {
302
        if (!isEnabled() || mc.level == null || mc.player == null) {
303
            return;
304
        }
305
306
        long now = System.currentTimeMillis();
307
308
        for (Player player : mc.level.players()) {
309
            if (player == null || player.isRemoved()) continue;
310
311
            int id = player.getId();
312
313
            if (player.isAlive() && player.getHealth() > 0.0f) {
314
                handledDeaths.remove(id);
315
                continue;
316
            }
317
318
            if (!deathFlight.get()) continue;
319
            if (handledDeaths.containsKey(id)) continue;
320
321
            handledDeaths.put(id, now);
322
            spawnFlyingTazik(player);
323
        }
324
325
        handledDeaths.entrySet().removeIf(entry -> now - entry.getValue() > 8000L);
326
327
        Iterator<Map.Entry<Integer, FlyingTazik>> iterator = flying.entrySet().iterator();
328
        while (iterator.hasNext()) {
329
            FlyingTazik tazik = iterator.next().getValue();
330
            if (tazik.update()) {
331
                iterator.remove();
332
            }
333
        }
334
    }
335
336
    @Override
337
    public void onDisable() {
338
        handledDeaths.clear();
339
        flying.clear();
340
    }
341
342
    @Override
343
    public void onRenderWorldEngine(Renderer3D renderer, Renderer3D depthRenderer, float tickDelta) {
344
        if (!isEnabled() || mc.level == null || mc.player == null) return;
345
346
        MeshBuilder tris = renderer.batch(
347
                depthTest.get()
348
                        ? CombatantRenderPipelines.WORLD_COLORED_DEPTH
349
                        : CombatantRenderPipelines.WORLD_COLORED,
350
                depthTest.get()
351
                        ? Renderer3D.DepthMode.PRE_DEPTH
352
                        : Renderer3D.DepthMode.NONE
353
        );
354
355
        MeshBuilder lines = renderer.batch(
356
                depthTest.get()
357
                        ? CombatantRenderPipelines.WORLD_COLORED_LINES_DEPTH
358
                        : CombatantRenderPipelines.WORLD_COLORED_LINES,
359
                depthTest.get()
360
                        ? Renderer3D.DepthMode.PRE_DEPTH
361
                        : Renderer3D.DepthMode.NONE
362
        );
363
364
        if (tris == null || lines == null) return;
365
366
        RenderBuffers buffers = new RenderBuffers(tris, lines);
367
368
        if (shouldRenderSelf() && !mc.options.getCameraType().isFirstPerson()) {
369
            renderAttached(buffers, mc.player, tickDelta);
370
        }
371
372
        if (shouldRenderPlayers()) {
373
            for (Player player : mc.level.players()) {
374
                if (player == null || player == mc.player || player.isRemoved()) continue;
375
                if (!player.isAlive() || player.getHealth() <= 0.0f) continue;
376
377
                renderAttached(buffers, player, tickDelta);
378
            }
379
        }
380
381
        renderFlying(buffers, tickDelta);
382
    }
383
384
    private boolean shouldRenderSelf() {
385
        return renderTarget.get() == RenderTarget.SELF || renderTarget.get() == RenderTarget.BOTH;
386
    }
387
388
    private boolean shouldRenderPlayers() {
389
        return renderTarget.get() == RenderTarget.PLAYERS || renderTarget.get() == RenderTarget.BOTH;
390
    }
391
392
    private boolean usesSecondaryManualColor() {
393
        if (useRelations.get()) return false;
394
        return AnimatedRenderColors.usesSecondary(animatedColorMode());
395
    }
396
397
    private void renderAttached(RenderBuffers buffers, Player player, float tickDelta) {
398
        boolean helmet = hasHelmet(player);
399
        float size = scale.get() * (helmet ? helmetScale.get() : 1.0f);
400
401
        HeadAnchor anchor = HeadAnchor.of(
402
                player,
403
                tickDelta,
404
                headTopOffset.get(),
405
                headForwardOffset.get(),
406
                headRightOffset.get()
407
        );
408
409
        Palette palette = resolvePalette(player);
410
        Wobble wobble = resolveWobble(player, tickDelta);
411
412
        buildTazik(
413
                buffers,
414
                anchor,
415
                size,
416
                0.0f,
417
                wobble.pitchDeg,
418
                wobble.rollDeg,
419
                palette,
420
                1.0f,
421
                player.getId()
422
        );
423
    }
424
425
    private void renderFlying(RenderBuffers buffers, float tickDelta) {
426
        long now = System.currentTimeMillis();
427
428
        for (FlyingTazik tazik : flying.values()) {
429
            float life = (now - tazik.createdAtMs) / (float) DEATH_LIFE_MS;
430
            float fade = 1.0f - AnimationUtility.smoothstep(Math.max(0.0f, life - 0.65f) / 0.35f);
431
432
            Vec3 pos = new Vec3(
433
                    AnimationUtility.lerp(tazik.prevPos.x, tazik.pos.x, tickDelta),
434
                    AnimationUtility.lerp(tazik.prevPos.y, tazik.pos.y, tickDelta),
435
                    AnimationUtility.lerp(tazik.prevPos.z, tazik.pos.z, tickDelta)
436
            );
437
438
            buildFlyingTazik(
439
                    buffers,
440
                    pos,
441
                    tazik.scale,
442
                    tazik.yaw,
443
                    tazik.pitch,
444
                    tazik.roll,
445
                    tazik.palette,
446
                    fade,
447
                    tazik.seed
448
            );
449
        }
450
    }
451
452
    private Wobble resolveWobble(Player player, float tickDelta) {
453
        float hurt = Math.max(0.0f, player.hurtTime - tickDelta);
454
        float hit = AnimationUtility.easeOutBack(AnimationUtility.clamp01(hurt / 10.0f), 1.25f);
455
456
        float strength = wobbleStrength.get();
457
        float time = (player.tickCount + tickDelta) * 0.35f + player.getId() * 0.17f;
458
459
        float hitAmp = hit * 5.0f * strength;
460
        float idleAmp = 1.3f * strength;
461
462
        float pitch = Mth.sin(time * 3.7f) * hitAmp
463
                + Mth.sin(time * 1.2f) * idleAmp;
464
465
        float roll = Mth.cos(time * 3.1f) * hitAmp
466
                + Mth.cos(time * 0.9f) * idleAmp;
467
468
        return new Wobble(pitch, roll);
469
    }
470
471
    private void buildTazik(RenderBuffers buffers,
472
                            HeadAnchor anchor,
473
                            float size,
474
                            float yawDeg,
475
                            float pitchDeg,
476
                            float rollDeg,
477
                            Palette palette,
478
                            float alphaMul,
479
                            int seed) {
480
        float rimRadius = BOWL_RIM_RADIUS * size;
481
        float topRadius = BOWL_TOP_RADIUS * size;
482
        float height = BOWL_HEIGHT * size;
483
        float rimWidth = BOWL_RIM_WIDTH * size;
484
485
        double rimOuterY = 0.055 * size;
486
        double rimInnerY = 0.073 * size;
487
        double topOuterY = height * 0.82;
488
        double topInnerY = height;
489
490
        Vec3[] rimOuter = new Vec3[SEGMENTS];
491
        Vec3[] rimInner = new Vec3[SEGMENTS];
492
        Vec3[] topOuter = new Vec3[SEGMENTS];
493
        Vec3[] topInner = new Vec3[SEGMENTS];
494
495
        for (int i = 0; i < SEGMENTS; i++) {
496
            float angle = (float) ((Math.PI * 2.0 * i) / SEGMENTS);
497
498
            float sx = Mth.sin(angle);
499
            float sz = Mth.cos(angle);
500
501
            float rimWave = 1.0f + 0.010f * Mth.sin(angle * 4.0f + seed * 0.013f);
502
            float topWave = 1.0f + 0.006f * Mth.cos(angle * 3.0f + seed * 0.011f);
503
504
            float outerRim = rimRadius * rimWave;
505
            float innerRim = Math.max(0.02f, outerRim - rimWidth);
506
507
            float outerTop = topRadius * topWave;
508
            float innerTop = Math.max(0.02f, outerTop - rimWidth * 0.35f);
509
510
            rimOuter[i] = anchor.localRotated(sx * outerRim, rimOuterY, sz * outerRim, yawDeg, pitchDeg, rollDeg);
511
            rimInner[i] = anchor.localRotated(sx * innerRim, rimInnerY, sz * innerRim, yawDeg, pitchDeg, rollDeg);
512
            topOuter[i] = anchor.localRotated(sx * outerTop, topOuterY, sz * outerTop, yawDeg, pitchDeg, rollDeg);
513
            topInner[i] = anchor.localRotated(sx * innerTop, topInnerY, sz * innerTop, yawDeg, pitchDeg, rollDeg);
514
        }
515
516
        Vec3 topCenter = anchor.localRotated(
517
                0.0,
518
                topInnerY + 0.002 * size,
519
                0.0,
520
                yawDeg,
521
                pitchDeg,
522
                rollDeg
523
        );
524
525
        drawTazikMesh(buffers, rimOuter, rimInner, topOuter, topInner, topCenter, palette, alphaMul);
526
    }
527
528
    private void buildFlyingTazik(RenderBuffers buffers,
529
                                  Vec3 center,
530
                                  float size,
531
                                  float yawDeg,
532
                                  float pitchDeg,
533
                                  float rollDeg,
534
                                  Palette palette,
535
                                  float alphaMul,
536
                                  int seed) {
537
        buildTazik(
538
                buffers,
539
                HeadAnchor.world(center),
540
                size,
541
                yawDeg,
542
                pitchDeg,
543
                rollDeg,
544
                palette,
545
                alphaMul,
546
                seed
547
        );
548
    }
549
550
    private void drawTazikMesh(RenderBuffers buffers,
551
                               Vec3[] rimOuter,
552
                               Vec3[] rimInner,
553
                               Vec3[] topOuter,
554
                               Vec3[] topInner,
555
                               Vec3 topCenter,
556
                               Palette palette,
557
                               float alphaMul) {
558
        for (int i = 0; i < SEGMENTS; i++) {
559
            int next = (i + 1) % SEGMENTS;
560
561
            int rimLow1 = colorAt(palette, i, 0.76f, alphaMul);
562
            int rimLow2 = colorAt(palette, next, 0.76f, alphaMul);
563
564
            int wallTop1 = colorAt(palette, i, 1.02f, alphaMul);
565
            int wallTop2 = colorAt(palette, next, 1.02f, alphaMul);
566
567
            int innerTop1 = colorAt(palette, i, 0.66f, alphaMul * 0.90f);
568
            int innerTop2 = colorAt(palette, next, 0.66f, alphaMul * 0.90f);
569
570
            int innerLow1 = colorAt(palette, i, 0.50f, alphaMul * 0.82f);
571
            int innerLow2 = colorAt(palette, next, 0.50f, alphaMul * 0.82f);
572
573
            int rim1 = rimColorAt(palette, i, alphaMul);
574
            int rim2 = rimColorAt(palette, next, alphaMul);
575
576
            int topCenterColor = colorAt(palette, i, 1.10f, alphaMul * 0.95f);
577
578
            quadGradient(buffers.tris, rimOuter[i], rimLow1, rimOuter[next], rimLow2, topOuter[next], wallTop2, topOuter[i], wallTop1);
579
            quadGradient(buffers.tris, topInner[i], innerTop1, topInner[next], innerTop2, rimInner[next], innerLow2, rimInner[i], innerLow1);
580
            quadGradient(buffers.tris, rimInner[i], rim1, rimInner[next], rim2, rimOuter[next], rim2, rimOuter[i], rim1);
581
582
            triangle(buffers.tris, topCenter, topInner[i], topInner[next], topCenterColor);
583
584
            lineGradient(buffers.lines, rimOuter[i], rimOuter[next], rim1, rim2);
585
            lineGradient(buffers.lines, topOuter[i], topOuter[next], wallTop1, wallTop2);
586
        }
587
    }
588
589
    private void spawnFlyingTazik(Player player) {
590
        if (player == null) return;
591
592
        boolean helmet = hasHelmet(player);
593
        float size = scale.get() * (helmet ? helmetScale.get() : 1.0f);
594
595
        HeadAnchor anchor = HeadAnchor.of(
596
                player,
597
                1.0f,
598
                headTopOffset.get(),
599
                headForwardOffset.get(),
600
                headRightOffset.get()
601
        );
602
603
        Vec3 base = anchor.origin();
604
605
        Vec3 away = mc.player != null
606
                ? base.subtract(mc.player.getEyePosition())
607
                : new Vec3(randomRange(-1.0f, 1.0f), 0.0, randomRange(-1.0f, 1.0f));
608
609
        if (away.lengthSqr() < 1.0e-5) {
610
            away = new Vec3(randomRange(-1.0f, 1.0f), 0.0, randomRange(-1.0f, 1.0f));
611
        }
612
613
        away = away.normalize();
614
615
        float power = deathFlightPower.get();
616
        Vec3 velocity = new Vec3(
617
                away.x * randomRange(0.18f, 0.34f) * power + randomRange(-0.08f, 0.08f),
618
                randomRange(0.34f, 0.58f) * power,
619
                away.z * randomRange(0.18f, 0.34f) * power + randomRange(-0.08f, 0.08f)
620
        );
621
622
        flying.put(player.getId(), new FlyingTazik(
623
                base,
624
                velocity,
625
                size,
626
                resolvePalette(player),
627
                random.nextInt()
628
        ));
629
    }
630
631
    private Palette resolvePalette(Player player) {
632
        if (useRelations.get()) {
633
            int relation = CategoryService.getColor(player);
634
            int primary = withAlpha(relation, alphaOr(primaryColor.getArgb(), 255));
635
            int secondary = withAlpha(AnimatedRenderColors.analogousColor(relation), alphaOr(secondaryColor.getArgb(), 170));
636
            int rim = withAlpha(brighten(relation, 1.35f), alphaOr(rimColor.getArgb(), 238));
637
638
            return new Palette(primary, secondary, rim);
639
        }
640
641
        return new Palette(
642
                primaryColor.getArgb(),
643
                secondaryColor.getArgb(),
644
                rimColor.getArgb()
645
        );
646
    }
647
648
    private int colorAt(Palette palette, int index, float verticalLight, float alphaMul) {
649
        int dynamic = getDynamicColor(
650
                palette.primary,
651
                palette.secondary,
652
                animatedColorMode(),
653
                colorSpeed.get(),
654
                index
655
        );
656
657
        float circumference = 0.5f + 0.5f * Mth.sin(index * 0.47f + System.currentTimeMillis() * 0.0007f);
658
        int mixed = multiplyRgb(dynamic, verticalLight + circumference * 0.16f);
659
660
        return withAlpha(mixed, Math.round(alpha(mixed) * alphaMul));
661
    }
662
663
    private int rimColorAt(Palette palette, int index, float alphaMul) {
664
        int dynamic = getDynamicColor(
665
                palette.rim,
666
                palette.secondary,
667
                animatedColorMode(),
668
                colorSpeed.get(),
669
                index + 120
670
        );
671
672
        float t = 0.5f + 0.5f * Mth.sin(index * 0.71f + System.currentTimeMillis() * 0.0011f);
673
        int mixed = mix(dynamic, brighten(palette.primary, 1.35f), t);
674
675
        return withAlpha(mixed, Math.round(alpha(mixed) * alphaMul));
676
    }
677
678
    private AnimatedRenderColors.Mode animatedColorMode() {
679
        return switch (colorMode.get()) {
680
            case RAINBOW -> AnimatedRenderColors.Mode.RAINBOW;
681
            case LIGHT_RAINBOW -> AnimatedRenderColors.Mode.LIGHT_RAINBOW;
682
            case SKY -> AnimatedRenderColors.Mode.SKY;
683
            case FADE -> AnimatedRenderColors.Mode.FADE;
684
            case DOUBLE_COLOR -> AnimatedRenderColors.Mode.DOUBLE_COLOR;
685
            case ANALOGOUS -> AnimatedRenderColors.Mode.ANALOGOUS;
686
            case THEME -> AnimatedRenderColors.Mode.THEME;
687
            case STATIC -> AnimatedRenderColors.Mode.STATIC;
688
        };
689
    }
690
691
    private int getDynamicColor(int primary,
692
                                int secondary,
693
                                AnimatedRenderColors.Mode mode,
694
                                int speed,
695
                                int index) {
696
        int spatialIndex = Math.floorMod((int) Math.round(index * RAINBOW_SPATIAL_SCALE), 3600);
697
        return AnimatedRenderColors.resolve(mode, speed, spatialIndex, primary, secondary, true);
698
    }
699
700
    private boolean hasHelmet(Player player) {
701
        ItemStack stack = player.getItemBySlot(EquipmentSlot.HEAD);
702
        return !stack.isEmpty() && (
703
                stack.is(Items.LEATHER_HELMET)
704
                        || stack.is(Items.CHAINMAIL_HELMET)
705
                        || stack.is(Items.IRON_HELMET)
706
                        || stack.is(Items.GOLDEN_HELMET)
707
                        || stack.is(Items.DIAMOND_HELMET)
708
                        || stack.is(Items.NETHERITE_HELMET)
709
        );
710
    }
711
712
    private float randomRange(float min, float max) {
713
        return min + random.nextFloat() * (max - min);
714
    }
715
716
    public enum RenderTarget implements EnumValue.IdProvider {
717
        SELF("self"),
718
        PLAYERS("players"),
719
        BOTH("both");
720
721
        private final String id;
722
723
        RenderTarget(String id) {
724
            this.id = id;
725
        }
726
727
        @Override
728
        public String id() {
729
            return id;
730
        }
731
    }
732
733
    public enum ColorMode implements EnumValue.IdProvider {
734
        STATIC("static"),
735
        RAINBOW("rainbow"),
736
        LIGHT_RAINBOW("light_rainbow"),
737
        SKY("sky"),
738
        FADE("fade"),
739
        DOUBLE_COLOR("double_color"),
740
        ANALOGOUS("analogous"),
741
        THEME("theme");
742
743
        private final String id;
744
745
        ColorMode(String id) {
746
            this.id = id;
747
        }
748
749
        @Override
750
        public String id() {
751
            return id;
752
        }
753
    }
754
755
    private record RenderBuffers(MeshBuilder tris, MeshBuilder lines) {
756
    }
757
758
    private record Palette(int primary, int secondary, int rim) {
759
    }
760
761
    private record Wobble(float pitchDeg, float rollDeg) {
762
    }
763
764
    private final class FlyingTazik {
765
        private final float scale;
766
        private final Palette palette;
767
        private final int seed;
768
        private final long createdAtMs;
769
        private Vec3 pos;
770
        private Vec3 prevPos;
771
        private Vec3 velocity;
772
        private float yaw;
773
        private float pitch;
774
        private float roll;
775
        private float yawVelocity;
776
        private float pitchVelocity;
777
        private float rollVelocity;
778
779
        private FlyingTazik(Vec3 pos, Vec3 velocity, float scale, Palette palette, int seed) {
780
            this.pos = pos;
781
            this.prevPos = pos;
782
            this.velocity = velocity;
783
            this.scale = scale;
784
            this.palette = palette;
785
            this.seed = seed;
786
            this.createdAtMs = System.currentTimeMillis();
787
788
            float power = deathFlightPower.get();
789
790
            this.yaw = randomRange(0.0f, 360.0f);
791
            this.pitch = randomRange(-20.0f, 20.0f);
792
            this.roll = randomRange(-20.0f, 20.0f);
793
794
            this.yawVelocity = randomRange(-18.0f, 18.0f) * power;
795
            this.pitchVelocity = randomRange(-22.0f, 22.0f) * power;
796
            this.rollVelocity = randomRange(-24.0f, 24.0f) * power;
797
        }
798
799
        private boolean update() {
800
            long age = System.currentTimeMillis() - createdAtMs;
801
            if (age > DEATH_LIFE_MS) {
802
                return true;
803
            }
804
805
            prevPos = pos;
806
807
            velocity = velocity.add(0.0, -0.034, 0.0);
808
            velocity = new Vec3(
809
                    velocity.x * 0.985,
810
                    velocity.y * 0.965,
811
                    velocity.z * 0.985
812
            );
813
814
            pos = pos.add(velocity);
815
816
            if (mc.level != null) {
817
                BlockPos ground = BlockPos.containing(pos.x, pos.y - 0.035, pos.z);
818
                if (!mc.level.getBlockState(ground).isAir() && velocity.y < 0.0) {
819
                    pos = new Vec3(pos.x, ground.getY() + 1.035, pos.z);
820
821
                    if (Math.abs(velocity.y) > 0.045) {
822
                        velocity = new Vec3(
823
                                velocity.x * 0.72,
824
                                -velocity.y * 0.34,
825
                                velocity.z * 0.72
826
                        );
827
828
                        pitchVelocity *= 0.72f;
829
                        rollVelocity *= 0.72f;
830
                    } else {
831
                        velocity = new Vec3(
832
                                velocity.x * 0.62,
833
                                0.0,
834
                                velocity.z * 0.62
835
                        );
836
837
                        pitchVelocity *= 0.58f;
838
                        rollVelocity *= 0.58f;
839
                    }
840
                }
841
            }
842
843
            yaw += yawVelocity;
844
            pitch += pitchVelocity;
845
            roll += rollVelocity;
846
847
            yawVelocity *= 0.985f;
848
            pitchVelocity *= 0.975f;
849
            rollVelocity *= 0.975f;
850
851
            return false;
852
        }
853
    }
854
}
855