Record Class DamageEventPacket

java.lang.Object
java.lang.Record
net.minestom.server.network.packet.server.play.DamageEventPacket
Record Components:
targetEntityId - ID of the entity being damaged
damageTypeId - ID of damage type
sourceEntityId - 0 if there is no source entity, otherwise it is entityId + 1
sourceDirectId - 0 if there is no direct source. For direct attacks (e.g. melee), this is the same as sourceEntityId. For indirect attacks (e.g. projectiles), this is the projectile entity id + 1
sourcePos - null if there is no source position, otherwise the position of the source
All Implemented Interfaces:
NetworkBuffer.Writer, SendablePacket, ServerPacket, ServerPacket.Play

public record DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable Point sourcePos) extends Record implements ServerPacket.Play
  • Constructor Details

    • DamageEventPacket

      public DamageEventPacket(@NotNull @NotNull NetworkBuffer reader)
    • DamageEventPacket

      public DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable @Nullable Point sourcePos)
      Creates an instance of a DamageEventPacket record class.
      Parameters:
      targetEntityId - the value for the targetEntityId record component
      damageTypeId - the value for the damageTypeId record component
      sourceEntityId - the value for the sourceEntityId record component
      sourceDirectId - the value for the sourceDirectId record component
      sourcePos - the value for the sourcePos record component
  • Method Details

    • playId

      public int playId()
      Specified by:
      playId in interface ServerPacket.Play
    • write

      public void write(@NotNull @NotNull NetworkBuffer writer)
      Specified by:
      write in interface NetworkBuffer.Writer
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • targetEntityId

      public int targetEntityId()
      Returns the value of the targetEntityId record component.
      Returns:
      the value of the targetEntityId record component
    • damageTypeId

      public int damageTypeId()
      Returns the value of the damageTypeId record component.
      Returns:
      the value of the damageTypeId record component
    • sourceEntityId

      public int sourceEntityId()
      Returns the value of the sourceEntityId record component.
      Returns:
      the value of the sourceEntityId record component
    • sourceDirectId

      public int sourceDirectId()
      Returns the value of the sourceDirectId record component.
      Returns:
      the value of the sourceDirectId record component
    • sourcePos

      @Nullable public @Nullable Point sourcePos()
      Returns the value of the sourcePos record component.
      Returns:
      the value of the sourcePos record component