diff --git a/src/main/java/me/kawaiizenbo/moonlight/module/modules/Speed.java b/src/main/java/me/kawaiizenbo/moonlight/module/modules/Speed.java index f005af4..c9a934e 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/module/modules/Speed.java +++ b/src/main/java/me/kawaiizenbo/moonlight/module/modules/Speed.java @@ -3,6 +3,7 @@ package me.kawaiizenbo.moonlight.module.modules; import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Module; import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; +import me.kawaiizenbo.moonlight.util.MathUtils; import net.minecraft.entity.MovementType; import net.minecraft.util.math.Vec3d; @@ -12,13 +13,28 @@ public class Speed extends Module public Speed() { super("Speed", "Allows you to move faster.", Category.MOVEMENT); + settings.add(speed); } @Override public void onMotion(MovementType type, Vec3d movement) { - // ??? - mc.player.addVelocity(movement); + // this is a little janky but it works, will find a better solution later + if (mc.player.forwardSpeed == 0 && mc.player.sidewaysSpeed == 0 && mc.player.isOnGround()) + { + mc.player.setVelocity(0, 0, 0); + } + Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20); + double mps = Math.abs(MathUtils.length2D(move)); + double normal = mc.player.isSprinting() ? 5.61 : 4.31; + if (mps > normal * speed.value) + { + return; + } + if (mc.player.isOnGround()) + { + mc.player.setVelocity(mc.player.getVelocity().x * speed.value, 0, mc.player.getVelocity().z * speed.value); + } } } diff --git a/src/main/java/me/kawaiizenbo/moonlight/module/modules/Step.java b/src/main/java/me/kawaiizenbo/moonlight/module/modules/Step.java index f5fb872..3fa8431 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/module/modules/Step.java +++ b/src/main/java/me/kawaiizenbo/moonlight/module/modules/Step.java @@ -24,6 +24,6 @@ public class Step extends Module public void onDisable() { super.onDisable(); - mc.player.setStepHeight(0.5f); + mc.player.setStepHeight(0.6f); } } diff --git a/src/main/java/me/kawaiizenbo/moonlight/module/settings/ColorSetting.java b/src/main/java/me/kawaiizenbo/moonlight/module/settings/ColorSetting.java deleted file mode 100644 index 228f4b9..0000000 --- a/src/main/java/me/kawaiizenbo/moonlight/module/settings/ColorSetting.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.kawaiizenbo.moonlight.module.settings; - -import me.kawaiizenbo.moonlight.util.ColorUtils; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; - -public class ColorSetting extends Setting -{ - // this is unfinished, please use 3 DoubleSettings instead - public int value; - public int r; - public int g; - public int b; - - - public ColorSetting(String name, int value) - { - this.name = name; - this.value = value; - this.height = 64; - this.r = (value >> 16) & 0xFF; - this.g = (value >> 8) & 0xFF; - this.b = value & 0xFF; - } - - @Override - public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) - { - super.render(drawContext, x, y, mouseX, mouseY, textRenderer); - drawContext.drawTextWithShadow(textRenderer, Text.literal(name), x+2, y+2, 0xFFFFFF); - int redDisplayStartColor = ColorUtils.rgbaToInt(0, g, b, 255); - int redDisplayEndColor = ColorUtils.rgbaToInt(255, g, b, 255); - int greenDisplayStartColor = ColorUtils.rgbaToInt(r, 0, b, 255); - int greenDisplayEndColor = ColorUtils.rgbaToInt(r, 255, b, 255); - int blueDisplayStartColor = ColorUtils.rgbaToInt(r, g, 0, 255); - int blueDisplayEndColor = ColorUtils.rgbaToInt(r, g, 255, 255); - drawContext.fillGradient(x+80, y+2, x+92, y+62, redDisplayEndColor, redDisplayStartColor, 0); - drawContext.fillGradient(x+95, y+2, x+107, y+62, greenDisplayEndColor, greenDisplayStartColor, 0); - drawContext.fillGradient(x+110, y+2, x+122, y+62, blueDisplayEndColor, blueDisplayStartColor, 0); - drawContext.drawTextWithShadow(textRenderer, Text.literal("Red: " + r), x+130, y+10, 0xFFFFFFFF); - drawContext.drawTextWithShadow(textRenderer, Text.literal("Green: " + g), x+130, y+26, 0xFFFFFFFF); - drawContext.drawTextWithShadow(textRenderer, Text.literal("Blue: " + b), x+130, y+42, 0xFFFFFFFF); - } -} diff --git a/src/main/java/me/kawaiizenbo/moonlight/module/settings/Setting.java b/src/main/java/me/kawaiizenbo/moonlight/module/settings/Setting.java index dba3a57..6d33f21 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/module/settings/Setting.java +++ b/src/main/java/me/kawaiizenbo/moonlight/module/settings/Setting.java @@ -6,14 +6,13 @@ import net.minecraft.client.gui.DrawContext; public class Setting { public String name; - public int height = 24; int x = 0, y = 0; public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) { this.x = x; this.y = y; - drawContext.fill(x, y, x+192, y+height, hovered(mouseX, mouseY) ? 0xFF444444: 0xFF222222); + drawContext.fill(x, y, x+192, y+24, hovered(mouseX, mouseY) ? 0xFF444444: 0xFF222222); } @@ -25,6 +24,6 @@ public class Setting protected boolean hovered(int mouseX, int mouseY) { - return mouseX >= x && mouseX <= x + 192 && mouseY >= y && mouseY <= y + height; + return mouseX >= x && mouseX <= x + 192 && mouseY >= y && mouseY <= y + 24; } } diff --git a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java index 65f9740..da72c44 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java +++ b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java @@ -44,7 +44,7 @@ public class SettingsScreen extends Screen for (Setting setting : module.settings) { setting.render(drawContext, x+16, yOffset, mouseX, mouseY, textRenderer); - yOffset += setting.height + 1; + yOffset += 25; } }