Class PacketEvent

java.lang.Object
me.hackware.api.event.Event
me.hackware.api.event.impl.PacketEvent

public class PacketEvent extends Event
Fired when a packet is sent (SEND) or received (RECEIVE). Cancellable — cancelling a SEND prevents this packet from being sent, and cancelling a RECEIVE prevents it from being processed.
  • Constructor Details

    • PacketEvent

      public PacketEvent(net.minecraft.network.protocol.Packet<?> packet, PacketEvent.Direction direction)
  • Method Details

    • getPacket

      public net.minecraft.network.protocol.Packet<?> getPacket()
      The packet being sent or received.
    • getDirection

      public PacketEvent.Direction getDirection()
    • isSend

      public boolean isSend()
    • isReceive

      public boolean isReceive()
    • is

      public boolean is(Class<? extends net.minecraft.network.protocol.Packet<?>> type)
      Check whether the packet is an instance of a specific type.
      
       if (event.is(ServerboundSwingPacket.class)) { ... }
       
    • as

      public <T extends net.minecraft.network.protocol.Packet<?>> T as(Class<T> type)
      Cast the packet to a specific type (unchecked — call is(java.lang.Class<? extends net.minecraft.network.protocol.Packet<?>>) first).