Skip to content

Commit

Permalink
Added Jetpack!
Browse files Browse the repository at this point in the history
Like fly, but better!
  • Loading branch information
coltonk9043 committed Oct 8, 2023
1 parent ed151ed commit cb6a102
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public ModuleComponent(String text, ClickGuiTab parent, Module module) {
this.module = module;

this.setHeight(30);
this.setLeft(2);
this.setRight(2);

int i = 30;
for (Setting setting : this.module.getSettings()) {
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/net/aoba/gui/tabs/components/SliderComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public SliderComponent(String text, IHudElement parent) {
super(parent);
this.text = text;
this.slider = null;


this.setHeight(24);
this.setLeft(4);
this.setRight(4);

Aoba.getInstance().eventManager.AddListener(LeftMouseDownListener.class, this);
}

Expand Down Expand Up @@ -78,13 +83,9 @@ public void update() {
@Override
public void draw(DrawContext drawContext, float partialTicks, Color color) {
MatrixStack matrixStack = drawContext.getMatrices();
renderUtils.drawBox(matrixStack, actualX, actualY, actualWidth, actualHeight, 0.5f, 0.5f, 0.5f, 0.3f);
renderUtils.drawBox(matrixStack, actualX, actualY,
(int) Math.floor(actualWidth)
* (float) ((slider.getValue() - slider.min_value) / (slider.max_value - slider.min_value)),
actualHeight, color, 1f);

renderUtils.drawOutline(matrixStack, actualX, actualY, actualWidth, actualHeight);
renderUtils.drawBox(matrixStack, actualX, actualY + 4, actualWidth, actualHeight - 8, 0.5f, 0.5f, 0.5f, 0.3f);
renderUtils.drawBox(matrixStack, actualX, actualY + 4, actualWidth * (float) ((slider.getValue() - slider.min_value) / (slider.max_value - slider.min_value)), actualHeight - 8, color, 1f);
renderUtils.drawOutline(matrixStack, actualX, actualY + 4, actualWidth, actualHeight - 8);
if (this.slider == null)
return;
// TODO: Slow but it works. Perhaps we can modify a STORED string using our new
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/aoba/module/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class ModuleManager {
public Module itemesp = new ItemESP();
public Module glide = new Glide();
public Module jesus = new Jesus();
public Module jetpack = new Jetpack();
public Module killaura = new KillAura();
public Module nametags = new Nametags();
public Module noclip = new Noclip();
Expand Down Expand Up @@ -114,6 +115,7 @@ public ModuleManager() {
addModule(glide);
addModule(itemesp);
addModule(jesus);
addModule(jetpack);
addModule(killaura);
addModule(nametags);
addModule(noclip);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/net/aoba/module/modules/movement/Fly.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ public void OnUpdate(TickEvent event) {
player.setVelocity(new Vec3d(0, 0, 0));

Vec3d vec = new Vec3d(0, 0, 0);

// If the player is moving forward.
if(MC.options.forwardKey.isPressed()) {

}


if (MC.options.jumpKey.isPressed()) {
vec = new Vec3d(0, speed * 0.2f, 0);
}
Expand Down
109 changes: 109 additions & 0 deletions src/main/java/net/aoba/module/modules/movement/Jetpack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Aoba Hacked Client
* Copyright (C) 2019-2023 coltonk9043
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Fly Module
*/
package net.aoba.module.modules.movement;

import org.lwjgl.glfw.GLFW;
import net.aoba.Aoba;
import net.aoba.core.settings.types.FloatSetting;
import net.aoba.event.events.TickEvent;
import net.aoba.event.listeners.TickListener;
import net.aoba.module.Module;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.OnGroundOnly;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.Vec3d;

public class Jetpack extends Module implements TickListener {

private FloatSetting jetpackSpeed;

public Jetpack() {
this.setName("Jetpack");
this.setBind(new KeyBinding("key.fly", GLFW.GLFW_KEY_V, "key.categories.aoba"));
this.setCategory(Category.Movement);
this.setDescription("Like fly, but a lot more fun!");

jetpackSpeed = new FloatSetting(""
+ "jetpack_speed", "Speed", "Jetpack Speed", 0.5f, 0.1f, 5.0f, 0.1f);
this.addSetting(jetpackSpeed);
}

public void setSpeed(float speed) {
this.jetpackSpeed.setValue((double)speed);
}

public double getSpeed() {
return this.jetpackSpeed.getValue();
}


@Override
public void onDisable() {
Aoba.getInstance().eventManager.RemoveListener(TickListener.class, this);
}

@Override
public void onEnable() {
Aoba.getInstance().eventManager.AddListener(TickListener.class, this);
}

@Override
public void onToggle() {

}

@Override
public void OnUpdate(TickEvent event) {
ClientPlayerEntity player = MC.player;
float speed = this.jetpackSpeed.getValue().floatValue();

if(MC.player.fallDistance > 2f) {
MC.player.networkHandler.sendPacket(new OnGroundOnly(true));
}

if(MC.player.isRiding()) {
Entity riding = MC.player.getRootVehicle();
Vec3d velocity = riding.getVelocity();
double motionY = MC.options.jumpKey.isPressed() ? 0.3 : 0;
riding.setVelocity(velocity.x, motionY, velocity.z);
}else {
player.getAbilities().flying = false;

Vec3d playerSpeed = player.getVelocity();
if (MC.options.jumpKey.isPressed()) {
double angle = -player.bodyYaw;
float leftThrusterX = (float) Math.sin(Math.toRadians(angle + 90)) * 0.25f;
float leftThrusterZ = (float) Math.cos(Math.toRadians(angle + 90)) * 0.25f;
float rightThrusterX = (float) Math.sin(Math.toRadians(angle + 270)) * 0.25f;
float rightThrusterZ = (float) Math.cos(Math.toRadians(angle + 270)) * 0.25f;

MC.world.addParticle(ParticleTypes.FLAME, player.getX() + leftThrusterX, player.getY(), player.getZ() + leftThrusterZ, 0, -0.5f, 0);
MC.world.addParticle(ParticleTypes.FLAME, player.getX() + rightThrusterX, player.getY(), player.getZ() + rightThrusterZ, 0, -0.5f, 0);
playerSpeed = playerSpeed.add(0, speed / 20.0f, 0);
}
player.setVelocity(playerSpeed);
}
}
}

0 comments on commit cb6a102

Please sign in to comment.