package dev.nthacks.cristalix;
import org.lwjgl.input.Keyboard;
import dev.xdark.clientapi.ClientApi;
import dev.xdark.clientapi.entity.EntityPlayerSP;
import dev.xdark.clientapi.entry.ModMain;
import dev.xdark.clientapi.event.Listener;
import dev.xdark.clientapi.event.entity.PlayerJump;
import dev.xdark.clientapi.event.lifecycle.GameLoop;
import dev.xdark.clientapi.event.render.GuiOverlayRender;
import dev.xdark.clientapi.math.MathHelper;
@SuppressWarnings({ "deprecation", "unchecked" })
public class Main
implements ModMain, Listener
{
private boolean keys[] = new boolean[256];
private boolean fly = false;
private boolean longjump = false;
@Override
public void load(ClientApi api)
{
api.eventBus().register(this, GameLoop.class, a -> {
EntityPlayerSP player = api.minecraft().getPlayer();
if (isKeyDown(Keyboard.KEY_F))
{
fly = !fly;
}
if (isKeyDown(Keyboard.KEY_V))
{
longjump = !longjump;
}
if (fly)
{
player.setMotionX(0.0D);
player.setMotionY(-0.1D);
player.setMotionZ(0.0D);
double yaw = player.getRotationYaw() + 90.0f;
boolean SPACE = Keyboard.isKeyDown(57);
boolean W = Keyboard.isKeyDown(17);
boolean A = Keyboard.isKeyDown(30);
boolean S = Keyboard.isKeyDown(31);
boolean D = Keyboard.isKeyDown(32);
boolean LSHIFT = Keyboard.isKeyDown(42);
if (LSHIFT) {
player.setMotionY(player.getMotionY() - 0.5D);
if (S) {
yaw += 180.0;
}
if (A) {
yaw -= 65.0;
}
if (D) {
yaw += 65.0;
}
} else if (SPACE) {
player.setMotionY(player.getMotionY() + 0.5D);
if (S) {
yaw += 180.0;
}
if (A) {
yaw -= 65.0;
}
if (D) {
yaw += 65.0;
}
} else if (W) {
if (A) {
yaw -= 65.0;
} else if (D) {
yaw += 65.0;
}
} else if (S) {
yaw += 180.0;
if (W) {
yaw += 65.0;
} else if (D) {
yaw -= 65.0;
} else if (A) {
yaw += 65.0;
}
} else if (A) {
yaw -= 90.0;
} else if (D) {
yaw += 90.0;
}
if (W || A || S || D) {
player.setMotionX(Math.cos(Math.toRadians(yaw)) * 1.5D);
player.setMotionZ(Math.sin(Math.toRadians(yaw)) * 1.5D);
}
}
}, 1);
api.eventBus().register(this, PlayerJump.class, b -> {
EntityPlayerSP player = api.minecraft().getPlayer();
if (longjump)
{
float yaw = player.getRotationYaw() / 180.0F * (float) Math.PI;
double cos = MathHelper.cos(yaw);
double sin = MathHelper.sin(yaw);
player.setMotion(-sin * 1.5D, 0.5D, cos * 1.5D);
}
}, 1);
api.eventBus().register(this, GuiOverlayRender.class, c -> {
api.fontRenderer().drawStringWithShadow("GayHack 1.0 by NTHacks", 2.0F, 2.0F, 0xFF279BDC);
api.fontRenderer().drawStringWithShadow("Fly [F]", 2.0F, 2.0F + (10.0F * 1), fly ? 0xFF00AA00 : 0xFFFF5555);
api.fontRenderer().drawStringWithShadow("LongJump [V]", 2.0F, 2.0F + (10.0F * 2), longjump ? 0xFF00AA00 : 0xFFFF5555);
}, 1);
}
@Override
public void unload() {}
private boolean isKeyDown(int key)
{
return Keyboard.isKeyDown(key) != keys[key] ? keys[key] = !keys[key] : false;
}
}