Record Class DamageSourcePredicate

java.lang.Object
java.lang.Record
net.minecraft.advancements.critereon.DamageSourcePredicate

public record DamageSourcePredicate(List<TagPredicate<DamageType>> tags, Optional<EntityPredicate> directEntity, Optional<EntityPredicate> sourceEntity) extends Record
  • Field Details

  • Constructor Details

    • DamageSourcePredicate

      public DamageSourcePredicate(List<TagPredicate<DamageType>> tags, Optional<EntityPredicate> directEntity, Optional<EntityPredicate> sourceEntity)
      Creates an instance of a DamageSourcePredicate record class.
      Parameters:
      tags - the value for the tags record component
      directEntity - the value for the directEntity record component
      sourceEntity - the value for the sourceEntity record component
  • Method Details

    • matches

      public boolean matches(ServerPlayer p_25449_, DamageSource p_25450_)
    • matches

      public boolean matches(ServerLevel p_25445_, Vec3 p_25446_, DamageSource p_25447_)
    • fromJson

      public static Optional<DamageSourcePredicate> fromJson(@Nullable com.google.gson.JsonElement p_25452_)
    • serializeToJson

      public com.google.gson.JsonElement serializeToJson()
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • tags

      public List<TagPredicate<DamageType>> tags()
      Returns the value of the tags record component.
      Returns:
      the value of the tags record component
    • directEntity

      public Optional<EntityPredicate> directEntity()
      Returns the value of the directEntity record component.
      Returns:
      the value of the directEntity record component
    • sourceEntity

      public Optional<EntityPredicate> sourceEntity()
      Returns the value of the sourceEntity record component.
      Returns:
      the value of the sourceEntity record component