diff --git a/src/main/java/net/wurstclient/command/CmdList.java b/src/main/java/net/wurstclient/command/CmdList.java index 0031ba7600..afeac367a9 100644 --- a/src/main/java/net/wurstclient/command/CmdList.java +++ b/src/main/java/net/wurstclient/command/CmdList.java @@ -45,6 +45,7 @@ public final class CmdList public final ItemListCmd itemListCmd = new ItemListCmd(); public final JumpCmd jumpCmd = new JumpCmd(); public final LeaveCmd leaveCmd = new LeaveCmd(); + public final LookCmd lookCmd = new LookCmd(); public final ModifyCmd modifyCmd = new ModifyCmd(); public final PathCmd pathCmd = new PathCmd(); public final PotionCmd potionCmd = new PotionCmd(); diff --git a/src/main/java/net/wurstclient/commands/LookCmd.java b/src/main/java/net/wurstclient/commands/LookCmd.java new file mode 100644 index 0000000000..20bf71bc1c --- /dev/null +++ b/src/main/java/net/wurstclient/commands/LookCmd.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014-2024 Wurst-Imperium and contributors. + * + * This source code is subject to the terms of the GNU General Public + * License, version 3. If a copy of the GPL was not distributed with this + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt + */ +package net.wurstclient.commands; + +import net.wurstclient.command.CmdException; +import net.wurstclient.command.CmdSyntaxError; +import net.wurstclient.command.Command; +import net.wurstclient.util.MathUtils; + +public final class LookCmd extends Command +{ + public LookCmd() + { + super("look", "Allows you to set your yaw and pitch.\n" + + "Replace the value with skip if you do not intend to set the value.", + ".look "); + } + + @Override + public void call(String[] args) throws CmdException + { + if(args.length != 2) + throw new CmdSyntaxError(); + if(!args[0].equalsIgnoreCase("skip")) + { + if(!MathUtils.isDouble(args[0])) + throw new CmdSyntaxError("Yaw is not a number."); + float yaw = Float.parseFloat(args[0]); + if(Math.abs(yaw) > 180) + throw new CmdSyntaxError("Invalid yaw."); + MC.player.setYaw(yaw); + } + if(!args[1].equalsIgnoreCase("skip")) + { + if(!MathUtils.isDouble(args[1])) + throw new CmdSyntaxError("Pitch is not a number."); + float pitch = Float.parseFloat(args[1]); + if(Math.abs(pitch) > 90) + throw new CmdSyntaxError("Invalid pitch."); + MC.player.setPitch(pitch); + } + } +}