package dev.crucifixbeta.api.events.impl;

import dev.crucifixbeta.api.events.Event;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.packet.Packet;

@Environment(EnvType.CLIENT)
public class PacketEvent extends Event {
   private final Packet<?> packet;

   public PacketEvent(Packet<?> packet, Event.Stage stage) {
      super(stage);
      this.packet = packet;
   }

   public Packet<?> getPacket() {
      return this.packet;
   }

   @Environment(EnvType.CLIENT)
   public static class Receive extends PacketEvent {
      public Receive(Packet<?> packet) {
         super(packet, Event.Stage.Pre);
      }
   }

   @Environment(EnvType.CLIENT)
   public static class Send extends PacketEvent {
      public Send(Packet<?> packet) {
         super(packet, Event.Stage.Pre);
      }
   }

   @Environment(EnvType.CLIENT)
   public static class Sent extends PacketEvent {
      public Sent(Packet<?> packet) {
         super(packet, Event.Stage.Post);
      }
   }
}
