Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.look #829

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

.look #829

Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/net/wurstclient/command/CmdList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/net/wurstclient/commands/LookCmd.java
Original file line number Diff line number Diff line change
@@ -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 <yaw> <pitch>");
}

@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]))
ThisTestUser marked this conversation as resolved.
Show resolved Hide resolved
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);
ThisTestUser marked this conversation as resolved.
Show resolved Hide resolved
}
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);
ThisTestUser marked this conversation as resolved.
Show resolved Hide resolved
}
}
}