first commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package online.bobtony.handlers;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import online.bobtony.BobTony;
|
||||
import online.bobtony.enums.Modes;
|
||||
|
||||
public class DoubleJumpHandler {
|
||||
|
||||
public static void handleDoubleJump(ClientPlayerEntity player) {
|
||||
boolean isJumping = player.input.playerInput.jump();
|
||||
|
||||
if (isJumping && !BobTony.wasJumping) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - BobTony.lastJumpTime < 300) {
|
||||
if(BobTony.mode == Modes.FLY) {
|
||||
toggleFlyMode(player);
|
||||
}else {
|
||||
boostPlayer(player);
|
||||
}
|
||||
}
|
||||
BobTony.lastJumpTime = currentTime;
|
||||
}
|
||||
|
||||
BobTony.wasJumping = isJumping;
|
||||
}
|
||||
|
||||
private static void toggleFlyMode(ClientPlayerEntity player) {
|
||||
boolean isFlying = !player.getAbilities().flying;
|
||||
player.getAbilities().flying = isFlying;
|
||||
player.getAbilities().setFlySpeed(BobTony.flyspeed);
|
||||
|
||||
if (isFlying) {
|
||||
BobTony.sendMessage(player, "Fly: §aEnabled", true);
|
||||
} else {
|
||||
BobTony.sendMessage(player, "Fly: §cDisabled", true);
|
||||
}
|
||||
|
||||
player.sendAbilitiesUpdate();
|
||||
}
|
||||
|
||||
private static void boostPlayer(ClientPlayerEntity apfel) {
|
||||
double pitch = apfel.getPitch();
|
||||
Vec3d velocity;
|
||||
|
||||
if (pitch > 70) {
|
||||
velocity = new Vec3d(0.0, 1.0, 0.0).multiply(BobTony.strength);
|
||||
} else {
|
||||
velocity = apfel.getRotationVector().multiply(BobTony.strength);
|
||||
}
|
||||
|
||||
apfel.addVelocity(velocity.x, velocity.y + 0.5, velocity.z);
|
||||
apfel.velocityModified = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user