diff --git a/src/main/java/thunder/hack/core/impl/AddonManager.java b/src/main/java/thunder/hack/core/impl/AddonManager.java index c33269f0..8aa66c50 100644 --- a/src/main/java/thunder/hack/core/impl/AddonManager.java +++ b/src/main/java/thunder/hack/core/impl/AddonManager.java @@ -52,40 +52,43 @@ public void initAddons() { ThunderHack.EVENT_BUS.registerLambdaFactory(addon.getPackage(), (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())); // Register Modules - addon.getModules().stream().filter(Objects::nonNull).forEach(module -> { - try { - LogUtils.getLogger().info("Registering module: " + module.getClass().getName()); - LogUtils.getLogger().debug("Module class loader: " + module.getClass().getClassLoader()); - ThunderHack.moduleManager.registerModule(module); - LogUtils.getLogger().info("Module registered successfully: " + module.getClass().getName()); - } catch (Exception e) { - LogUtils.getLogger().error("Error registering module: " + module.getClass().getName(), e); - } - }); + if (addon.getModules() != null) + addon.getModules().stream().filter(Objects::nonNull).forEach(module -> { + try { + LogUtils.getLogger().info("Registering module: " + module.getClass().getName()); + LogUtils.getLogger().debug("Module class loader: " + module.getClass().getClassLoader()); + ThunderHack.moduleManager.registerModule(module); + LogUtils.getLogger().info("Module registered successfully: " + module.getClass().getName()); + } catch (Exception e) { + LogUtils.getLogger().error("Error registering module: " + module.getClass().getName(), e); + } + }); // Register Commands - addon.getCommands().stream().filter(Objects::nonNull).forEach(command -> { - try { - LogUtils.getLogger().info("Registering command: " + command.getClass().getName()); - LogUtils.getLogger().debug("Command class loader: " + command.getClass().getClassLoader()); - ThunderHack.commandManager.registerCommand(command); - LogUtils.getLogger().info("Command registered successfully: " + command.getClass().getName()); - } catch (Exception e) { - LogUtils.getLogger().error("Error registering command: " + command.getClass().getName(), e); - } - }); + if (addon.getCommands() != null) + addon.getCommands().stream().filter(Objects::nonNull).forEach(command -> { + try { + LogUtils.getLogger().info("Registering command: " + command.getClass().getName()); + LogUtils.getLogger().debug("Command class loader: " + command.getClass().getClassLoader()); + ThunderHack.commandManager.registerCommand(command); + LogUtils.getLogger().info("Command registered successfully: " + command.getClass().getName()); + } catch (Exception e) { + LogUtils.getLogger().error("Error registering command: " + command.getClass().getName(), e); + } + }); // Register HUD Elements - addon.getHudElements().stream().filter(Objects::nonNull).forEach(hudElement -> { - try { - LogUtils.getLogger().info("Registering HUD element: " + hudElement.getClass().getName()); - LogUtils.getLogger().debug("HUD element class loader: " + hudElement.getClass().getClassLoader()); - ThunderHack.moduleManager.registerHudElement(hudElement); - LogUtils.getLogger().info("HUD element registered successfully: " + hudElement.getClass().getName()); - } catch (Exception e) { - LogUtils.getLogger().error("Error registering HUD element: " + hudElement.getClass().getName(), e); - } - }); + if (addon.getHudElements() != null) + addon.getHudElements().stream().filter(Objects::nonNull).forEach(hudElement -> { + try { + LogUtils.getLogger().info("Registering HUD element: " + hudElement.getClass().getName()); + LogUtils.getLogger().debug("HUD element class loader: " + hudElement.getClass().getClassLoader()); + ThunderHack.moduleManager.registerHudElement(hudElement); + LogUtils.getLogger().info("HUD element registered successfully: " + hudElement.getClass().getName()); + } catch (Exception e) { + LogUtils.getLogger().error("Error registering HUD element: " + hudElement.getClass().getName(), e); + } + }); } catch (Exception e) { LogUtils.getLogger().error("Error initializing addon: " + addon.getClass().getName(), e); diff --git a/src/main/java/thunder/hack/core/impl/PlayerManager.java b/src/main/java/thunder/hack/core/impl/PlayerManager.java index bda6f23f..801a3d4d 100644 --- a/src/main/java/thunder/hack/core/impl/PlayerManager.java +++ b/src/main/java/thunder/hack/core/impl/PlayerManager.java @@ -339,7 +339,7 @@ public static Vec2f calcAngleVec(Vec3d to) { return new Vec2f((float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(difZ, difX)) - 90.0), (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(difY, dist)))); } - private @NotNull Vec3d getRotationVector(float yaw, float pitch) { + public @NotNull Vec3d getRotationVector(float yaw, float pitch) { return new Vec3d(MathHelper.sin(-pitch * 0.017453292F) * MathHelper.cos(yaw * 0.017453292F), -MathHelper.sin(yaw * 0.017453292F), MathHelper.cos(-pitch * 0.017453292F) * MathHelper.cos(yaw * 0.017453292F)); } diff --git a/src/main/java/thunder/hack/core/impl/ProxyManager.java b/src/main/java/thunder/hack/core/impl/ProxyManager.java index 85a40b02..f2da2342 100644 --- a/src/main/java/thunder/hack/core/impl/ProxyManager.java +++ b/src/main/java/thunder/hack/core/impl/ProxyManager.java @@ -143,8 +143,6 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { - System.err.println("Exception caught: " + cause.getMessage()); - cause.printStackTrace(); ctx.close(); } } diff --git a/src/main/java/thunder/hack/core/impl/ShaderManager.java b/src/main/java/thunder/hack/core/impl/ShaderManager.java index f6afafa9..0870e0dd 100644 --- a/src/main/java/thunder/hack/core/impl/ShaderManager.java +++ b/src/main/java/thunder/hack/core/impl/ShaderManager.java @@ -27,11 +27,13 @@ public class ShaderManager implements IManager { public static ManagedShaderEffect SMOKE_OUTLINE; public static ManagedShaderEffect GRADIENT_OUTLINE; public static ManagedShaderEffect SNOW_OUTLINE; + public static ManagedShaderEffect FADE_OUTLINE; public static ManagedShaderEffect DEFAULT; public static ManagedShaderEffect SMOKE; public static ManagedShaderEffect GRADIENT; public static ManagedShaderEffect SNOW; + public static ManagedShaderEffect FADE; public void renderShader(Runnable runnable, Shader mode) { tasks.add(new RenderTask(runnable, mode)); @@ -86,6 +88,7 @@ public ManagedShaderEffect getShader(@NotNull Shader mode) { case Gradient -> GRADIENT; case Smoke -> SMOKE; case Snow -> SNOW; + case Fade -> FADE; default -> DEFAULT; }; } @@ -95,6 +98,7 @@ public ManagedShaderEffect getShaderOutline(@NotNull Shader mode) { case Gradient -> GRADIENT_OUTLINE; case Smoke -> SMOKE_OUTLINE; case Snow -> SNOW_OUTLINE; + case Fade -> FADE_OUTLINE; default -> DEFAULT_OUTLINE; }; } @@ -144,6 +148,15 @@ public void setupShader(Shader shader, ManagedShaderEffect effect) { effect.setUniformValue("time", time); effect.render(mc.getTickDelta()); time += 0.008f; + } else if (shader == Shader.Fade) { + effect.setUniformValue("alpha0", shaders.glow.getValue() ? -1.0f : shaders.outlineColor.getValue().getAlpha() / 255.0f); + effect.setUniformValue("lineWidth", shaders.lineWidth.getValue()); + effect.setUniformValue("quality", shaders.quality.getValue()); + effect.setUniformValue("outlinecolor", shaders.outlineColor.getValue().getGlRed(), shaders.outlineColor.getValue().getGlGreen(), shaders.outlineColor.getValue().getGlBlue(), shaders.outlineColor.getValue().getGlAlpha()); + effect.setUniformValue("primaryColor", shaders.fillColor1.getValue().getGlRed(), shaders.fillColor1.getValue().getGlGreen(), shaders.fillColor1.getValue().getGlBlue()); + effect.setUniformValue("secondaryColor", shaders.fillColor2.getValue().getGlRed(), shaders.fillColor2.getValue().getGlGreen(), shaders.fillColor2.getValue().getGlBlue()); + effect.setUniformValue("time", (float) ((System.currentTimeMillis() % 100000) / 1000f)); + effect.render(mc.getTickDelta()); } } @@ -152,6 +165,15 @@ public void reloadShaders() { SMOKE = ShaderEffectManager.getInstance().manage(new Identifier("thunderhack", "shaders/post/smoke.json")); GRADIENT = ShaderEffectManager.getInstance().manage(new Identifier("thunderhack", "shaders/post/gradient.json")); SNOW = ShaderEffectManager.getInstance().manage(new Identifier("thunderhack", "shaders/post/snow.json")); + FADE = ShaderEffectManager.getInstance().manage(new Identifier("thunderhack", "shaders/post/fade.json")); + + FADE_OUTLINE = ShaderEffectManager.getInstance().manage(new Identifier("thunderhack", "shaders/post/fade.json"), managedShaderEffect -> { + PostEffectProcessor effect = managedShaderEffect.getShaderEffect(); + if (effect == null) return; + + ((IShaderEffect) effect).addFakeTargetHook("bufIn", mc.worldRenderer.getEntityOutlinesFramebuffer()); + ((IShaderEffect) effect).addFakeTargetHook("bufOut", mc.worldRenderer.getEntityOutlinesFramebuffer()); + }); DEFAULT_OUTLINE = ShaderEffectManager.getInstance().manage(new Identifier("thunderhack", "shaders/post/outline.json"), managedShaderEffect -> { PostEffectProcessor effect = managedShaderEffect.getShaderEffect(); @@ -212,6 +234,7 @@ public enum Shader { Default, Smoke, Gradient, - Snow + Snow, + Fade } } diff --git a/src/main/java/thunder/hack/injection/MixinFireWorkEntity.java b/src/main/java/thunder/hack/injection/MixinFireWorkEntity.java new file mode 100644 index 00000000..f86ac5ae --- /dev/null +++ b/src/main/java/thunder/hack/injection/MixinFireWorkEntity.java @@ -0,0 +1,33 @@ +package thunder.hack.injection; + +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.projectile.FireworkRocketEntity; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import thunder.hack.ThunderHack; +import thunder.hack.core.impl.ModuleManager; +import thunder.hack.core.impl.PlayerManager; +import thunder.hack.modules.combat.Aura; + +import static thunder.hack.core.IManager.mc; + +@Mixin(FireworkRocketEntity.class) +public class MixinFireWorkEntity { + + @Shadow + private LivingEntity shooter; + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getRotationVector()Lnet/minecraft/util/math/Vec3d;")) + private Vec3d tickHook(LivingEntity instance) { + if (ModuleManager.aura.isEnabled() && ModuleManager.aura.rotationMode.not(Aura.Mode.None) + && ModuleManager.aura.target != null && shooter == mc.player && ModuleManager.aura.elytraTarget.getValue()) { + + // float[] nonLimitedRotation = PlayerManager.calcAngle(ModuleManager.aura.target.getEyePos().add(0, 0.5, 0)); + return ThunderHack.playerManager.getRotationVector(ModuleManager.aura.rotationPitch, ModuleManager.aura.rotationYaw); + } + return shooter.getRotationVector(); + } +} diff --git a/src/main/java/thunder/hack/modules/client/Rotations.java b/src/main/java/thunder/hack/modules/client/Rotations.java index bb78a00b..714f5e93 100644 --- a/src/main/java/thunder/hack/modules/client/Rotations.java +++ b/src/main/java/thunder/hack/modules/client/Rotations.java @@ -1,12 +1,17 @@ package thunder.hack.modules.client; +import net.minecraft.item.FireworkRocketItem; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; +import thunder.hack.ThunderHack; +import thunder.hack.core.impl.ModuleManager; +import thunder.hack.core.impl.PlayerManager; import thunder.hack.events.impl.EventFixVelocity; import thunder.hack.events.impl.EventKeyboardInput; import thunder.hack.events.impl.EventPlayerJump; import thunder.hack.events.impl.EventPlayerTravel; import thunder.hack.modules.Module; +import thunder.hack.modules.combat.Aura; import thunder.hack.setting.Setting; @@ -23,16 +28,16 @@ private enum MoveFix { } public float fixRotation; - private float prevRotation; + private float prevYaw, prevPitch; public void onJump(EventPlayerJump e) { if (Float.isNaN(fixRotation) || moveFix.getValue() == MoveFix.Off || mc.player.isRiding()) return; if (e.isPre()) { - prevRotation = mc.player.getYaw(); + prevYaw = mc.player.getYaw(); mc.player.setYaw(fixRotation); - } else mc.player.setYaw(prevRotation); + } else mc.player.setYaw(prevYaw); } public void onPlayerMove(EventFixVelocity event) { @@ -44,12 +49,28 @@ public void onPlayerMove(EventFixVelocity event) { } public void modifyVelocity(EventPlayerTravel e) { + if (ModuleManager.aura.isEnabled() && ModuleManager.aura.target != null && ModuleManager.aura.rotationMode.not(Aura.Mode.None) + && ModuleManager.aura.elytraTarget.getValue() && ThunderHack.playerManager.ticksElytraFlying > 5) { + if (e.isPre()) { + prevYaw = mc.player.getYaw(); + prevPitch = mc.player.getPitch(); + + mc.player.setYaw(fixRotation); + mc.player.setPitch(ModuleManager.aura.rotationPitch); + } else { + mc.player.setYaw(prevYaw); + mc.player.setPitch(prevPitch); + } + return; + } + + if (moveFix.getValue() == MoveFix.Focused && !Float.isNaN(fixRotation) && !mc.player.isRiding()) { if (e.isPre()) { - prevRotation = mc.player.getYaw(); + prevYaw = mc.player.getYaw(); mc.player.setYaw(fixRotation); } else { - mc.player.setYaw(prevRotation); + mc.player.setYaw(prevYaw); } } } diff --git a/src/main/java/thunder/hack/modules/combat/Aura.java b/src/main/java/thunder/hack/modules/combat/Aura.java index 0d1ab5a4..e84abdfb 100644 --- a/src/main/java/thunder/hack/modules/combat/Aura.java +++ b/src/main/java/thunder/hack/modules/combat/Aura.java @@ -87,6 +87,7 @@ public class Aura extends Module { public final Setting esp = new Setting<>("ESP", ESP.ThunderHack); public final Setting sort = new Setting<>("Sort", Sort.LowestDistance); public final Setting lockTarget = new Setting<>("LockTarget", true); + public final Setting elytraTarget = new Setting<>("ElytraTarget", true); /* ADVANCED */ public final Setting advanced = new Setting<>("Advanced", new SettingGroup(false, 0)); @@ -139,7 +140,9 @@ public class Aura extends Module { public static Entity target; - public float rotationYaw, rotationPitch, pitchAcceleration = 1f, prevYaw; + public float rotationYaw; + public float rotationPitch; + public float pitchAcceleration = 1f; private Vec3d rotationPoint = Vec3d.ZERO; private Vec3d rotationMotion = Vec3d.ZERO; @@ -518,18 +521,12 @@ private void calcRotations(boolean ready) { float delta_pitch = ((float) (-Math.toDegrees(Math.atan2(targetVec.y - (mc.player.getPos().y + mc.player.getEyeHeight(mc.player.getPose())), Math.sqrt(Math.pow((targetVec.x - mc.player.getX()), 2) + Math.pow(targetVec.z - mc.player.getZ(), 2))))) - rotationPitch); float yawStep = rotationMode.getValue() != Mode.Track ? 360f : random(minYawStep.getValue(), maxYawStep.getValue()); - float pitchStep = rotationMode.getValue() != Mode.Track ? 180f : pitchAcceleration + random(-1f, 1f); + float pitchStep = rotationMode.getValue() != Mode.Track ? 180f : ThunderHack.playerManager.ticksElytraFlying > 5 ? 180 : (pitchAcceleration + random(-1f, 1f)); if (ready) switch (accelerateOnHit.getValue()) { - case Off -> { - } - case Yaw -> { - yawStep = 180f; - } - case Pitch -> { - pitchStep = 90f; - } + case Yaw -> yawStep = 180f; + case Pitch -> pitchStep = 90f; case Both -> { yawStep = 180f; pitchStep = 90f; diff --git a/src/main/java/thunder/hack/modules/combat/Breaker.java b/src/main/java/thunder/hack/modules/combat/Breaker.java index 6979b415..bfae33e5 100644 --- a/src/main/java/thunder/hack/modules/combat/Breaker.java +++ b/src/main/java/thunder/hack/modules/combat/Breaker.java @@ -51,11 +51,10 @@ public Breaker() { private void onSync(EventSync event) { PlayerEntity target; - if (targetMode.is(Target.Breaker)) { + if (targetMode.is(Target.Breaker)) target = ThunderHack.combatManager.getTarget(range.getValue(), targetBy.getValue()); - } else { + else target = AutoCrystal.target; - } if (target == null) return; diff --git a/src/main/java/thunder/hack/modules/render/Shaders.java b/src/main/java/thunder/hack/modules/render/Shaders.java index 4de8c238..9c4a0dae 100644 --- a/src/main/java/thunder/hack/modules/render/Shaders.java +++ b/src/main/java/thunder/hack/modules/render/Shaders.java @@ -37,7 +37,7 @@ public Shaders() { public final Setting factor = new Setting<>("GradientFactor", 2f, 0f, 20f, v -> mode.is(ShaderManager.Shader.Gradient) || handsMode.is(ShaderManager.Shader.Gradient)); public final Setting gradient = new Setting<>("Gradient", 2f, 0f, 20f, v -> mode.is(ShaderManager.Shader.Gradient) || handsMode.is(ShaderManager.Shader.Gradient)); public final Setting alpha2 = new Setting<>("GradientAlpha", 170, 0, 255, v -> mode.is(ShaderManager.Shader.Gradient) || handsMode.is(ShaderManager.Shader.Gradient)); - public final Setting lineWidth = new Setting<>("LineWidth", 2, 0, 20); + public final Setting lineWidth = new Setting<>("LineWidth", 2, 0, 100); public final Setting quality = new Setting<>("Quality", 3, 0, 20); public final Setting octaves = new Setting<>("SmokeOctaves", 10, 5, 30); public final Setting fillAlpha = new Setting<>("FillAlpha", 170, 0, 255); @@ -80,8 +80,6 @@ public boolean shouldRender(Entity entity) { }; } - public static boolean rendering = false; - public void onRender3D(MatrixStack matrices) { if (hands.getValue()) ThunderHack.shaderManager.renderShader(() -> ((IGameRenderer) mc.gameRenderer).irenderHand(mc.gameRenderer.getCamera(), mc.getTickDelta(), matrices.peek().getPositionMatrix()), handsMode.getValue()); diff --git a/src/main/resources/assets/thunderhack/shaders/post/fade.json b/src/main/resources/assets/thunderhack/shaders/post/fade.json new file mode 100644 index 00000000..9509e9c8 --- /dev/null +++ b/src/main/resources/assets/thunderhack/shaders/post/fade.json @@ -0,0 +1,21 @@ +{ + "targets": [ + "bufIn", + "swap", + "bufOut" + ], + "passes": [ + { + "name": "thunderhack:fade", + "intarget": "bufIn", + "outtarget": "swap", + "uniforms": [] + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "bufOut", + "uniforms": [] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/thunderhack/shaders/program/fade.fsh b/src/main/resources/assets/thunderhack/shaders/program/fade.fsh new file mode 100644 index 00000000..9d2e92bb --- /dev/null +++ b/src/main/resources/assets/thunderhack/shaders/program/fade.fsh @@ -0,0 +1,54 @@ +#version 150 + +in vec2 texCoord; +out vec4 fragColor; + +uniform sampler2D DiffuseSampler; +uniform vec3 primaryColor; +uniform vec3 secondaryColor; +uniform float time; +uniform vec2 InSize; + +uniform vec4 outlinecolor; +uniform float alpha0; +uniform int quality; +uniform int lineWidth; +in vec2 oneTexel; + +vec3 wave(vec2 pos) +{ + return mix(primaryColor, secondaryColor, sin((distance(vec2(0), pos) - time * 60.0) / 60.) * 0.5 + 0.5); +} + +void main() +{ + + vec4 centerCol = texture(DiffuseSampler, texCoord); + + if (centerCol.a != 0) { + fragColor = vec4(wave(gl_FragCoord.xy), 1); + } else { + float alphaOutline = 0; + vec3 colorFinal = vec3(-1); + for (int x = -quality; x < quality; x++) { + for (int y = -quality; y < quality; y++) { + vec2 offset = vec2(x, y); + vec2 coord = texCoord + offset * oneTexel; + vec4 t = texture(DiffuseSampler, coord); + if (t.a != 0){ + if (alpha0 == -1.0) { + if (colorFinal[0] == -1) { + colorFinal = outlinecolor.rgb; + } + alphaOutline += outlinecolor.a * 255.0 > 0 ? max(0, (lineWidth - distance(vec2(x, y), vec2(0))) / (outlinecolor.a * 255.0)) : 1; + } + else { + fragColor = vec4(outlinecolor.rgb, alpha0); + return; + } + } + } + } + fragColor = vec4(colorFinal, alphaOutline); + } +} diff --git a/src/main/resources/assets/thunderhack/shaders/program/fade.json b/src/main/resources/assets/thunderhack/shaders/program/fade.json new file mode 100644 index 00000000..e816422b --- /dev/null +++ b/src/main/resources/assets/thunderhack/shaders/program/fade.json @@ -0,0 +1,27 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "sobel", + "fragment": "thunderhack:fade", + "attributes": [ + "Position" + ], + "samplers": [ + {"name": "DiffuseSampler"} + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]}, + { "name": "InSize", "type": "float", "count": 2, "values": [1.0, 1.0]}, + { "name": "OutSize", "type": "float", "count": 2, "values": [1.0, 1.0]}, + { "name": "primaryColor", "type": "float", "count": 3, "values": [1.0, 1.0, 1.0]}, + { "name": "secondaryColor", "type": "float", "count": 3, "values": [1.0, 1.0, 1.0]}, + { "name": "time", "type": "float", "count": 1, "values": [ 1.0] }, + { "name": "outlinecolor", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, + { "name": "lineWidth", "type": "int", "count": 1, "values": [ 1.0] }, + { "name": "alpha0", "type": "float", "count": 1, "values": [ 1.0] }, + { "name": "quality", "type": "int", "count": 1, "values": [ 1.0] } + ] +} \ No newline at end of file diff --git a/src/main/resources/thunderhack.mixins.json b/src/main/resources/thunderhack.mixins.json index 872dded6..1d7b2781 100644 --- a/src/main/resources/thunderhack.mixins.json +++ b/src/main/resources/thunderhack.mixins.json @@ -75,6 +75,7 @@ "MixinEndCrystal", "MixinEntity", "MixinEntityLiving", + "MixinFireWorkEntity", "MixinFlowableFluid", "MixinPlayerEntity", "MixinPlayerEntityRenderer",