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

import dev.crucifixbeta.api.events.eventbus.EventListener;
import dev.crucifixbeta.api.events.impl.EntityVelocityUpdateEvent;
import dev.crucifixbeta.mod.modules.Module;
import dev.crucifixbeta.mod.modules.settings.impl.BooleanSetting;
import dev.crucifixbeta.mod.modules.settings.impl.SliderSetting;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class KnockbackHighJump extends Module {
   public static KnockbackHighJump INSTANCE;
   private final SliderSetting height = this.add(new SliderSetting("Height", 1.0, 0.5, 4.0, 0.1));
   private final BooleanSetting onlyWhenGrounded = this.add(new BooleanSetting("OnlyWhenGrounded", true));

   public KnockbackHighJump() {
      super("KnockbackHighJump", Module.Category.Movement);
      this.setChinese("\u51fb\u9000\u9ad8\u8df3");
      INSTANCE = this;
   }

   @Override
   public String getInfo() {
      return String.valueOf(this.height.getValue());
   }

   @EventListener
   public void onVelocity(EntityVelocityUpdateEvent event) {
      if (!nullCheck() && event.getEntity() == mc.player) {
         boolean var2 = event.isExplosion() || Math.abs(event.getX()) > 0.1 || Math.abs(event.getY()) > 0.1 || Math.abs(event.getZ()) > 0.1;
         if (var2 && (!this.onlyWhenGrounded.getValue() || mc.player.isOnGround())) {
            mc.player.addVelocity(0.0, this.height.getValue(), 0.0);
         }
      }
   }
}
