Skip to content

Commit

Permalink
Converted doubles to floats.
Browse files Browse the repository at this point in the history
No need for extra precision!
  • Loading branch information
coltonk9043 committed Jul 29, 2023
1 parent 0ad6528 commit f20ff52
Show file tree
Hide file tree
Showing 32 changed files with 136 additions and 138 deletions.
6 changes: 3 additions & 3 deletions src/main/java/net/aoba/core/settings/SettingManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.aoba.core.settings;

import net.aoba.core.settings.types.DoubleSetting;
import net.aoba.core.settings.types.FloatSetting;
import net.aoba.core.settings.types.IntegerSetting;
import net.aoba.core.utils.types.Vector2;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -78,7 +78,7 @@ public static void loadSettings(String name, List<Setting> setting_list) {
if (value == null) break;
switch (setting.type) {
case DOUBLE -> {
if (((DoubleSetting) setting).min_value <= Double.parseDouble(value) && ((DoubleSetting) setting).max_value >= Double.parseDouble(value)) {
if (((FloatSetting) setting).min_value <= Double.parseDouble(value) && ((FloatSetting) setting).max_value >= Double.parseDouble(value)) {
if (DEBUG_STUFF) System.out.println(setting.displayName + " " + setting.value + " " + Double.parseDouble(value));
setting.setValue(Double.parseDouble(value));
}
Expand All @@ -105,7 +105,7 @@ public static void loadSettings(String name, List<Setting> setting_list) {
String value_y = config.getProperty(setting.ID + "_y", null);
if (value_x == null || value_y == null) break;
/* if (DEBUG_STUFF) */ System.out.println(setting.displayName + " " + ((Vector2)setting.value).x + " " + ((Vector2)setting.value).y + " " + value_x + " " + value_y);
setting.setValue(new Vector2(Double.parseDouble(value_x), Double.parseDouble(value_y)));
setting.setValue(new Vector2(Float.parseFloat(value_x), Float.parseFloat(value_y)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
import net.aoba.core.settings.Setting;
import java.util.function.Consumer;

public class DoubleSetting extends Setting<Double> {
public class FloatSetting extends Setting<Double> {
public final double min_value;
public final double max_value;
public final double step;

public DoubleSetting(String ID, String description, double default_value, double min_value, double max_value, double step) {
public FloatSetting(String ID, String description, double default_value, double min_value, double max_value, double step) {
super(ID, description, default_value);
this.min_value = min_value;
this.max_value = max_value;
this.step = step;
type = TYPE.DOUBLE;
}

public DoubleSetting(String ID, String displayName, String description, double default_value, double min_value, double max_value, double step) {
public FloatSetting(String ID, String displayName, String description, double default_value, double min_value, double max_value, double step) {
super(ID, displayName, description, default_value);
this.min_value = min_value;
this.max_value = max_value;
this.step = step;
type = TYPE.DOUBLE;
}

public DoubleSetting(String ID, String description, double default_value, double min_value, double max_value, double step, Consumer<Double> onUpdate) {
public FloatSetting(String ID, String description, double default_value, double min_value, double max_value, double step, Consumer<Double> onUpdate) {
super(ID, description, default_value, onUpdate);
this.min_value = min_value;
this.max_value = max_value;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/aoba/core/utils/types/Vector2.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.aoba.core.utils.types;

public class Vector2 {
public double x = 0;
public double y = 0;
public float x = 0;
public float y = 0;

public Vector2() {}
public Vector2(double x, double y) {
public Vector2(float x, float y) {
this.x = x;
this.y = y;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/aoba/gui/HudManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import net.aoba.core.settings.SettingManager;
import net.aoba.core.settings.types.BooleanSetting;
import net.aoba.core.settings.types.DoubleSetting;
import net.aoba.core.settings.types.FloatSetting;

import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
Expand Down Expand Up @@ -53,8 +53,8 @@ public class HudManager {

public NavigationBar clickGuiNavBar;

public DoubleSetting hue = new DoubleSetting("color_hue", "Hue", 4, 0, 360, 1, null);
public DoubleSetting effectSpeed = new DoubleSetting("color_speed", "Effect Spd", 4, 1, 20, 0.1, null);
public FloatSetting hue = new FloatSetting("color_hue", "Hue", 4, 0, 360, 1, null);
public FloatSetting effectSpeed = new FloatSetting("color_speed", "Effect Spd", 4, 1, 20, 0.1, null);
public BooleanSetting rainbow = new BooleanSetting("rainbow_mode", "Rainbow", false, null);
public BooleanSetting ah = new BooleanSetting("armorhud_toggle", "ArmorHUD", false, null);

Expand Down Expand Up @@ -97,7 +97,7 @@ public HudManager() {
hudPane.AddHud(radarHud);
hudPane.AddHud(infoHud);

settingsPane.AddHud(new OptionsTab("Options", 370, 500, hue, rainbow, ah, effectSpeed));
settingsPane.AddHud(new OptionsTab());

int xOffset = 335;
for (Category category : Module.Category.values()) {
Expand Down Expand Up @@ -155,8 +155,8 @@ public void update() {
if (!mouseClicked)
currentGrabbed = null;
else if (currentGrabbed != null) {
int newX = Math.max(0, currentGrabbed.getX() - (lastMouseX - dx));
int newY = Math.max(0, currentGrabbed.getY() - (lastMouseY - dy));
float newX = Math.max(0, currentGrabbed.getX() - (lastMouseX - dx));
float newY = Math.max(0, currentGrabbed.getY() - (lastMouseY - dy));

currentGrabbed.setX(newX);
currentGrabbed.setY(newY);
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/aoba/gui/IMoveable.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package net.aoba.gui;

public interface IMoveable {
public int getX();
public int getY();
public int getHeight();
public int getWidth();
public void setX(int x);
public void setY(int y);
public void setWidth(int width);
public void setHeight(int height);
public float getX();
public float getY();
public float getHeight();
public float getWidth();
public void setX(float x);
public void setY(float y);
public void setWidth(float width);
public void setHeight(float height);
}
29 changes: 15 additions & 14 deletions src/main/java/net/aoba/gui/hud/AbstractHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import java.util.function.Consumer;

public abstract class AbstractHud implements IMoveable {
protected int x;
protected int y;
protected int width;
protected int height;
protected float x;
protected float y;
protected float width;
protected float height;

protected RenderUtils renderUtils = new RenderUtils();
protected MinecraftClient mc = MinecraftClient.getInstance();
Expand All @@ -34,46 +34,47 @@ public AbstractHud(String ID, int x, int y, int width, int height) {
position_setting_update = new Consumer<Vector2>() {
@Override
public void accept(Vector2 vector2) {
setX((int)vector2.x);
setY((int)vector2.y);
setX(vector2.x);
setY(vector2.y);
}
};

position_setting = new Vector2Setting(ID + "_position", "Position", new Vector2(x, y), position_setting_update);
SettingManager.register_setting(position_setting, Aoba.getInstance().settingManager.hidden_category);
}

public int getX() {
public float getX() {
return this.x;
}

public int getY() {
public float getY() {
return this.y;
}

public int getHeight() {
public float getHeight() {
return this.height;
}

public int getWidth() {
public float getWidth() {
return this.width;
}

public void setX(int x) {
public void setX(float x) {
this.x = x;
}

public void setY(int y) {
public void setY(float y) {
this.y = y;
}

public void setWidth(int width) {
public void setWidth(float width) {
this.width = width;
}

public void setHeight(int height) {
public void setHeight(float height) {
this.height = height;
}

public void update(double mouseX, double mouseY, boolean mouseClicked) {
if (Aoba.getInstance().hudManager.isClickGuiOpen()) {
if (HudManager.currentGrabbed == null) {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/net/aoba/gui/hud/ArmorHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@

public class ArmorHud extends AbstractHud{

private ItemRenderer itemRenderer;

public ArmorHud(int x, int y, int width, int height) {
super("ArmorHud", x,y,width,height);
itemRenderer = mc.getItemRenderer();
this.x = 300;
this.y = 300;
this.width = 64;
Expand All @@ -48,7 +45,7 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) {
int yOff = 16;
for(ItemStack armor : armors) {
if(armor.getItem() == Items.AIR) continue;
drawContext.drawItem(armor, this.x, this.y + this.height - yOff);
drawContext.drawItem(armor, (int)this.x, (int)(this.y + this.height - yOff));
yOff += 16;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/aoba/gui/hud/RadarHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) {
float sin_theta = (float) Math.sin(Math.toRadians(-mc.player.getRotationClient().y));
float cos_theta = (float) Math.cos(Math.toRadians(-mc.player.getRotationClient().y));

int center_x = x + (width / 2);
int center_y = y - 2 + (height / 2);
float center_x = x + (width / 2);
float center_y = y - 2 + (height / 2);

// Render Entities
for (Entity entity : mc.world.getEntities()) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/aoba/gui/tabs/AuthCrackerTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

import net.aoba.core.settings.types.DoubleSetting;
import net.aoba.core.settings.types.FloatSetting;
import net.aoba.gui.tabs.components.ButtonComponent;
import net.aoba.gui.tabs.components.SliderComponent;
import net.aoba.gui.tabs.components.StringComponent;
Expand All @@ -17,7 +17,7 @@ public class AuthCrackerTab extends ClickGuiTab {
private SliderComponent delaySlider;
private ButtonComponent start;

private DoubleSetting delay = new DoubleSetting("authcracker_delay", "Delay", 100, 50, 50000, 1, null);
private FloatSetting delay = new FloatSetting("authcracker_delay", "Delay", 100, 50, 50000, 1, null);

private AuthCracker authCracker;

Expand Down Expand Up @@ -63,9 +63,9 @@ class AuthCracker{
private Thread curThread;
private boolean shouldContinue = true;
private MinecraftClient mc = MinecraftClient.getInstance();
private DoubleSetting delay;
private FloatSetting delay;

public AuthCracker(DoubleSetting delay) {
public AuthCracker(FloatSetting delay) {
this.delay = delay;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/aoba/gui/tabs/ClickGuiTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,31 @@ public final void setTitle(String title) {
this.title = title;
}

public final int getX() {
public final float getX() {
return x;
}

public final void setX(int x) {
this.x = x;
}

public final int getY() {
public final float getY() {
return y;
}

public final void setY(int y) {
this.y = y;
}

public final int getWidth() {
public final float getWidth() {
return width;
}

public final void setWidth(int width) {
this.width = width;
}

public final int getHeight() {
public final float getHeight() {
return height;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/aoba/gui/tabs/components/ButtonComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public ButtonComponent(ClickGuiTab parent, String text, Runnable onClick) {
}

public void update(int offset, double mouseX, double mouseY, boolean mouseClicked) {
int parentX = parent.getX();
int parentY = parent.getY();
int parentWidth = parent.getWidth();
float parentX = parent.getX();
float parentY = parent.getY();
float parentWidth = parent.getWidth();

if (HudManager.currentGrabbed == null) {
if (mouseClicked) {
Expand Down Expand Up @@ -66,9 +66,9 @@ public void setOnClick(Runnable onClick) {

@Override
public void draw(int offset, DrawContext drawContext, float partialTicks, Color color) {
int parentX = parent.getX();
int parentY = parent.getY();
int parentWidth = parent.getWidth();
float parentX = parent.getX();
float parentY = parent.getY();
float parentWidth = parent.getWidth();
MatrixStack matrixStack = drawContext.getMatrices();
renderUtils.drawOutlinedBox(matrixStack, parentX + 2, parentY + offset, parentWidth - 4, this.getHeight() - 2,
backgroundColor, 0.2f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public CheckboxComponent(ClickGuiTab parent, BooleanSetting checkbox) {

@Override
public void update(int offset, double mouseX, double mouseY, boolean mouseClicked) {
int parentX = parent.getX();
int parentY = parent.getY();
int parentWidth = parent.getWidth();
float parentX = parent.getX();
float parentY = parent.getY();
float parentWidth = parent.getWidth();
if (HudManager.currentGrabbed == null) {
if (mouseClicked) {
if (mouseX >= ((parentX + parent.getWidth() - 28))
Expand All @@ -48,9 +48,9 @@ public void update(int offset, double mouseX, double mouseY, boolean mouseClicke

@Override
public void draw(int offset, DrawContext drawContext, float partialTicks, Color color) {
int parentX = parent.getX();
int parentY = parent.getY();
int parentWidth = parent.getWidth();
float parentX = parent.getX();
float parentY = parent.getY();
float parentWidth = parent.getWidth();
MatrixStack matrixStack = drawContext.getMatrices();
renderUtils.drawString(drawContext, this.text, parentX + 10,
parentY + offset + 8, 0xFFFFFF);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/aoba/gui/tabs/components/ListComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public ListComponent(ClickGuiTab parent, IndexedStringListSetting list) {

@Override
public void update(int offset, double mouseX, double mouseY, boolean mouseClicked) {
int parentX = parent.getX();
int parentY = parent.getY();
int parentWidth = parent.getWidth();
float parentX = parent.getX();
float parentY = parent.getY();
float parentWidth = parent.getWidth();
if (HudManager.currentGrabbed == null) {
if (mouseClicked) {
if (mouseY >= (((parentY + offset + 4))) && mouseY <= (parentY + offset + 22)) {
Expand Down Expand Up @@ -66,9 +66,9 @@ public void update(int offset, double mouseX, double mouseY, boolean mouseClicke

@Override
public void draw(int offset, DrawContext drawContext, float partialTicks, Color color) {
int parentX = parent.getX();
int parentY = parent.getY();
int parentWidth = parent.getWidth();
float parentX = parent.getX();
float parentY = parent.getY();
float parentWidth = parent.getWidth();
int length = MinecraftClient.getInstance().textRenderer.getWidth(list.getIndexValue());
MatrixStack matrixStack = drawContext.getMatrices();
renderUtils.drawOutlinedBox(matrixStack, parentX + 4, parentY + offset, parentWidth - 8, 22, new Color(25,25,25),
Expand Down
Loading

0 comments on commit f20ff52

Please sign in to comment.