Improved logic, average multiple directions and use variables for repeating calculations

This commit is contained in:
Alex 2020-04-22 00:05:10 +02:00 committed by GitHub
parent 91db3a8491
commit 02e61a4f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 27 deletions

View File

@ -160,41 +160,44 @@ public final class ElytraFlyModule extends Module {
}
break;
case CONTROL:
final double speedHalved = this.speed.getValue() / 2;
mc.player.motionY = 0;
if (mc.gameSettings.keyBindJump.isKeyDown()) {
mc.player.motionY = this.speed.getValue() / 2;
mc.player.motionY = speedHalved;
} else if (mc.gameSettings.keyBindSneak.isKeyDown()) {
mc.player.motionY = -this.speed.getValue() / 2;
} else {
mc.player.motionY = 0;
mc.player.motionY = -speedHalved;
}
final double sinSpeed = Math.sin(rotationYaw) * this.speed.getValue();
final double cosSpeed = Math.cos(rotationYaw) * this.speed.getValue();
double Xavg = 0;
double Zavg = 0;
boolean avgbit = false;
final boolean invBit = rotationYaw/90%2==1;
if (mc.gameSettings.keyBindForward.isKeyDown()) {
mc.player.motionX = -Math.sin(rotationYaw) * this.speed.getValue();
mc.player.motionZ = Math.cos(rotationYaw) * this.speed.getValue();
Xavg = -sinSpeed;
Zavg = cosSpeed;
avgbit = true;
} else if (mc.gameSettings.keyBindBack.isKeyDown()) {
mc.player.motionX = Math.sin(rotationYaw) * this.speed.getValue();
mc.player.motionZ = -Math.cos(rotationYaw) * this.speed.getValue();
} else if (mc.gameSettings.keyBindRight.isKeyDown()) {
if (rotationYaw/90%2==1) {
mc.player.motionX = Math.cos(rotationYaw) * this.speed.getValue();
mc.player.motionZ = Math.sin(rotationYaw) * this.speed.getValue();
} else {
mc.player.motionX = -Math.cos(rotationYaw) * this.speed.getValue();
mc.player.motionZ = -Math.sin(rotationYaw) * this.speed.getValue();
}
} else if (mc.gameSettings.keyBindLeft.isKeyDown()) {
if (rotationYaw/90%2==1) {
mc.player.motionX = -Math.cos(rotationYaw) * this.speed.getValue();
mc.player.motionZ = -Math.sin(rotationYaw) * this.speed.getValue();
} else {
mc.player.motionX = Math.cos(rotationYaw) * this.speed.getValue();
mc.player.motionZ = Math.sin(rotationYaw) * this.speed.getValue();
}
} else {
mc.player.motionX = 0;
mc.player.motionZ = 0;
Xavg = sinSpeed;
Zavg = -cosSpeed;
avgbit = true;
}
if ((mc.gameSettings.keyBindRight.isKeyDown() && invBit) || mc.gameSettings.keyBindLeft.isKeyDown()) {
Xavg += cosSpeed;
Zavg += sinSpeed;
} else if ((mc.gameSettings.keyBindLeft.isKeyDown() && invBit) || mc.gameSettings.keyBindRight.isKeyDown()) {
Xavg += -cosSpeed;
Zavg += -sinSpeed;
}
if (avgbit) {
Xavg *= 0.5;
Zavg *= 0.5;
}
mc.player.motionX = Xavg;
mc.player.motionZ = Zavg;
break;
}
}