Record Class VillagerSells

java.lang.Object
java.lang.Record
net.darkhax.bookshelf.common.api.entity.villager.trades.VillagerSells
Record Components:
itemToBuy - The item being sold by the villager.
emeraldCost - The amount of emeralds the trade will cost.
maxUses - The amount of times the trade can be performed before a restocking is required.
villagerXp - The amount of villager XP to award for performing the trade.
priceMultiplier - A price multiplier.
All Implemented Interfaces:
net.minecraft.world.entity.npc.VillagerTrades.ItemListing

public record VillagerSells(Supplier<net.minecraft.world.item.ItemStack> itemToBuy, int emeraldCost, int maxUses, int villagerXp, float priceMultiplier) extends Record implements net.minecraft.world.entity.npc.VillagerTrades.ItemListing
A simple villager trade entry that represents an item being sold to the player.
  • Constructor Summary

    Constructors
    Constructor
    Description
    VillagerSells(Supplier<net.minecraft.world.item.ItemStack> itemToBuy, int emeraldCost, int maxUses, int villagerXp, float priceMultiplier)
    Creates an instance of a VillagerSells record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the emeraldCost record component.
    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 villager, @NotNull net.minecraft.util.RandomSource rng)
     
    final int
    Returns a hash code value for this object.
    Supplier<net.minecraft.world.item.ItemStack>
    Returns the value of the itemToBuy record component.
    int
    Returns the value of the maxUses record component.
    float
    Returns the value of the priceMultiplier record component.
    final String
    Returns a string representation of this record class.
    int
    Returns the value of the villagerXp record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • VillagerSells

      public VillagerSells(Supplier<net.minecraft.world.item.ItemStack> itemToBuy, int emeraldCost, int maxUses, int villagerXp, float priceMultiplier)
      Creates an instance of a VillagerSells record class.
      Parameters:
      itemToBuy - the value for the itemToBuy record component
      emeraldCost - the value for the emeraldCost record component
      maxUses - the value for the maxUses record component
      villagerXp - the value for the villagerXp record component
      priceMultiplier - the value for the priceMultiplier record component
  • Method Details

    • getOffer

      public net.minecraft.world.item.trading.MerchantOffer getOffer(@NotNull @NotNull net.minecraft.world.entity.Entity villager, @NotNull @NotNull net.minecraft.util.RandomSource rng)
      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. 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.
    • itemToBuy

      public Supplier<net.minecraft.world.item.ItemStack> itemToBuy()
      Returns the value of the itemToBuy record component.
      Returns:
      the value of the itemToBuy record component
    • emeraldCost

      public int emeraldCost()
      Returns the value of the emeraldCost record component.
      Returns:
      the value of the emeraldCost record component
    • maxUses

      public int maxUses()
      Returns the value of the maxUses record component.
      Returns:
      the value of the maxUses record component
    • villagerXp

      public int villagerXp()
      Returns the value of the villagerXp record component.
      Returns:
      the value of the villagerXp record component
    • priceMultiplier

      public float priceMultiplier()
      Returns the value of the priceMultiplier record component.
      Returns:
      the value of the priceMultiplier record component