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 vanillaBypassTickCounter;
protected int vanillaBypassTickResetCounter = 0; protected int vanillaBypassTickResetCounter = 0;
protected final int vanillaBypassResetTimeout = 7; protected final int vanillaBypassResetTimeout = 5;
private static KeyBinding toggleBinding; private static KeyBinding toggleBinding;
@ -51,11 +51,14 @@ public class Jetpack implements Module {
Module.super.endTick(client); Module.super.endTick(client);
while (toggleBinding.wasPressed()) { while (toggleBinding.wasPressed()) {
client.player.sendMessage(Text.of(String.format("[%s] Toggled!", this.getId())));
this.isEnabled = !this.isEnabled; 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 @Override
public void startTick(MinecraftClient client) { public void startTick(MinecraftClient client) {
Module.super.startTick(client); Module.super.startTick(client);
@ -63,37 +66,56 @@ public class Jetpack implements Module {
if (!isEnabled) return; if (!isEnabled) return;
if (client.player != null) { if (client.player != null) {
if (vanillaBypassTickCounter > 75 && isVanillaBypassEnabled) { boolean isJumping = client.options.jumpKey.isPressed();
Vec3d velocity = client.player.getVelocity(); boolean isSneaking = client.options.sneakKey.isPressed();
this.prevVelocity = velocity.getY();
client.player.setVelocity(new Vec3d(velocity.getX(), -1, velocity.getZ())); boolean isMovingForward = client.options.forwardKey.isPressed();
vanillaBypassTickCounter = -vanillaBypassResetTimeout; boolean isMovingLeft = client.options.leftKey.isPressed();
} boolean isMovingRight = client.options.rightKey.isPressed();
if (vanillaBypassTickCounter == 0) { boolean isMovingBack = client.options.backKey.isPressed();
vanillaBypassTickCounter++;
Vec3d velocity = client.player.getVelocity(); if (vanillaBypassTickCounter > 75 && isVanillaBypassEnabled) { vanillaBypassTickCounter = -vanillaBypassResetTimeout; }
client.player.setVelocity(new Vec3d(velocity.getX(), this.prevVelocity, velocity.getZ())); vanillaBypassTickCounter++;
}
if (vanillaBypassTickCounter < 0 && isVanillaBypassEnabled) { Vec3d velocity = client.player.getVelocity();
vanillaBypassTickCounter++;
if (vanillaBypassTickCounter < 0) {
client.player.setVelocity(new Vec3d(velocity.getX(), -0.04, velocity.getZ()));
return; return;
} }
if (client.player.input.jumping && !client.player.isOnGround()) { Vec3d newVel = new Vec3d(0, 0, 0);
vanillaBypassTickResetCounter = 0;
vanillaBypassTickCounter++;
Vec3d velocity = client.player.getVelocity();
client.player.setVelocity(new Vec3d(velocity.getX(), velocity.getY() + upwardsVel, velocity.getZ())); if (isJumping) {
} else { newVel = new Vec3d(newVel.getX(), this.upwardsVel, newVel.getZ());
vanillaBypassTickResetCounter++; if (isMovingForward) {
if (vanillaBypassTickResetCounter > vanillaBypassResetTimeout) { newVel = client.player.getRotationVector().multiply(acceleration);
vanillaBypassTickCounter = 0;
vanillaBypassTickResetCounter = 0;
} }
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.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.addDrawableChild(new ButtonWidget(5, this.height - 25, 40, 20, ScreenTexts.BACK, (button) -> {
this.client.setScreen(this.parent); this.client.setScreen(this.parent);
})); }));

View File

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