HitParticles module

HitParticles: Minecraft 26.3 cheat module, full source for every implementation (1 client: MelaHack (ThunderHack fork)).

1 implementationRENDER

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.

MelaHack (ThunderHack fork)RENDERsrc/main/java/thunder/hack/features/modules/render/HitParticles.javaJava · 233 lines · 9.4 KB

Spawns particles on hit.

SettingsModePhysicsColorSelfAmountLifeTimeSpeedScaleColorModeHealColorDamageColor
HitParticles.javaJava · Minecraft 26.2 · 233 lines · 9.4 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.render;
2
3
import thunder.hack.utility.render.compat.RenderSystem;
4
import thunder.hack.gui.font.FontRenderers;
5
import thunder.hack.features.modules.Module;
6
import thunder.hack.features.modules.client.HudEditor;
7
import thunder.hack.setting.Setting;
8
import thunder.hack.setting.impl.ColorSetting;
9
import thunder.hack.utility.math.MathUtility;
10
import thunder.hack.utility.render.Render2DEngine;
11
import thunder.hack.utility.render.Render3DEngine;
12
import thunder.hack.utility.render.animation.AnimationUtility;
13
14
import java.awt.*;
15
import java.util.HashMap;
16
import java.util.concurrent.CopyOnWriteArrayList;
17
import net.minecraft.core.BlockPos;
18
import net.minecraft.world.entity.Entity;
19
import net.minecraft.world.entity.LivingEntity;
20
import net.minecraft.world.entity.player.Player;
21
import net.minecraft.world.level.block.AirBlock;
22
import net.minecraft.world.level.block.Block;
23
import net.minecraft.world.level.block.Blocks;
24
25
import static thunder.hack.utility.render.Render2DEngine.*;
26
27
import com.mojang.blaze3d.vertex.PoseStack;
28
import com.mojang.math.Axis;
29
30
public class HitParticles extends Module {
31
    public HitParticles() {
32
        super("HitParticles", Category.RENDER);
33
    }
34
35
    private final Setting<Mode> mode = new Setting<>("Mode", Mode.Stars);
36
    private final Setting<Physics> physics = new Setting<>("Physics", Physics.Fall);
37
    private final Setting<ColorSetting> colorrr = new Setting<>("Color", new ColorSetting(0x8800FF00));
38
    private final Setting<Boolean> onlySelf = new Setting<>("Self", false);
39
    private final Setting<Integer> amount = new Setting<>("Amount", 2, 1, 5);
40
    private final Setting<Integer> lifeTime = new Setting<>("LifeTime", 2, 1, 10);
41
    private final Setting<Integer> speed = new Setting<>("Speed", 2, 1, 20);
42
    private final Setting<Float> starsScale = new Setting<>("Scale", 3f, 1f, 10f, v -> mode.getValue() != Mode.Orbiz);
43
    private final Setting<ColorMode> colorMode = new Setting<>("ColorMode", ColorMode.Sync);
44
    private final Setting<ColorSetting> colorH = new Setting<>("HealColor", new ColorSetting(3142544), v -> mode.is(Mode.Text));
45
    private final Setting<ColorSetting> colorD = new Setting<>("DamageColor", new ColorSetting(15811379), v -> mode.is(Mode.Text));
46
47
    private final HashMap<Integer, Float> healthMap = new HashMap<>();
48
    private final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList<>();
49
50
    @Override
51
    public void onUpdate() {
52
        particles.removeIf(Particle::update);
53
54
        if (mode.is(Mode.Text)) {
55
            for (Entity entity : mc.level.entitiesForRendering()) {
56
                if (entity == null || mc.player.distanceToSqr(entity) > 256f || !entity.isAlive() || !(entity instanceof LivingEntity lent))
57
                    continue;
58
59
                Color c = colorMode.getValue() == ColorMode.Sync ? HudEditor.getColor((int) MathUtility.random(1, 228)) : colorrr.getValue().getColorObject();
60
                float health = lent.getHealth() + lent.getAbsorptionAmount();
61
                float lastHealth = healthMap.getOrDefault(entity.getId(), health);
62
                healthMap.put(entity.getId(), health);
63
                if (lastHealth == health)
64
                    continue;
65
66
                particles.add(new Particle((float) lent.getX(), MathUtility.random((float) (lent.getY() + lent.getBbHeight()), (float) lent.getY()), (float) lent.getZ(), c,
67
                        MathUtility.random(0, 180), MathUtility.random(10f, 60f), health - lastHealth));
68
            }
69
            return;
70
        }
71
72
        for (Player player : mc.level.players()) {
73
            if (onlySelf.getValue() && player != mc.player)
74
                continue;
75
            if (player.hurtTime > 0) {
76
                Color c = colorMode.getValue() == ColorMode.Sync ? HudEditor.getColor((int) MathUtility.random(1, 228)) : colorrr.getValue().getColorObject();
77
                for (int i = 0; i < amount.getValue(); i++) {
78
                    particles.add(new Particle((float) player.getX(), MathUtility.random((float) (player.getY() + player.getBbHeight()), (float) player.getY()), (float) player.getZ(), c, MathUtility.random(0, 180), MathUtility.random(10f, 60f), 0));
79
                }
80
            }
81
        }
82
    }
83
84
    public void onRender3D(PoseStack stack) {
85
        RenderSystem.disableDepthTest();
86
        if (mc.player != null && mc.level != null) {
87
            for (Particle particle : particles) {
88
                particle.render(stack);
89
            }
90
        }
91
        RenderSystem.enableDepthTest();
92
    }
93
94
    public class Particle {
95
        float x;
96
        float y;
97
        float z;
98
99
        float px;
100
        float py;
101
        float pz;
102
103
        float motionX;
104
        float motionY;
105
        float motionZ;
106
107
        float rotationAngle;
108
        float rotationSpeed;
109
        float health;
110
111
        long time;
112
        Color color;
113
114
        public Particle(float x, float y, float z, Color color, float rotationAngle, float rotationSpeed, float health) {
115
            this.x = x;
116
            this.y = y;
117
            this.z = z;
118
            px = x;
119
            py = y;
120
            pz = z;
121
            motionX = MathUtility.random(-(float) speed.getValue() / 50f, (float) speed.getValue() / 50f);
122
            motionY = MathUtility.random(-(float) speed.getValue() / 50f, (float) speed.getValue() / 50f);
123
            motionZ = MathUtility.random(-(float) speed.getValue() / 50f, (float) speed.getValue() / 50f);
124
            time = System.currentTimeMillis();
125
            this.color = color;
126
            this.rotationAngle = rotationAngle;
127
            this.rotationSpeed = rotationSpeed;
128
            this.health = health;
129
        }
130
131
        public long getTime() {
132
            return time;
133
        }
134
135
        public boolean update() {
136
            double sp = Math.sqrt(motionX * motionX + motionZ * motionZ);
137
            px = x;
138
            py = y;
139
            pz = z;
140
141
            x += motionX;
142
            y += motionY;
143
            z += motionZ;
144
145
            if (posBlock(x, y - starsScale.getValue() / 10f, z)) {
146
                motionY = -motionY / 1.1f;
147
                motionX = motionX / 1.1f;
148
                motionZ = motionZ / 1.1f;
149
            } else {
150
                if (posBlock(x - sp, y, z - sp)
151
                        || posBlock(x + sp, y, z + sp)
152
                        || posBlock(x + sp, y, z - sp)
153
                        || posBlock(x - sp, y, z + sp)
154
                        || posBlock(x + sp, y, z)
155
                        || posBlock(x - sp, y, z)
156
                        || posBlock(x, y, z + sp)
157
                        || posBlock(x, y, z - sp)
158
                ) {
159
                    motionX = -motionX;
160
                    motionZ = -motionZ;
161
                }
162
            }
163
164
            if (physics.getValue() == Physics.Fall)
165
                motionY -= 0.035f;
166
167
            motionX /= 1.005f;
168
            motionZ /= 1.005f;
169
            motionY /= 1.005f;
170
171
            return System.currentTimeMillis() - getTime() > lifeTime.getValue() * 1000;
172
        }
173
174
        public void render(PoseStack matrixStack) {
175
            float size = starsScale.getValue();
176
            float scale = mode.is(Mode.Text) ? 0.025f * size : 0.07f;
177
178
            final double posX = Render2DEngine.interpolate(px, x, Render3DEngine.getTickDelta()) - mc.getEntityRenderDispatcher().camera.position().x;
179
            final double posY = Render2DEngine.interpolate(py, y, Render3DEngine.getTickDelta()) + 0.1 - mc.getEntityRenderDispatcher().camera.position().y;
180
            final double posZ = Render2DEngine.interpolate(pz, z, Render3DEngine.getTickDelta()) - mc.getEntityRenderDispatcher().camera.position().z;
181
182
            matrixStack.pushPose();
183
            matrixStack.translate(posX, posY, posZ);
184
185
            matrixStack.scale(scale, scale, scale);
186
187
            matrixStack.translate(size / 2, size / 2, size / 2);
188
            matrixStack.mulPose(Axis.YP.rotationDegrees(-mc.gameRenderer.mainCamera().yRot()));
189
            matrixStack.mulPose(Axis.XP.rotationDegrees(mc.gameRenderer.mainCamera().xRot()));
190
191
            if (mode.is(Mode.Text))
192
                matrixStack.mulPose(Axis.ZP.rotationDegrees(180));
193
            else
194
                matrixStack.mulPose(Axis.ZP.rotationDegrees(rotationAngle += (float) (AnimationUtility.deltaTime() * rotationSpeed)));
195
196
            matrixStack.translate(-size / 2, -size / 2, -size / 2);
197
198
            switch (mode.getValue()) {
199
                case Orbiz -> {
200
                    drawOrbiz(matrixStack, 0.0f, 0.3, color);
201
                    drawOrbiz(matrixStack, -0.1f, 0.5, color);
202
                    drawOrbiz(matrixStack, -0.2f, 0.7, color);
203
                }
204
                case Stars -> drawStar(matrixStack, color, size);
205
                case Hearts -> drawHeart(matrixStack, color, size);
206
                case Bloom -> drawBloom(matrixStack, color, size);
207
                case Text ->
208
                        FontRenderers.sf_medium.drawCenteredString(matrixStack, MathUtility.round2(health) + " ", 0, 0, (health > 0 ? colorH.getValue() : colorD.getValue()).getColorObject());
209
            }
210
211
            matrixStack.scale(0.8f, 0.8f, 0.8f);
212
            matrixStack.popPose();
213
        }
214
215
        private boolean posBlock(double x, double y, double z) {
216
            Block b = mc.level.getBlockState(BlockPos.containing(x, y, z)).getBlock();
217
            return (!(b instanceof AirBlock) && b != Blocks.WATER && b != Blocks.LAVA);
218
        }
219
    }
220
221
    public enum Physics {
222
        Fall, Fly
223
    }
224
225
    public enum Mode {
226
        Orbiz, Stars, Hearts, Bloom, Text
227
    }
228
229
    public enum ColorMode {
230
        Custom, Sync
231
    }
232
}
233