Record Class XpReward

java.lang.Object
java.lang.Record
fr.pacdu.pacpackquests.reward.XpReward
Record Components:
amount - The number of experience points to grant.
All Implemented Interfaces:
QuestReward

public record XpReward(int amount) extends Record implements QuestReward
A quest reward that grants flat experience points directly to the player.
  • Constructor Summary

    Constructors
    Constructor
    Description
    XpReward(int amount)
    Creates an instance of a XpReward record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the amount record component.
    net.minecraft.world.item.ItemStack
    createIconStack(net.minecraft.core.HolderLookup.Provider registries)
    Generates a visual ItemStack representing this reward for display in tooltips and menus.
    final boolean
    Indicates whether some other object is "equal to" this one.
    void
    grant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager)
    Grants the reward to the given server player.
    final int
    Returns a hash code value for this object.
    static XpReward
    read(net.minecraft.network.FriendlyByteBuf buf)
    Reads an XpReward from the network buffer.
    final String
    Returns a string representation of this record class.
    Returns the category type of this reward.
    void
    write(net.minecraft.network.FriendlyByteBuf buf)
    Serializes this reward into a network buffer.

    Methods inherited from class java.lang.Object

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

    • XpReward

      public XpReward(int amount)
      Creates an instance of a XpReward record class.
      Parameters:
      amount - the value for the amount record component
  • Method Details

    • type

      public RewardType type()
      Description copied from interface: QuestReward
      Returns the category type of this reward.
      Specified by:
      type in interface QuestReward
      Returns:
      The RewardType.
    • grant

      public void grant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager)
      Description copied from interface: QuestReward
      Grants the reward to the given server player.
      Specified by:
      grant in interface QuestReward
      Parameters:
      player - The ServerPlayer claiming the quest.
      registryManager - The server registry access.
    • createIconStack

      public net.minecraft.world.item.ItemStack createIconStack(net.minecraft.core.HolderLookup.Provider registries)
      Description copied from interface: QuestReward
      Generates a visual ItemStack representing this reward for display in tooltips and menus.
      Specified by:
      createIconStack in interface QuestReward
      Parameters:
      registries - The registry lookup provider.
      Returns:
      An ItemStack for GUI rendering.
    • write

      public void write(net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: QuestReward
      Serializes this reward into a network buffer.
      Specified by:
      write in interface QuestReward
      Parameters:
      buf - The FriendlyByteBuf to write into.
    • read

      public static XpReward read(net.minecraft.network.FriendlyByteBuf buf)
      Reads an XpReward from the network buffer.
      Parameters:
      buf - The buffer to read from.
      Returns:
      The read XpReward.
    • 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 '=='.
      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.
    • amount

      public int amount()
      Returns the value of the amount record component.
      Specified by:
      amount in interface QuestReward
      Returns:
      the value of the amount record component