package dev.crucifixbeta.mod.modules.impl.movement;

import dev.crucifixbeta.api.events.eventbus.EventListener;
import dev.crucifixbeta.api.events.impl.UpdateEvent;
import dev.crucifixbeta.mod.modules.Module;
import dev.crucifixbeta.mod.modules.settings.impl.EnumSetting;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.PositionAndOnGround;

@Environment(EnvType.CLIENT)
public class VClip extends Module {
   private final EnumSetting<VClip.Mode> mode = this.add(new EnumSetting<>("Mode", VClip.Mode.Jump));

   public VClip() {
      super("VClip", Module.Category.Movement);
      this.setChinese("\u7eb5\u5411\u7a7f\u5899");
   }

   @EventListener
   public void onUpdate(UpdateEvent event) {
      this.disable();
      switch ((VClip.Mode)this.mode.getValue()) {
         case Glitch:
            double var2 = mc.player.getX();
            double var4 = (double)Math.round(mc.player.getY());
            double var6 = mc.player.getZ();
            boolean var8 = mc.player.isOnGround();
            mc.getNetworkHandler().sendPacket(new PositionAndOnGround(var2, var4, var6, var8));
            double var9 = 0.005;
            double var11;
            mc.player.setPosition(var2, var11 = var4 - var9, var6);
            mc.getNetworkHandler().sendPacket(new PositionAndOnGround(var2, var11, var6, var8));
            mc.player.setPosition(var2, var4 = var11 - var9 * 300.0, var6);
            mc.getNetworkHandler().sendPacket(new PositionAndOnGround(var2, var4, var6, var8));
            break;
         case Teleport:
            mc.player.setPosition(mc.player.getX(), mc.player.getY() + 3.0, mc.player.getZ());
            mc.getNetworkHandler().sendPacket(new PositionAndOnGround(mc.player.getX(), mc.player.getY(), mc.player.getZ(), true));
            break;
         case Jump:
            mc.getNetworkHandler().sendPacket(new PositionAndOnGround(mc.player.getX(), mc.player.getY() + 0.4199999868869781, mc.player.getZ(), false));
            mc.getNetworkHandler().sendPacket(new PositionAndOnGround(mc.player.getX(), mc.player.getY() + 0.7531999805212017, mc.player.getZ(), false));
            mc.player.setPosition(mc.player.getX(), mc.player.getY() + 1.0, mc.player.getZ());
            mc.getNetworkHandler().sendPacket(new PositionAndOnGround(mc.player.getX(), mc.player.getY(), mc.player.getZ(), true));
      }
   }
@Environment(EnvType.CLIENT)
   public static enum Mode {
      Glitch,
      Teleport,
      Jump;

}
}
