Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Shaders -> Fade, Aura -> ElytraTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
Pan4ur committed Jul 22, 2024
1 parent c4433a6 commit eaeebae
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 55 deletions.
63 changes: 33 additions & 30 deletions src/main/java/thunder/hack/core/impl/AddonManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/thunder/hack/core/impl/PlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/thunder/hack/core/impl/ProxyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/thunder/hack/core/impl/ShaderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -86,6 +88,7 @@ public ManagedShaderEffect getShader(@NotNull Shader mode) {
case Gradient -> GRADIENT;
case Smoke -> SMOKE;
case Snow -> SNOW;
case Fade -> FADE;
default -> DEFAULT;
};
}
Expand All @@ -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;
};
}
Expand Down Expand Up @@ -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());
}
}

Expand All @@ -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();
Expand Down Expand Up @@ -212,6 +234,7 @@ public enum Shader {
Default,
Smoke,
Gradient,
Snow
Snow,
Fade
}
}
33 changes: 33 additions & 0 deletions src/main/java/thunder/hack/injection/MixinFireWorkEntity.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
31 changes: 26 additions & 5 deletions src/main/java/thunder/hack/modules/client/Rotations.java
Original file line number Diff line number Diff line change
@@ -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;


Expand All @@ -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) {
Expand All @@ -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);
}
}
}
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/thunder/hack/modules/combat/Aura.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class Aura extends Module {
public final Setting<ESP> esp = new Setting<>("ESP", ESP.ThunderHack);
public final Setting<Sort> sort = new Setting<>("Sort", Sort.LowestDistance);
public final Setting<Boolean> lockTarget = new Setting<>("LockTarget", true);
public final Setting<Boolean> elytraTarget = new Setting<>("ElytraTarget", true);

/* ADVANCED */
public final Setting<SettingGroup> advanced = new Setting<>("Advanced", new SettingGroup(false, 0));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/thunder/hack/modules/combat/Breaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/thunder/hack/modules/render/Shaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Shaders() {
public final Setting<Float> factor = new Setting<>("GradientFactor", 2f, 0f, 20f, v -> mode.is(ShaderManager.Shader.Gradient) || handsMode.is(ShaderManager.Shader.Gradient));
public final Setting<Float> gradient = new Setting<>("Gradient", 2f, 0f, 20f, v -> mode.is(ShaderManager.Shader.Gradient) || handsMode.is(ShaderManager.Shader.Gradient));
public final Setting<Integer> alpha2 = new Setting<>("GradientAlpha", 170, 0, 255, v -> mode.is(ShaderManager.Shader.Gradient) || handsMode.is(ShaderManager.Shader.Gradient));
public final Setting<Integer> lineWidth = new Setting<>("LineWidth", 2, 0, 20);
public final Setting<Integer> lineWidth = new Setting<>("LineWidth", 2, 0, 100);
public final Setting<Integer> quality = new Setting<>("Quality", 3, 0, 20);
public final Setting<Integer> octaves = new Setting<>("SmokeOctaves", 10, 5, 30);
public final Setting<Integer> fillAlpha = new Setting<>("FillAlpha", 170, 0, 255);
Expand Down Expand Up @@ -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());
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/assets/thunderhack/shaders/post/fade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"targets": [
"bufIn",
"swap",
"bufOut"
],
"passes": [
{
"name": "thunderhack:fade",
"intarget": "bufIn",
"outtarget": "swap",
"uniforms": []
},
{
"name": "blit",
"intarget": "swap",
"outtarget": "bufOut",
"uniforms": []
}
]
}
Loading

0 comments on commit eaeebae

Please sign in to comment.