Record Class ConditionalNumberProvider

java.lang.Object
java.lang.Record
com.petrolpark.core.data.loot.numberprovider.ConditionalNumberProvider
All Implemented Interfaces:
IEstimableNumberProvider, net.minecraft.world.level.storage.loot.LootContextUser, net.minecraft.world.level.storage.loot.providers.number.NumberProvider

public record ConditionalNumberProvider(net.minecraft.world.level.storage.loot.predicates.LootItemCondition condition, net.minecraft.world.level.storage.loot.providers.number.NumberProvider pass, net.minecraft.world.level.storage.loot.providers.number.NumberProvider fail) extends Record implements IEstimableNumberProvider

petrolpark:conditional

Choose between two NumberProviders based on whether a LootItemCondition passes. Arguments:
  • condition - LootItemCondition to test
  • pass - NumberProvider to call if the condition is met
  • fail - NumberProvider to call if the condition is not met
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<ConditionalNumberProvider>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConditionalNumberProvider(net.minecraft.world.level.storage.loot.predicates.LootItemCondition condition, net.minecraft.world.level.storage.loot.providers.number.NumberProvider pass, net.minecraft.world.level.storage.loot.providers.number.NumberProvider fail)
    Creates an instance of a ConditionalNumberProvider record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.level.storage.loot.predicates.LootItemCondition
    Returns the value of the condition record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    net.minecraft.world.level.storage.loot.providers.number.NumberProvider
    Returns the value of the fail record component.
    net.minecraft.world.level.storage.loot.providers.number.NumberProvider
    get(net.minecraft.world.level.storage.loot.LootContext context)
     
    A rough estimate for the output of this Number Provider, for display purposes only.
    float
    getFloat(net.minecraft.world.level.storage.loot.LootContext lootContext)
     
    int
    getInt(net.minecraft.world.level.storage.loot.LootContext lootContext)
     
    float
    getMaxFloat(net.minecraft.world.level.storage.loot.LootContext context)
    The maximum possible value this Number Provider can give, ignoring any randomness.
    Set<net.minecraft.world.level.storage.loot.parameters.LootContextParam<?>>
     
    net.minecraft.world.level.storage.loot.providers.number.LootNumberProviderType
     
    final int
    Returns a hash code value for this object.
    net.minecraft.world.level.storage.loot.providers.number.NumberProvider
    Returns the value of the pass record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.minecraft.world.level.storage.loot.LootContextUser

    validate
  • Field Details

  • Constructor Details

    • ConditionalNumberProvider

      public ConditionalNumberProvider(net.minecraft.world.level.storage.loot.predicates.LootItemCondition condition, net.minecraft.world.level.storage.loot.providers.number.NumberProvider pass, net.minecraft.world.level.storage.loot.providers.number.NumberProvider fail)
      Creates an instance of a ConditionalNumberProvider record class.
      Parameters:
      condition - the value for the condition record component
      pass - the value for the pass record component
      fail - the value for the fail record component
  • Method Details

    • get

      public net.minecraft.world.level.storage.loot.providers.number.NumberProvider get(net.minecraft.world.level.storage.loot.LootContext context)
    • getFloat

      public float getFloat(@Nonnull net.minecraft.world.level.storage.loot.LootContext lootContext)
      Specified by:
      getFloat in interface net.minecraft.world.level.storage.loot.providers.number.NumberProvider
    • getInt

      public int getInt(@Nonnull net.minecraft.world.level.storage.loot.LootContext lootContext)
      Specified by:
      getInt in interface net.minecraft.world.level.storage.loot.providers.number.NumberProvider
    • getType

      public net.minecraft.world.level.storage.loot.providers.number.LootNumberProviderType getType()
      Specified by:
      getType in interface net.minecraft.world.level.storage.loot.providers.number.NumberProvider
    • getEstimate

      public NumberEstimate getEstimate()
      Description copied from interface: IEstimableNumberProvider
      A rough estimate for the output of this Number Provider, for display purposes only.
      Specified by:
      getEstimate in interface IEstimableNumberProvider
    • getMaxFloat

      public float getMaxFloat(net.minecraft.world.level.storage.loot.LootContext context)
      Description copied from interface: IEstimableNumberProvider
      The maximum possible value this Number Provider can give, ignoring any randomness.
      Specified by:
      getMaxFloat in interface IEstimableNumberProvider
    • getReferencedContextParams

      public Set<net.minecraft.world.level.storage.loot.parameters.LootContextParam<?>> getReferencedContextParams()
      Specified by:
      getReferencedContextParams in interface net.minecraft.world.level.storage.loot.LootContextUser
    • 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.
    • condition

      public net.minecraft.world.level.storage.loot.predicates.LootItemCondition condition()
      Returns the value of the condition record component.
      Returns:
      the value of the condition record component
    • pass

      public net.minecraft.world.level.storage.loot.providers.number.NumberProvider pass()
      Returns the value of the pass record component.
      Returns:
      the value of the pass record component
    • fail

      public net.minecraft.world.level.storage.loot.providers.number.NumberProvider fail()
      Returns the value of the fail record component.
      Returns:
      the value of the fail record component