Record Class VillagerOffers

java.lang.Object
java.lang.Record
net.darkhax.bookshelf.common.api.entity.villager.trades.VillagerOffers
Record Components:
offers - An equally weighted array of offers.
All Implemented Interfaces:
net.minecraft.world.entity.npc.VillagerTrades.ItemListing

public record VillagerOffers(Supplier<net.minecraft.world.item.trading.MerchantOffer>[] offers) extends Record implements net.minecraft.world.entity.npc.VillagerTrades.ItemListing
A simple villager trade entry that selects a random offer from an equally weighted array of offers.
  • Constructor Summary

    Constructors
    Constructor
    Description
    VillagerOffers(Supplier<net.minecraft.world.item.trading.MerchantOffer>... offers)
    Creates an instance of a VillagerOffers record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    net.minecraft.world.item.trading.MerchantOffer
    getOffer(@NotNull net.minecraft.world.entity.Entity entity, @NotNull net.minecraft.util.RandomSource randomSource)
     
    final int
    Returns a hash code value for this object.
    Supplier<net.minecraft.world.item.trading.MerchantOffer>[]
    Returns the value of the offers 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
  • Constructor Details

    • VillagerOffers

      @SafeVarargs public VillagerOffers(Supplier<net.minecraft.world.item.trading.MerchantOffer>... offers)
      Creates an instance of a VillagerOffers record class.
      Parameters:
      offers - the value for the offers record component
  • Method Details

    • getOffer

      public net.minecraft.world.item.trading.MerchantOffer getOffer(@NotNull @NotNull net.minecraft.world.entity.Entity entity, @NotNull @NotNull net.minecraft.util.RandomSource randomSource)
      Specified by:
      getOffer in interface net.minecraft.world.entity.npc.VillagerTrades.ItemListing
    • 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.
    • offers

      public Supplier<net.minecraft.world.item.trading.MerchantOffer>[] offers()
      Returns the value of the offers record component.
      Returns:
      the value of the offers record component