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

import dev.crucifixbeta.api.events.eventbus.EventListener;
import dev.crucifixbeta.api.events.impl.PacketEvent;
import dev.crucifixbeta.mod.modules.Module;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action;
import net.minecraft.screen.slot.SlotActionType;

@Environment(EnvType.CLIENT)
public class InfiniteTrident extends Module {

   public InfiniteTrident() {
      super("InfiniteTrident", Module.Category.Exploit);
      this.setChinese("\u65e0\u9650\u4e09\u53c9\u621f");
   }

   @EventListener(
      priority = 201
   )
   private void onSendPacket(PacketEvent.Send event) {
      Packet var2 = event.getPacket();
      PlayerActionC2SPacket var3;
      if (var2 instanceof PlayerActionC2SPacket && (var3 = (PlayerActionC2SPacket)var2).getAction() == Action.RELEASE_USE_ITEM) {
         mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 3, mc.player.getInventory().selectedSlot, SlotActionType.SWAP, mc.player);
      }
   }

   @EventListener(
      priority = 201
   )
   private void onSendPacket(PacketEvent.Sent event) {
      Packet var2 = event.getPacket();
      PlayerActionC2SPacket var3;
      if (var2 instanceof PlayerActionC2SPacket && (var3 = (PlayerActionC2SPacket)var2).getAction() == Action.RELEASE_USE_ITEM) {
         mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 3, mc.player.getInventory().selectedSlot, SlotActionType.SWAP, mc.player);
      }
   }
}
