Skip to content

Conversation

@RudideC
Copy link

@RudideC RudideC commented Feb 19, 2024

Added more smoothness, randomness and an option to change where to aim.
Feedback is appreciated

Copy link
Contributor

@0x3C50 0x3C50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code style and a few descriptions, otherwise great

.description("Where to aim")
.get());
final DoubleSetting aimHeight = this.config.create(new DoubleSetting.Builder(1).name("Aim Height")
.description("Where to aim (in %)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably elaborate on what that % affects

.description("Whether or not to aim instantly instead of smoothly")
.get());
final BooleanSetting aimRandom = this.config.create(new BooleanSetting.Builder(false).name("Aim random")
.description("Whether or not the laziness should have randomness")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Randomize speed when aiming"

.get());
RangeSetting.Range defaultValue = new RangeSetting.Range(1, 100);
final RangeSetting aimRandomness = this.config.create(new RangeSetting.Builder(defaultValue).name("Randomness")
.description("The amount of randomness the lazyness should have")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"How strongly to affect speed when randomizing"

if (!aimInstant.getValue()) {
if(aimMode.getValue() == AimMode.Top)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 1.3d), 0), (float) (modifiedLaziness));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this look at the head of an entity? in which case getEyePos()

Comment on lines 215 to 240
} else {
if(aimMode.getValue() == AimMode.Top)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 1.3d), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Middle)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 2d), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Bottom)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 4d), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Custom)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 100) * aimHeight.getValue(), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely this can be simplified down to avoid duplicate code

Comment on lines 242 to 287
else if (!aimRandom.getValue())
{
if (!aimInstant.getValue()) {
if(aimMode.getValue() == AimMode.Top)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 1.3d), 0), (float) (laziness.getValue() + 0));
}
if(aimMode.getValue() == AimMode.Middle)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 2d), 0), (float) (laziness.getValue() + 0));
}
else if(aimMode.getValue() == AimMode.Bottom)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 4d), 0), (float) (laziness.getValue() + 0));
}
else if(aimMode.getValue() == AimMode.Bottom)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 100) * aimHeight.getValue(), 0), (float) (laziness.getValue() + 0));
}
} else {
if(aimMode.getValue() == AimMode.Top)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 1.3d), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Middle)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, le.getHeight() / 2d, 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Bottom)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, le.getHeight() / 4d, 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Custom)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 100) * aimHeight.getValue(), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same code but with a different variable, you can just use the modifiedLaziness and only change it when randomness is enabled

@RudideC
Copy link
Author

RudideC commented Feb 20, 2024

Ok fixed stuff now

@RudideC
Copy link
Author

RudideC commented Feb 20, 2024

By the way the createrelease.sh doesn't work, at least on mac

Copy link
Contributor

@0x3C50 0x3C50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took a proper look, didn't notice these things at first when going over the pr on mobile.
if you have a lot of duplicate code with only one variable or argument changing, it's best to remove the duplicate code and only actually change that one part. both of the if chains have a lot of duplicate code where you could just modify the position to look at. everything else is the same

Comment on lines 227 to 256
if(aimMode.getValue() == AimMode.Top)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 1.3d), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Middle)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 2d), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Bottom)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 4d), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if(aimMode.getValue() == AimMode.Custom)
{
Rotation py = Rotations.getPitchYaw(le.getPos().add(0, (le.getHeight() / 100) * aimHeight.getValue(), 0));
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
else if (aimMode.getValue() == AimMode.Eyes)
{
Rotation py = Rotations.getPitchYaw(le.getEyePos());
Objects.requireNonNull(CoffeeMain.client.player).setPitch(py.getPitch());
CoffeeMain.client.player.setYaw(py.getYaw());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still code duplicates, you can use an enhanced switch here:

Rotation py = switch (aimMode.getValue()) {
    case AimMode.Top -> ...;
    case AimMode.Middle -> ...;
    ...
}
// use py

Comment on lines 206 to 225
if(aimMode.getValue() == AimMode.Top)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 1.3d), 0), (float) (modifiedLaziness));
}
if(aimMode.getValue() == AimMode.Middle)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 2d), 0), (float) (modifiedLaziness));
}
else if(aimMode.getValue() == AimMode.Bottom)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 4d), 0), (float) (modifiedLaziness));
}
else if(aimMode.getValue() == AimMode.Custom)
{
Rotations.lookAtPositionSmooth(le.getPos().add(0, (le.getHeight() / 100) * aimHeight.getValue(), 0), (float) (modifiedLaziness));
}
else if (aimMode.getValue() == AimMode.Eyes)
{
Rotations.lookAtPositionSmooth(le.getEyePos(), (float) (modifiedLaziness));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enhanced switch might be best here too


void aimAtTarget() {

double modifiedLaziness = laziness.getValue() + 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a double, but any usages are casted to floats. probably better to make this a float and use Random#nextFloat for the offset

@RudideC
Copy link
Author

RudideC commented Feb 20, 2024

all right imma look into this tomorrow

@RudideC
Copy link
Author

RudideC commented Feb 25, 2024

ok i really haven't had time to do this so I will do it after my exams (i will work on it next thursday)

@RudideC RudideC closed this Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants