From ee2f3e9748402ee55a6d1222b2407ac9350b8a9b Mon Sep 17 00:00:00 2001 From: tanishisherewithhh <120117618+tanishisherewithhh@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:44:03 +0530 Subject: [PATCH] Some changes and forgot to remove 1 line in fabric.mod.json. Readme change. --- README.md | 2 +- .../events/player/PlayerMotionEvent.java | 5 +++++ .../module/modules/movement/Speed.java | 20 +++++++++++-------- .../module/modules/movement/Sprint.java | 2 +- .../module/modules/player/AutoEat.java | 4 +++- .../heliosclient/module/settings/KeyBind.java | 8 +++----- .../util/player/InventoryUtils.java | 7 ------- src/main/resources/fabric.mod.json | 3 +-- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index bc76f0ff..5526ef2c 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ To submit a bug open an issue in this repository. Before doing so please assure yourself that the issues isn't already listed under [Known issues](#known-issues). ## Known issues -- Buggy modules like Tick-Shift, PacketMine. +- Buggy modules like Tick-Shift. - Incomplete modules like Phase, Fucker, InventoryTweaks. - ~~HudElements don't resize to their proper locations sometimes.~~ - Scripting System (WIP). diff --git a/src/main/java/dev/heliosclient/event/events/player/PlayerMotionEvent.java b/src/main/java/dev/heliosclient/event/events/player/PlayerMotionEvent.java index eef4da9a..a79a943e 100644 --- a/src/main/java/dev/heliosclient/event/events/player/PlayerMotionEvent.java +++ b/src/main/java/dev/heliosclient/event/events/player/PlayerMotionEvent.java @@ -3,6 +3,7 @@ import dev.heliosclient.event.Cancelable; import dev.heliosclient.event.Event; import dev.heliosclient.event.LuaEvent; +import dev.heliosclient.system.mixininterface.IVec3d; import net.minecraft.entity.MovementType; import net.minecraft.util.math.Vec3d; @@ -24,4 +25,8 @@ public MovementType getType() { public Vec3d getMovement() { return movement; } + + public IVec3d modifyMovement(){ + return (IVec3d)movement; + } } diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Speed.java b/src/main/java/dev/heliosclient/module/modules/movement/Speed.java index c5c69bc0..d45dd664 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Speed.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Speed.java @@ -66,7 +66,7 @@ public Speed() { @SubscribeEvent @SuppressWarnings("all") public void onMotion(PlayerMotionEvent e) { - if (mc.options.sneakKey.isPressed() && !whileSneaking.value) + if ((mc.options.sneakKey.isPressed() && !whileSneaking.value) || mc.getCameraEntity() != mc.player) return; // Strafe Mode @@ -94,14 +94,18 @@ public void onMotion(PlayerMotionEvent e) { mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.START_SPRINTING)); } - double prevX = e.getMovement().x * (1.0 - speed.value/10.1); - double prevZ = e.getMovement().z * (1.0 - speed.value/10.1); - double useSpeed = mc.player.getVelocity().horizontalLength() * (speed.value/10.0); + double prevX = e.getMovement().x * speed.value; + double prevZ = e.getMovement().z * speed.value; + double useSpeed = mc.player.getVelocity().horizontalLength() * (speed.value / 10.0); - double angle = Math.toRadians(mc.player.getYaw(mc.getTickDelta())); - double x = (-Math.sin(angle) * useSpeed) + prevX; - double z = (Math.cos(angle) * useSpeed) + prevZ; - ((IVec3d) e.getMovement()).heliosClient$setXZ(x,z); + double angle = Math.toRadians(mc.player.getYaw(mc.getTickDelta())); + double forward = mc.player.input.movementForward; + double strafe = mc.player.input.movementSideways; + + double x = (-Math.sin(angle) * forward + Math.cos(angle) * strafe) * useSpeed + prevX; + double z = (Math.cos(angle) * forward + Math.sin(angle) * strafe) * useSpeed + prevZ; + + e.modifyMovement().heliosClient$setXZ(x, z); } // OnGround Mode else if (speedMode.getOption() == Modes.OnGround) { diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java b/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java index 1dafd40b..d8493f30 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java @@ -41,7 +41,7 @@ public boolean strictModeCheck() { if(!strictMode.value){ return mc.currentScreen == null; } - return mc.player.forwardSpeed > 0.00f && + return (mc.player.forwardSpeed != 0 || mc.player.sidewaysSpeed != 0) && !mc.player.horizontalCollision && !mc.player.isTouchingWater() && !mc.player.isSubmergedInWater() && diff --git a/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java b/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java index 87d6cc06..24949623 100644 --- a/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java +++ b/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java @@ -122,7 +122,9 @@ public void onTick(TickEvent.PLAYER event) { if ((isEating && !shouldEat()) || mc.player.getInventory().getStack(bestFoodSlot) == null) { isEating = false; mc.options.useKey.setPressed(false); - InventoryUtils.swapBackHotbar(); + + if(bestFoodSlot != InventoryUtils.OFFHAND) + InventoryUtils.swapBackHotbar(); } } diff --git a/src/main/java/dev/heliosclient/module/settings/KeyBind.java b/src/main/java/dev/heliosclient/module/settings/KeyBind.java index a70b5293..9eeedd4d 100644 --- a/src/main/java/dev/heliosclient/module/settings/KeyBind.java +++ b/src/main/java/dev/heliosclient/module/settings/KeyBind.java @@ -16,6 +16,9 @@ import java.util.Locale; import java.util.function.BooleanSupplier; +/** + * The keybind setting only provides a way to get key codes which the user has selected. On its own, it does not perform anything when the key is pressed. + */ public class KeyBind extends Setting { public static boolean listeningKey = false; public static boolean listeningMouse = false; @@ -146,11 +149,6 @@ public void loadFromFile(MapReader map) { value = map.getInt(this.getSaveName(),defaultValue); } - @Override - public void mouseReleased(double mouseX, double mouseY, int button) { - super.mouseReleased(mouseX, mouseY, button); - } - public static class Builder extends SettingBuilder { ISettingChange iSettingChange; diff --git a/src/main/java/dev/heliosclient/util/player/InventoryUtils.java b/src/main/java/dev/heliosclient/util/player/InventoryUtils.java index aaa1231e..25789b5a 100644 --- a/src/main/java/dev/heliosclient/util/player/InventoryUtils.java +++ b/src/main/java/dev/heliosclient/util/player/InventoryUtils.java @@ -31,8 +31,6 @@ public static void swapBackHotbar() { } } - - public static boolean swapToSlot(int hotbarSlot, boolean swapBack) { if (hotbarSlot == InventoryUtils.OFFHAND) return true; if (HeliosClient.MC.player.getInventory().selectedSlot == hotbarSlot) return true; @@ -269,9 +267,4 @@ public static void moveItem(int fromSlot, int toSlot, SlotActionType fromAction, HeliosClient.MC.interactionManager.clickSlot(player.currentScreenHandler.syncId, toSlot, 0, toAction, player); } } - - public static void moveItemPickup(int fromSlot, int toSlot) { - moveItem(fromSlot,toSlot,SlotActionType.PICKUP,SlotActionType.PICKUP); - } - } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 23d8a026..6e47e83e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,8 +30,7 @@ "fabricloader": ">=0.15.0", "fabric-api": "*", "minecraft": "~1.20", - "java": ">=17", - "modmenu": ">=9.0.0" + "java": ">=17" }, "suggests": { "ModMenu": "*"