Record Class LootItemRandomChanceWithEnchantedBonusCondition

java.lang.Object
java.lang.Record
net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceWithEnchantedBonusCondition
All Implemented Interfaces:
Predicate<LootContext>, LootContextUser, LootItemCondition

public record LootItemRandomChanceWithEnchantedBonusCondition(float unenchantedChance, LevelBasedValue enchantedChance, Holder<Enchantment> enchantment) extends Record implements LootItemCondition
  • Field Details

    • unenchantedChance

      private final float unenchantedChance
      The field for the unenchantedChance record component.
    • enchantedChance

      private final LevelBasedValue enchantedChance
      The field for the enchantedChance record component.
    • enchantment

      private final Holder<Enchantment> enchantment
      The field for the enchantment record component.
    • CODEC

      public static final com.mojang.serialization.MapCodec<LootItemRandomChanceWithEnchantedBonusCondition> CODEC
  • Constructor Details

    • LootItemRandomChanceWithEnchantedBonusCondition

      public LootItemRandomChanceWithEnchantedBonusCondition(float unenchantedChance, LevelBasedValue enchantedChance, Holder<Enchantment> enchantment)
      Creates an instance of a LootItemRandomChanceWithEnchantedBonusCondition record class.
      Parameters:
      unenchantedChance - the value for the unenchantedChance record component
      enchantedChance - the value for the enchantedChance record component
      enchantment - the value for the enchantment record component
  • Method Details

    • getType

      public LootItemConditionType getType()
      Specified by:
      getType in interface LootItemCondition
    • getReferencedContextParams

      public Set<LootContextParam<?>> getReferencedContextParams()
      Specified by:
      getReferencedContextParams in interface LootContextUser
    • test

      public boolean test(LootContext p_343845_)
      Specified by:
      test in interface Predicate<LootContext>
    • randomChanceAndLootingBoost

      public static LootItemCondition.Builder randomChanceAndLootingBoost(HolderLookup.Provider p_343257_, float p_343637_, float p_342446_)
    • 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.
    • unenchantedChance

      public float unenchantedChance()
      Returns the value of the unenchantedChance record component.
      Returns:
      the value of the unenchantedChance record component
    • enchantedChance

      public LevelBasedValue enchantedChance()
      Returns the value of the enchantedChance record component.
      Returns:
      the value of the enchantedChance record component
    • enchantment

      public Holder<Enchantment> enchantment()
      Returns the value of the enchantment record component.
      Returns:
      the value of the enchantment record component