java.lang.Object
java.lang.Record
top.offsetmonkey538.loottablemodifier.common.api.resource.LootModifier
Record Components:
actions - a list of actions to apply
predicate - the predicate
All Implemented Interfaces:
Predicate<LootModifierContext>

public record LootModifier(@NotNull @UnmodifiableView List<LootModifierAction> actions, @NotNull LootModifierPredicate predicate) extends Record implements Predicate<LootModifierContext>
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<LootModifier> CODEC
  • Constructor Details

    • LootModifier

      public LootModifier(@NotNull @NotNull @UnmodifiableView List<LootModifierAction> actions, @NotNull @NotNull LootModifierPredicate predicate)
      Creates an instance of a LootModifier record class.
      Parameters:
      actions - the value for the actions record component
      predicate - the value for the predicate record component
  • Method Details

    • apply

      public int apply(@NotNull @NotNull LootModifierContext context)
      Applied all the actions of this modifier using the provided context.
      Parameters:
      context - context to modify
      Returns:
      highest modification level from applied actions. LootModifierAction.MODIFIED_NONE when no action was applied.
      See Also:
    • test

      public boolean test(@NotNull @NotNull LootModifierContext context)
      Tests the predicate of this loot modifier against the provided context.
      Specified by:
      test in interface Predicate<LootModifierContext>
      Parameters:
      context - the context to match against
      Returns:
      if the predicate of this loot modifier matched the provided context
    • builder

      @Contract("->new") public static LootModifier.Builder builder()
      Creates a builder for LootModifier
      Returns:
      a new LootModifier.Builder
    • 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.
    • actions

      @NotNull public @NotNull @UnmodifiableView List<LootModifierAction> actions()
      Returns the value of the actions record component.
      Returns:
      the value of the actions record component
    • predicate

      @NotNull public @NotNull LootModifierPredicate predicate()
      Returns the value of the predicate record component.
      Returns:
      the value of the predicate record component