rewrite jetpack

This commit is contained in:
c0repwn3r 2022-12-03 20:44:24 -05:00
parent 2e20a54dfb
commit e41a18a7bd
Signed by: core
GPG Key ID: FDBF740DADDCEECF
2 changed files with 70 additions and 27 deletions

View File

@ -26,7 +26,7 @@ public class Jetpack implements Module {
protected int vanillaBypassTickCounter;
protected int vanillaBypassTickResetCounter = 0;
protected final int vanillaBypassResetTimeout = 7;
protected final int vanillaBypassResetTimeout = 5;
private static KeyBinding toggleBinding;
@ -51,11 +51,14 @@ public class Jetpack implements Module {
Module.super.endTick(client);
while (toggleBinding.wasPressed()) {
client.player.sendMessage(Text.of(String.format("[%s] Toggled!", this.getId())));
this.isEnabled = !this.isEnabled;
client.player.sendMessage(Text.of(String.format("[%s] %s %s", this.getId(), (this.isEnabled) ? "Enabled" : "Disabled", this.getId())));
}
}
private double acceleration = 0;
protected double max = 10;
@Override
public void startTick(MinecraftClient client) {
Module.super.startTick(client);
@ -63,37 +66,56 @@ public class Jetpack implements Module {
if (!isEnabled) return;
if (client.player != null) {
if (vanillaBypassTickCounter > 75 && isVanillaBypassEnabled) {
Vec3d velocity = client.player.getVelocity();
this.prevVelocity = velocity.getY();
client.player.setVelocity(new Vec3d(velocity.getX(), -1, velocity.getZ()));
vanillaBypassTickCounter = -vanillaBypassResetTimeout;
}
if (vanillaBypassTickCounter == 0) {
boolean isJumping = client.options.jumpKey.isPressed();
boolean isSneaking = client.options.sneakKey.isPressed();
boolean isMovingForward = client.options.forwardKey.isPressed();
boolean isMovingLeft = client.options.leftKey.isPressed();
boolean isMovingRight = client.options.rightKey.isPressed();
boolean isMovingBack = client.options.backKey.isPressed();
if (vanillaBypassTickCounter > 75 && isVanillaBypassEnabled) { vanillaBypassTickCounter = -vanillaBypassResetTimeout; }
vanillaBypassTickCounter++;
Vec3d velocity = client.player.getVelocity();
client.player.setVelocity(new Vec3d(velocity.getX(), this.prevVelocity, velocity.getZ()));
}
if (vanillaBypassTickCounter < 0 && isVanillaBypassEnabled) {
vanillaBypassTickCounter++;
if (vanillaBypassTickCounter < 0) {
client.player.setVelocity(new Vec3d(velocity.getX(), -0.04, velocity.getZ()));
return;
}
if (client.player.input.jumping && !client.player.isOnGround()) {
vanillaBypassTickResetCounter = 0;
vanillaBypassTickCounter++;
Vec3d velocity = client.player.getVelocity();
Vec3d newVel = new Vec3d(0, 0, 0);
client.player.setVelocity(new Vec3d(velocity.getX(), velocity.getY() + upwardsVel, velocity.getZ()));
} else {
vanillaBypassTickResetCounter++;
if (vanillaBypassTickResetCounter > vanillaBypassResetTimeout) {
vanillaBypassTickCounter = 0;
vanillaBypassTickResetCounter = 0;
if (isJumping) {
newVel = new Vec3d(newVel.getX(), this.upwardsVel, newVel.getZ());
if (isMovingForward) {
newVel = client.player.getRotationVector().multiply(acceleration);
}
if (isMovingLeft) {
newVel = client.player.getRotationVector().multiply(acceleration).rotateY(3.1415927F/2);
newVel = new Vec3d(newVel.getX(), 0, newVel.getZ());
}
if (isMovingRight) {
newVel = client.player.getRotationVector().multiply(acceleration).rotateY(-3.1415927F/2);
newVel = new Vec3d(newVel.getX(), 0, newVel.getZ());
}
if (isMovingBack) {
newVel = client.player.getRotationVector().negate().multiply(acceleration);
}
} else if (isSneaking) {
newVel = new Vec3d(newVel.getX(), -0.5, newVel.getZ());
}
if (isMovingForward || isMovingLeft || isMovingRight || isMovingBack) {
if (acceleration < max) {
acceleration += 0.1;
}
} else if (acceleration > 0.2) {
acceleration -= 0.2;
}
client.player.setVelocity(newVel);
}
}
@ -159,6 +181,27 @@ public class Jetpack implements Module {
this.upwardsVelBtn.setMessage(Text.of("UpVel: " + df.format((this.parentModule.upwardsVel))));
}));
this.addDrawableChild(new ButtonWidget(5, 80, 20, 20, Text.of("++"), (button) -> {
this.parentModule.max += 1;
this.upwardsVelBtn.setMessage(Text.of("MaxSpd: " + df.format((this.parentModule.max))));
}));
this.addDrawableChild(new ButtonWidget(30, 80, 20, 20, Text.of("+"), (button) -> {
this.parentModule.max += 0.1;
this.upwardsVelBtn.setMessage(Text.of("MaxSpd: " + df.format((this.parentModule.max))));
}));
this.upwardsVelBtn = new ButtonWidget(55, 80, 70, 20, Text.of("MaxSpd: " + df.format((this.parentModule.max))), (button) -> {});
this.addDrawableChild(this.upwardsVelBtn);
this.addDrawableChild(new ButtonWidget(130, 80, 20, 20, Text.of("-"), (button) -> {
this.parentModule.max -= 0.1;
this.upwardsVelBtn.setMessage(Text.of("MaxSpd: " + df.format((this.parentModule.max))));
}));
this.addDrawableChild(new ButtonWidget(155, 80, 20, 20, Text.of("--"), (button) -> {
this.parentModule.max -= 1;
this.upwardsVelBtn.setMessage(Text.of("MaxSpd: " + df.format((this.parentModule.max))));
}));
this.addDrawableChild(new ButtonWidget(5, this.height - 25, 40, 20, ScreenTexts.BACK, (button) -> {
this.client.setScreen(this.parent);
}));

View File

@ -37,8 +37,8 @@ public class NoFall implements Module {
Module.super.endTick(client);
while (toggleBinding.wasPressed()) {
client.player.sendMessage(Text.of(String.format("[%s] Toggled!", this.getId())));
this.isEnabled = !this.isEnabled;
client.player.sendMessage(Text.of(String.format("[%s] %s %s", this.getId(), (this.isEnabled) ? "Enabled" : "Disabled", this.getId())));
}
}