Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathHelper & unused imports #266

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import meteordevelopment.meteorclient.gui.utils.AlignmentX;
import meteordevelopment.meteorclient.gui.widgets.pressable.WPressable;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.util.math.MathHelper;

import static meteordevelopment.meteorclient.MeteorClient.mc;
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
Expand Down Expand Up @@ -66,10 +66,10 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub
double pad = pad();

animationProgress1 += delta * 4 * ((module.isActive() || mouseOver) ? 1 : -1);
animationProgress1 = Math.max(0, Math.min(1, animationProgress1));
animationProgress1 = MathHelper.clamp(animationProgress1, 0, 1);

animationProgress2 += delta * 6 * (module.isActive() ? 1 : -1);
animationProgress2 = Math.max(0, Math.min(1, animationProgress2));
animationProgress2 = MathHelper.clamp(animationProgress2, 0, 1);

if (animationProgress1 > 0) {
renderer.quad(x, y, width * animationProgress1, height, theme.moduleBackground.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import meteordevelopment.meteorclient.gui.widgets.containers.WContainer;
import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.render.color.Color;
import net.minecraft.util.math.MathHelper;

public class WMeteorTextBox extends WTextBox implements MeteorWidget {
private boolean cursorVisible;
Expand Down Expand Up @@ -68,7 +68,7 @@ else if (placeholder != null) {

// Cursor
animProgress += delta * 10 * (focused && cursorVisible ? 1 : -1);
animProgress = Math.max(0, Math.min(1, animProgress));
animProgress = MathHelper.clamp(animProgress, 0, 1);

if ((focused && cursorVisible) || animProgress > 0) {
renderer.setAlpha(animProgress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import meteordevelopment.meteorclient.gui.renderer.GuiRenderer;
import anticope.rejects.gui.themes.rounded.MeteorWidget;
import meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox;
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.util.math.MathHelper;

public class WMeteorCheckbox extends WCheckbox implements MeteorWidget {
private double animProgress;
Expand All @@ -25,7 +25,7 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub
MeteorRoundedGuiTheme theme = theme();

animProgress += (checked ? 1 : -1) * delta * 14;
animProgress = Math.max(0, Math.min(1, animProgress));
animProgress = MathHelper.clamp(animProgress, 0, 1);

renderBackground(renderer, this, pressed, mouseOver);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/anticope/rejects/modules/Confuse.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.entity.SortPriority;
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
import meteordevelopment.meteorclient.utils.render.color.Color;
Expand All @@ -15,6 +14,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;

Expand Down Expand Up @@ -155,7 +155,7 @@ private void onTick(TickEvent.Pre event) {

case Switch:
Vec3d diff = entityPos.subtract(playerPos);
Vec3d diff1 = new Vec3d(Math.max(-halfRange, Math.min(halfRange, diff.x)), Math.max(-halfRange, Math.min(halfRange, diff.y)), Math.max(-halfRange, Math.min(halfRange, diff.z)));
Vec3d diff1 = new Vec3d(MathHelper.clamp(diff.x, -halfRange, halfRange), MathHelper.clamp(diff.y, -halfRange, halfRange), MathHelper.clamp(diff.z, -halfRange, halfRange));
Vec3d goal2 = entityPos.add(diff1);
hit = mc.world.raycast(new RaycastContext(mc.player.getPos(), goal2, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player));
if (!moveThroughBlocks.get() && hit.isInsideBlock()) {
Expand Down