mirror of https://github.com/kami-blue/client
cleanup elytraflight code in preparation for #616
This commit is contained in:
parent
44800c43ca
commit
a0e3e5a5c3
|
@ -31,40 +31,51 @@ public class ElytraFlight extends Module {
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
if (mc.player == null) return;
|
if (mc.player == null) return;
|
||||||
|
if (defaultSetting.getValue()) defaults();
|
||||||
|
|
||||||
if (defaultSetting.getValue()) {
|
takeOff();
|
||||||
easyTakeOff.setValue(true);
|
setFlySpeed();
|
||||||
takeOffMode.setValue(TakeoffMode.PACKET);
|
|
||||||
overrideMaxSpeed.setValue(false);
|
|
||||||
speedHighway.setValue(1.8f);
|
|
||||||
speedHighwayOverride.setValue(1.8f);
|
|
||||||
fallSpeedHighway.setValue(.000050000002f);
|
|
||||||
fallSpeed.setValue(-.003f);
|
|
||||||
upSpeedBoost.setValue(0.08f);
|
|
||||||
downSpeedBoost.setValue(0.04f);
|
|
||||||
defaultSetting.setValue(false);
|
|
||||||
Command.sendChatMessage(getChatName() + " Set to defaults!");
|
|
||||||
Command.sendChatMessage(getChatName() + " Close and reopen the " + getName() + " settings menu to see changes");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode.getValue().equals(ElytraFlightMode.HIGHWAY)
|
// Command.sendChatMessage("Rotation: " + mc.player.rotationPitch + " Camera: " + mc.player.cameraPitch);
|
||||||
&& easyTakeOff.getValue()
|
|
||||||
&& !mc.player.isElytraFlying()
|
/* required on some servers in order to land */
|
||||||
&& !mc.player.onGround) {
|
if (mc.player.onGround) mc.player.capabilities.allowFlying = false;
|
||||||
switch (takeOffMode.getValue()) {
|
|
||||||
case CLIENT:
|
if (!mc.player.isElytraFlying()) return;
|
||||||
mc.player.capabilities.isFlying = true;
|
|
||||||
case PACKET:
|
if (mode.getValue() == ElytraFlightMode.BOOST) {
|
||||||
Objects.requireNonNull(mc.getConnection()).sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_FALL_FLYING));
|
if (mc.player.isInWater()) {
|
||||||
default:
|
Objects.requireNonNull(mc.getConnection()).sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_FALL_FLYING));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (mode.getValue().equals(ElytraFlightMode.HIGHWAY) && easyTakeOff.getValue() && mc.player.isElytraFlying()) {
|
if (mc.gameSettings.keyBindJump.isKeyDown())
|
||||||
easyTakeOff.setValue(false);
|
mc.player.motionY += upSpeedBoost.getValue();
|
||||||
Command.sendChatMessage(getChatName() + "Disabled takeoff!");
|
else
|
||||||
}
|
if (mc.gameSettings.keyBindSneak.isKeyDown())
|
||||||
|
mc.player.motionY -= downSpeedBoost.getValue();
|
||||||
|
|
||||||
|
if (mc.gameSettings.keyBindForward.isKeyDown()) {
|
||||||
|
float yaw = (float) Math.toRadians(mc.player.rotationYaw);
|
||||||
|
mc.player.motionX -= MathHelper.sin(yaw) * 0.05F;
|
||||||
|
mc.player.motionZ += MathHelper.cos(yaw) * 0.05F;
|
||||||
|
} else
|
||||||
|
if (mc.gameSettings.keyBindBack.isKeyDown()) {
|
||||||
|
float yaw = (float) Math.toRadians(mc.player.rotationYaw);
|
||||||
|
mc.player.motionX += MathHelper.sin(yaw) * 0.05F;
|
||||||
|
mc.player.motionZ -= MathHelper.cos(yaw) * 0.05F;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mc.player.capabilities.setFlySpeed(.915f);
|
||||||
|
mc.player.capabilities.isFlying = true;
|
||||||
|
|
||||||
|
if (mc.player.capabilities.isCreativeMode)
|
||||||
|
return;
|
||||||
|
mc.player.capabilities.allowFlying = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFlySpeed() {
|
||||||
if (mc.player.capabilities.isFlying) {
|
if (mc.player.capabilities.isFlying) {
|
||||||
if (mode.getValue().equals(ElytraFlightMode.HIGHWAY)) {
|
if (mode.getValue().equals(ElytraFlightMode.HIGHWAY)) {
|
||||||
mc.player.setSprinting(false);
|
mc.player.setSprinting(false);
|
||||||
|
@ -77,43 +88,23 @@ public class ElytraFlight extends Module {
|
||||||
mc.player.setPosition(mc.player.posX, mc.player.posY - fallSpeed.getValue(), mc.player.posZ);
|
mc.player.setPosition(mc.player.posX, mc.player.posY - fallSpeed.getValue(), mc.player.posZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mc.player.onGround) {
|
private void takeOff() {
|
||||||
mc.player.capabilities.allowFlying = false;
|
if (!(mode.getValue().equals(ElytraFlightMode.HIGHWAY) && easyTakeOff.getValue())) return;
|
||||||
|
if (!mc.player.isElytraFlying() && !mc.player.onGround) {
|
||||||
|
switch (takeOffMode.getValue()) {
|
||||||
|
case CLIENT:
|
||||||
|
mc.player.capabilities.isFlying = true;
|
||||||
|
case PACKET:
|
||||||
|
Objects.requireNonNull(mc.getConnection()).sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_FALL_FLYING));
|
||||||
|
default:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mc.player.isElytraFlying()) return;
|
if (mc.player.isElytraFlying()) {
|
||||||
switch (mode.getValue()) {
|
easyTakeOff.setValue(false);
|
||||||
case BOOST:
|
Command.sendChatMessage(getChatName() + "Disabled takeoff!");
|
||||||
if (mc.player.isInWater()) {
|
|
||||||
Objects.requireNonNull(mc.getConnection()).sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_FALL_FLYING));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mc.gameSettings.keyBindJump.isKeyDown())
|
|
||||||
mc.player.motionY += upSpeedBoost.getValue();
|
|
||||||
else if (mc.gameSettings.keyBindSneak.isKeyDown())
|
|
||||||
mc.player.motionY -= downSpeedBoost.getValue();
|
|
||||||
|
|
||||||
if (mc.gameSettings.keyBindForward.isKeyDown()) {
|
|
||||||
float yaw = (float) Math
|
|
||||||
.toRadians(mc.player.rotationYaw);
|
|
||||||
mc.player.motionX -= MathHelper.sin(yaw) * 0.05F;
|
|
||||||
mc.player.motionZ += MathHelper.cos(yaw) * 0.05F;
|
|
||||||
} else if (mc.gameSettings.keyBindBack.isKeyDown()) {
|
|
||||||
float yaw = (float) Math
|
|
||||||
.toRadians(mc.player.rotationYaw);
|
|
||||||
mc.player.motionX += MathHelper.sin(yaw) * 0.05F;
|
|
||||||
mc.player.motionZ -= MathHelper.cos(yaw) * 0.05F;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mc.player.capabilities.setFlySpeed(.915f);
|
|
||||||
mc.player.capabilities.isFlying = true;
|
|
||||||
|
|
||||||
if (mc.player.capabilities.isCreativeMode) return;
|
|
||||||
mc.player.capabilities.allowFlying = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +116,21 @@ public class ElytraFlight extends Module {
|
||||||
mc.player.capabilities.allowFlying = false;
|
mc.player.capabilities.allowFlying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void defaults() {
|
||||||
|
easyTakeOff.setValue(true);
|
||||||
|
takeOffMode.setValue(TakeoffMode.PACKET);
|
||||||
|
overrideMaxSpeed.setValue(false);
|
||||||
|
speedHighway.setValue(1.8f);
|
||||||
|
speedHighwayOverride.setValue(1.8f);
|
||||||
|
fallSpeedHighway.setValue(.000050000002f);
|
||||||
|
fallSpeed.setValue(-.003f);
|
||||||
|
upSpeedBoost.setValue(0.08f);
|
||||||
|
downSpeedBoost.setValue(0.04f);
|
||||||
|
defaultSetting.setValue(false);
|
||||||
|
Command.sendChatMessage(getChatName() + " Set to defaults!");
|
||||||
|
Command.sendChatMessage(getChatName() + " Close and reopen the " + getName() + " settings menu to see changes");
|
||||||
|
}
|
||||||
|
|
||||||
private float getHighwaySpeed() {
|
private float getHighwaySpeed() {
|
||||||
if (overrideMaxSpeed.getValue()) {
|
if (overrideMaxSpeed.getValue()) {
|
||||||
return speedHighwayOverride.getValue();
|
return speedHighwayOverride.getValue();
|
||||||
|
|
Loading…
Reference in New Issue