ElytraFly: X, Y, Z speed factors

This commit is contained in:
noil 2021-03-04 23:27:33 -05:00
parent bd0cc23834
commit 690b5ce71a
2 changed files with 80 additions and 24 deletions

View File

@ -45,9 +45,14 @@ public final class SliderComponent extends HudComponent {
if (this.textComponent == null) {
if (this.sliderBar != null) {
int offsetWidth = 0;
if (this.subComponents > 0) {
offsetWidth = 8;
}
this.sliderBar.parent.setX(this.getX());
this.sliderBar.parent.setY(this.getY());
this.sliderBar.parent.setW(this.getW());
this.sliderBar.parent.setW(this.getW() - offsetWidth);
this.sliderBar.parent.setH(this.getH());
if (!this.sliding) {
@ -78,13 +83,32 @@ public final class SliderComponent extends HudComponent {
Minecraft.getMinecraft().fontRenderer.drawString(renderName, (int) this.getX() + 1, (int) this.getY() + 1, 0xFFAAAAAA);
String displayedValue = this.decimalFormat.format(this.value.getValue());
if (this.sliding) {
if (this.sliding && this.sliderBar != null) {
final String draggedValue = this.sliderBar.getValueFromPosition();
if (draggedValue != null)
displayedValue = draggedValue;
}
Minecraft.getMinecraft().fontRenderer.drawString(displayedValue, (int) (this.getX() + this.getW()) - Minecraft.getMinecraft().fontRenderer.getStringWidth(displayedValue) - 1, (int) this.getY() + 1, 0xFFAAAAAA);
if (this.subComponents > 0) {
final boolean isMousingHoveringDropdown = mouseX >= this.getX() + this.getW() && mouseX <= this.getX() + this.getW() + 8 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
// draw bg behind triangles
RenderUtil.drawRect(this.getX() + this.getW(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x45202020);
// draw right click box
if (this.rightClickEnabled) {
RenderUtil.drawTriangle(this.getX() + this.getW() + 4, this.getY() + 4, 3, 180, 0xFF6D55FF);
if (isMousingHoveringDropdown)
RenderUtil.drawTriangle(this.getX() + this.getW() + 4, this.getY() + 4, 3, 180, 0x50FFFFFF);
} else {
RenderUtil.drawTriangle(this.getX() + this.getW() + 4, this.getY() + 4, 3, -90, 0x75909090);
if (isMousingHoveringDropdown)
RenderUtil.drawTriangle(this.getX() + this.getW() + 4, this.getY() + 4, 3, -90, 0x50FFFFFF);
}
}
final int displayedTextX = (int) (this.getX() + this.getW()) - Minecraft.getMinecraft().fontRenderer.getStringWidth(displayedValue) - 1;
Minecraft.getMinecraft().fontRenderer.drawString(displayedValue, displayedTextX, (int) this.getY() + 1, 0xFFAAAAAA);
} else {
this.textComponent.setX(this.getX());
this.textComponent.setY(this.getY());
@ -98,10 +122,19 @@ public final class SliderComponent extends HudComponent {
public void mouseClick(int mouseX, int mouseY, int button) {
super.mouseClick(mouseX, mouseY, button);
if (!this.isMouseInside(mouseX, mouseY))
return;
if (button == 0) {
if (!this.isMouseInside(mouseX, mouseY)) {
if (this.subComponents > 0) {
// is inside button
final boolean isMousingHoveringDropdown = mouseX >= this.getX() + this.getW() && mouseX <= this.getX() + this.getW() + 8 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
if (isMousingHoveringDropdown) {
return; // cancel normal action
}
}
return;
}
if (this.textComponent == null) {
this.sliding = true;
this.sliderBar.mouseClick(mouseX, mouseY, button);
@ -115,10 +148,19 @@ public final class SliderComponent extends HudComponent {
public void mouseClickMove(int mouseX, int mouseY, int button) {
super.mouseClickMove(mouseX, mouseY, button);
if (!this.isMouseInside(mouseX, mouseY))
return;
if (button == 0) {
if (!this.isMouseInside(mouseX, mouseY)) {
if (this.subComponents > 0) {
// is inside button
final boolean isMousingHoveringDropdown = mouseX >= this.getX() + this.getW() && mouseX <= this.getX() + this.getW() + 8 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
if (isMousingHoveringDropdown) {
return; // cancel normal action
}
}
return;
}
if (this.textComponent == null) {
this.sliderBar.mouseClickMove(mouseX, mouseY, button);
} else {
@ -129,11 +171,21 @@ public final class SliderComponent extends HudComponent {
@Override
public void mouseRelease(int mouseX, int mouseY, int button) {
super.mouseRelease(mouseX, mouseY, button);
//super.mouseRelease(mouseX, mouseY, button);
if (!this.isMouseInside(mouseX, mouseY)) {
if (this.textComponent != null)
if (this.textComponent == null) {
if (button == 0 && this.subComponents > 0) {
// is inside button
final boolean isMousingHoveringDropdown = mouseX >= this.getX() + this.getW() && mouseX <= this.getX() + this.getW() + 8 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
if (isMousingHoveringDropdown) {
this.rightClickEnabled = !this.rightClickEnabled;
return; // cancel normal action
}
}
} else {
this.textComponent = null;
}
this.sliding = false;
return;

View File

@ -37,7 +37,11 @@ public final class ElytraFlyModule extends Module {
VANILLA, PACKET, CONTROL
}
public final Value<Float> speed = new Value<Float>("Speed", new String[]{"Spd", "amount", "s"}, "Speed multiplier for elytra flight, higher values equals more speed.", 1.0f, 0.0f, 5.0f, 0.01f);
public final Value<Float> speed = new Value<Float>("Speed", new String[]{"Spd", "amount", "s"}, "Speed multiplier for elytra flight, higher values equals more speed.", 1.0f, 0.0f, 5.0f, 0.1f);
public final Value<Float> speedX = new Value<Float>("SpeedX", new String[]{"SpdX", "amountX", "sX"}, "The X speed factor (speed * this).", 1.0f, 0.1f, 5.0f, 0.1f);
public final Value<Float> speedYUp = new Value<Float>("SpeedYUp", new String[]{"SpdYUp", "amountYUp", "sYU"}, "The upwards Y speed factor (speed * this).", 1.0f, 0.1f, 5.0f, 0.1f);
public final Value<Float> speedYDown = new Value<Float>("SpeedYDown", new String[]{"SpdYDown", "amountYDown", "sYD"}, "The downwards Y speed factor (speed * this).", 1.0f, 0.1f, 5.0f, 0.1f);
public final Value<Float> speedZ = new Value<Float>("SpeedZ", new String[]{"SpdZ", "amountZ", "sZ"}, "The Z speed factor (speed * this).", 1.0f, 0.1f, 5.0f, 0.1f);
public final Value<Boolean> autoStart = new Value<Boolean>("AutoStart", new String[]{"AutoStart", "Auto-Start", "start", "autojump", "as"}, "Hold down the jump key to have an easy automated lift off.", true);
public final Value<Float> autoStartDelay = new Value<Float>("StartDelay", new String[]{"AutoStartDelay", "startdelay", "autojumpdelay", "asd"}, "Delay(ms) between auto-start attempts.", 20.0f, 0.0f, 200.0f, 5.0f);
@ -176,16 +180,16 @@ public final class ElytraFlyModule extends Module {
final double[] directionSpeedPacket = MathUtil.directionSpeed(this.speed.getValue());
if (mc.player.movementInput.jump) {
mc.player.motionY = this.speed.getValue();
mc.player.motionY = this.speed.getValue() * this.speedYUp.getValue();
}
if (mc.player.movementInput.sneak) {
mc.player.motionY = -this.speed.getValue();
mc.player.motionY = -this.speed.getValue() * this.speedYDown.getValue();
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX = directionSpeedPacket[0];
mc.player.motionZ = directionSpeedPacket[1];
mc.player.motionX = directionSpeedPacket[0] * this.speedX.getValue();
mc.player.motionZ = directionSpeedPacket[1] * this.speedZ.getValue();
}
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_FALL_FLYING));
@ -194,15 +198,15 @@ public final class ElytraFlyModule extends Module {
final float speedScaled = this.speed.getValue() * 0.05f; // 5/100 of original value
final double[] directionSpeedVanilla = MathUtil.directionSpeed(speedScaled);
if (mc.player.movementInput.jump) {
mc.player.motionY = this.speed.getValue();
mc.player.motionY = this.speed.getValue() * this.speedYUp.getValue();
}
if (mc.player.movementInput.sneak) {
mc.player.motionY = -this.speed.getValue();
mc.player.motionY = -this.speed.getValue() * this.speedYDown.getValue();
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX += directionSpeedVanilla[0];
mc.player.motionZ += directionSpeedVanilla[1];
mc.player.motionX += directionSpeedVanilla[0] * this.speedX.getValue();
mc.player.motionZ += directionSpeedVanilla[1] * this.speedZ.getValue();
}
}
}
@ -231,13 +235,13 @@ public final class ElytraFlyModule extends Module {
mc.player.motionX = 0;
mc.player.motionZ = 0;
if (mc.player.movementInput.jump) {
mc.player.motionY = this.speed.getValue() / 2;
mc.player.motionY = (this.speed.getValue() / 2) * this.speedYUp.getValue();
} else if (mc.player.movementInput.sneak) {
mc.player.motionY = -this.speed.getValue() / 2;
mc.player.motionY = -(this.speed.getValue() / 2) * this.speedYDown.getValue();
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX = directionSpeedControl[0];
mc.player.motionZ = directionSpeedControl[1];
mc.player.motionX = directionSpeedControl[0] * this.speedX.getValue();
mc.player.motionZ = directionSpeedControl[1] * this.speedZ.getValue();
}
event.setX(mc.player.motionX);