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

Commit

Permalink
Particles -> Physics, Better user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
Pan4ur committed Jan 27, 2024
1 parent b75aaaa commit 2f7712b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/main/java/thunder/hack/core/impl/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import org.lwjgl.glfw.GLFW;
import thunder.hack.ThunderHack;
import thunder.hack.cmd.Command;
import thunder.hack.core.IManager;
import thunder.hack.gui.clickui.normal.ClickUI;
import thunder.hack.gui.clickui.small.SmallClickUI;
import thunder.hack.gui.font.FontRenderers;
import thunder.hack.gui.hud.HudElement;
import thunder.hack.gui.hud.impl.*;
import thunder.hack.modules.Module;
import thunder.hack.modules.client.*;
Expand Down Expand Up @@ -294,7 +296,10 @@ public void onUpdate() {
}

public void onRender2D(DrawContext context) {
HudElement.anyHovered = false;
modules.stream().filter(Module::isEnabled).forEach(module -> module.onRender2D(context));
if(!HudElement.anyHovered && !ClickUI.anyHovered)
GLFW.glfwSetCursor(mc.getWindow().getHandle(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_CURSOR_NORMAL));
ThunderHack.core.onRender2D(context);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package thunder.hack.gui.clickui.impl;

import net.minecraft.client.gui.DrawContext;
import org.lwjgl.glfw.GLFW;
import thunder.hack.gui.clickui.AbstractElement;
import thunder.hack.gui.clickui.normal.ClickUI;
import thunder.hack.modules.client.ClickGui;
import thunder.hack.utility.math.MathUtility;
import thunder.hack.gui.font.FontRenderers;
Expand All @@ -11,6 +13,7 @@

import java.awt.*;

import static thunder.hack.modules.Module.mc;
import static thunder.hack.utility.render.animation.AnimationUtility.fast;

public class BooleanElement extends AbstractElement {
Expand All @@ -36,6 +39,12 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
Render2DEngine.drawRect(context.getMatrices(), (float) x + 4, (float) y, 1f, 15, ClickGui.getInstance().getColor(1));
}

if(hovered) {
GLFW.glfwSetCursor(mc.getWindow().getHandle(),
GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR));
ClickUI.anyHovered = true;
}

if(!isSmall()) {
FontRenderers.settings.drawString(context.getMatrices(), setting.getName(), (setting.parent != null ? 2f : 0f) + (x + 6), (y + height / 2 - (6 / 2f)) + 2, new Color(-1).getRGB());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis;
import org.lwjgl.glfw.GLFW;
import thunder.hack.gui.clickui.AbstractElement;
import thunder.hack.gui.clickui.normal.ClickUI;
import thunder.hack.gui.font.FontRenderers;
import thunder.hack.modules.client.ClickGui;
import thunder.hack.setting.Setting;
Expand All @@ -15,6 +17,7 @@
import java.awt.*;

import static thunder.hack.gui.clickui.normal.ClickUI.arrow;
import static thunder.hack.modules.Module.mc;
import static thunder.hack.utility.render.animation.AnimationUtility.fast;

public class BooleanParentElement extends AbstractElement {
Expand Down Expand Up @@ -57,6 +60,12 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
Color color = ClickGui.getInstance().getColor(0);
Render2DEngine.drawRound(context.getMatrices(),(float) (x + width - 36), (float) (y + height / 2 - 4), 15, 8, 4, paddingX > 4 ? color : new Color(0xFFB2B1B1));
Render2DEngine.drawRound(context.getMatrices(),(float) (x + width - 35 + paddingX), (float) (y + height / 2 - 3), 6, 6, 3, new Color(-1));

if(hovered) {
GLFW.glfwSetCursor(mc.getWindow().getHandle(),
GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR));
ClickUI.anyHovered = true;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import thunder.hack.ThunderHack;
import thunder.hack.cmd.Command;
import thunder.hack.gui.clickui.AbstractElement;
import thunder.hack.gui.clickui.normal.ClickUI;
import thunder.hack.gui.font.FontRenderers;
import thunder.hack.modules.client.ClickGui;
import thunder.hack.setting.Setting;
Expand All @@ -16,6 +17,8 @@
import java.awt.*;
import java.util.Objects;

import static thunder.hack.modules.Module.mc;

public class SliderElement extends AbstractElement {

private final float min, max;
Expand Down Expand Up @@ -53,6 +56,12 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {

animation = MathUtility.clamp(animation, 0, 1);

if(hovered) {
GLFW.glfwSetCursor(mc.getWindow().getHandle(),
GLFW.glfwCreateStandardCursor(GLFW.GLFW_HRESIZE_CURSOR));
ClickUI.anyHovered = true;
}

if (dragging)
setValue(mouseX, x + 7, width - 14);
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/thunder/hack/gui/clickui/normal/ClickUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ClickUI extends Screen {
private boolean firstOpen;
private float scrollY;
private boolean setup = false;
public static boolean anyHovered = false;

/*
0 - lang
Expand Down Expand Up @@ -105,6 +106,8 @@ public boolean shouldPause() {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
anyHovered = false;

if (ThunderHack.isOutdated && (mc.player == null || (mc.player.age % 20) > 10)) {
FontRenderers.thglitch.drawCenteredString(context.getMatrices(), "New version is available!", mc.getWindow().getScaledWidth() / 2f + 1, mc.getWindow().getScaledHeight() - 39 - FontRenderers.thglitch.getFontHeight("New version is available!"), Color.BLACK.getRGB());
FontRenderers.thglitch.drawCenteredString(context.getMatrices(), "New version is available!", mc.getWindow().getScaledWidth() / 2f, mc.getWindow().getScaledHeight() - 40 - FontRenderers.thglitch.getFontHeight("New version is available!"), -1);
Expand Down Expand Up @@ -246,6 +249,10 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
FontRenderers.sf_medium.drawString(context.getMatrices(), currentDescription, mouseX + 10, mouseY + 10, -1);
currentDescription = "";
}

if(!anyHovered)
GLFW.glfwSetCursor(mc.getWindow().getHandle(),
GLFW.glfwCreateStandardCursor(GLFW.GLFW_CURSOR_NORMAL));
}

@Override
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/thunder/hack/gui/hud/HudElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
import thunder.hack.events.impl.EventMouse;
import thunder.hack.gui.clickui.normal.ClickUI;
import thunder.hack.modules.Module;
import thunder.hack.setting.Setting;
import thunder.hack.setting.impl.PositionSetting;
Expand All @@ -15,6 +17,7 @@ public class HudElement extends Module {
private boolean mouseState = false, mouseButton = false;
private float x, y, dragX, dragY;
private int height, width;
public static boolean anyHovered = false;

public HudElement(String name, int width, int height) {
super(name, Category.HUD);
Expand All @@ -33,6 +36,7 @@ public void onRender2D(DrawContext context) {
pos.getValue().setY((normaliseY() - dragY) / mc.getWindow().getScaledHeight());
}
}

if (mouseButton) {
if (!mouseState && isHovering()) {
dragX = (int) (normaliseX() - (pos.getValue().getX() * mc.getWindow().getScaledWidth()));
Expand All @@ -42,6 +46,11 @@ public void onRender2D(DrawContext context) {
} else {
mouseState = false;
}

if(isHovering()) {
GLFW.glfwSetCursor(mc.getWindow().getHandle(), mouseState ? GLFW.glfwCreateStandardCursor(GLFW.GLFW_CROSSHAIR_CURSOR) : GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR));
anyHovered = true;
}
}

@EventHandler
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/thunder/hack/modules/render/Particles.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public Particles() {
private final Setting<Float> size = new Setting<>("Size", 1f, 0.1f, 6.0f);
private final Setting<ColorMode> lmode = new Setting<>("ColorMode", ColorMode.Sync);
private final Setting<ColorSetting> color = new Setting<>("Color", new ColorSetting(3649978), v -> lmode.getValue() == ColorMode.Custom);
private final Setting<Physics> physics = new Setting<>("Physics", Physics.Fly, v -> mode.getValue() != Mode.Off);


public enum ColorMode {
Custom, Sync
Expand All @@ -52,6 +54,9 @@ public enum Mode {
Off, SnowFlake, Stars, Hearts, Dollars, Bloom;
}

public enum Physics {
Drop, Fly
}

private final ArrayList<ParticleBase> fireFlies = new ArrayList<>();
private final ArrayList<ParticleBase> particles = new ArrayList<>();
Expand All @@ -73,14 +78,15 @@ public void onUpdate() {
}

for (int j = particles.size(); j < count.getValue(); j++) {
boolean drop = physics.getValue() == Physics.Drop;
if (mode.getValue() != Mode.Off)
particles.add(new ParticleBase(
(float) (mc.player.getX() + MathUtility.random(-48f, 48f)),
(float) (mc.player.getY() + MathUtility.random(2, 48f)),
(float) (mc.player.getZ() + MathUtility.random(-48f, 48f)),
MathUtility.random(-0.4f, 0.4f),
MathUtility.random(-0.1f, 0.1f),
MathUtility.random(-0.4f, 0.4f)));
drop ? 0 : MathUtility.random(-0.4f, 0.4f),
drop ? MathUtility.random(-0.2f, -0.05f) : MathUtility.random(-0.1f, 0.1f),
drop ? 0 : MathUtility.random(-0.4f, 0.4f)));
}
}

Expand Down Expand Up @@ -220,7 +226,8 @@ public boolean tick() {
posZ += motionZ;

motionX *= 0.9f;
motionY *= 0.9f;
if(physics.getValue() == Physics.Fly)
motionY *= 0.9f;
motionZ *= 0.9f;

motionY -= 0.001f;
Expand Down

0 comments on commit 2f7712b

Please sign in to comment.