package com.arslaancodes.arslaansmagichax.modules.impl; import com.arslaancodes.arslaansmagichax.modules.Category; import com.arslaancodes.arslaansmagichax.modules.Module; import com.arslaancodes.arslaansmagichax.modules.settings.BooleanSetting; import com.arslaancodes.arslaansmagichax.modules.settings.NumberSetting; import net.minecraft.text.Text; public class Speed extends Module { private final NumberSetting speed = new NumberSetting("Speed", 0.1, 2.0, 0.4, 0.05); private final BooleanSetting enableWhileSneaking = new BooleanSetting("Enable while Sneaking", true); private final BooleanSetting enableInWater = new BooleanSetting("Enable in Water", true); private final BooleanSetting enableInLava = new BooleanSetting("Enable in Lava", true); public Speed() { super("Speed", "Makes you faster.", -1, Category.MOVEMENT); addSetting(speed); addSetting(enableWhileSneaking); addSetting(enableInWater); addSetting(enableInLava); } @Override protected void onEnable() { if (mc.player == null) return; mc.player.sendMessage(Text.literal("[Speed] It is recommended to use this hack in combination with NoFall."), false); } @Override public void tick() { if (!isEnabled() || mc.player == null) return; if (!enableWhileSneaking.isEnabled() && mc.player.isSneaking()) return; if (!enableInLava.isEnabled() && mc.player.isInLava()) return; if (!enableInWater.isEnabled() && mc.player.isTouchingWater()) return; float forward = mc.player.forwardSpeed; float strafe = mc.player.sidewaysSpeed; float yaw = mc.player.getYaw(); if (forward == 0 && strafe == 0) return; if (forward != 0) { if (strafe > 0) yaw += (forward > 0 ? -45 : 45); else if (strafe < 0) yaw += (forward > 0 ? 45 : -45); strafe = 0; forward = forward > 0 ? 1 : -1; } double rad = Math.toRadians(yaw); double sin = Math.sin(rad); double cos = Math.cos(rad); double x = (forward * -sin + strafe * cos) * speed.getValue(); double z = (forward * cos - strafe * -sin) * speed.getValue(); mc.player.setVelocity(x, mc.player.getVelocity().y, z); } }