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 damageddamageTypeId- ID of damage typesourceEntityId- 0 if there is no source entity, otherwise it is entityId + 1sourceDirectId- 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 + 1sourcePos- null if there is no source position, otherwise the position of the source
- All Implemented Interfaces:
NetworkBuffer.Writer,SendablePacket,ServerPacket
public record DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable Point sourcePos)
extends Record
implements ServerPacket
See https://wiki.vg/Protocol#Damage_Event for more info.
-
Constructor Summary
ConstructorsConstructorDescriptionDamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable Point sourcePos) Creates an instance of aDamageEventPacketrecord class.DamageEventPacket(@NotNull NetworkBuffer reader) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thedamageTypeIdrecord component.final booleanIndicates whether some other object is "equal to" this one.intgetId(@NotNull ConnectionState state) Gets the id of this packet.final inthashCode()Returns a hash code value for this object.intReturns the value of thesourceDirectIdrecord component.intReturns the value of thesourceEntityIdrecord component.@Nullable PointReturns the value of thesourcePosrecord component.intReturns the value of thetargetEntityIdrecord component.final StringtoString()Returns a string representation of this record class.voidwrite(@NotNull NetworkBuffer writer)
-
Constructor Details
-
DamageEventPacket
-
DamageEventPacket
public DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable @Nullable Point sourcePos) Creates an instance of aDamageEventPacketrecord class.- Parameters:
targetEntityId- the value for thetargetEntityIdrecord componentdamageTypeId- the value for thedamageTypeIdrecord componentsourceEntityId- the value for thesourceEntityIdrecord componentsourceDirectId- the value for thesourceDirectIdrecord componentsourcePos- the value for thesourcePosrecord component
-
-
Method Details
-
getId
Description copied from interface:ServerPacketGets the id of this packet.Written in the final buffer header so it needs to match the client id.
- Specified by:
getIdin interfaceServerPacket- Returns:
- the id of this packet
-
write
- Specified by:
writein interfaceNetworkBuffer.Writer
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
targetEntityId
public int targetEntityId()Returns the value of thetargetEntityIdrecord component.- Returns:
- the value of the
targetEntityIdrecord component
-
damageTypeId
public int damageTypeId()Returns the value of thedamageTypeIdrecord component.- Returns:
- the value of the
damageTypeIdrecord component
-
sourceEntityId
public int sourceEntityId()Returns the value of thesourceEntityIdrecord component.- Returns:
- the value of the
sourceEntityIdrecord component
-
sourceDirectId
public int sourceDirectId()Returns the value of thesourceDirectIdrecord component.- Returns:
- the value of the
sourceDirectIdrecord component
-
sourcePos
Returns the value of thesourcePosrecord component.- Returns:
- the value of the
sourcePosrecord component
-