Package fr.pacdu.pacpackquests.reward
Record Class ItemReward
java.lang.Object
java.lang.Record
fr.pacdu.pacpackquests.reward.ItemReward
- Record Components:
target- The item identifier string, SNBT command string, or item tag (prefixed with #).amount- The number of items to grant.
- All Implemented Interfaces:
QuestReward
A quest reward that grants item stacks (direct items, items with NBT/components, or random items from a tag).
-
Constructor Summary
ConstructorsConstructorDescriptionItemReward(String target, int amount) Creates an instance of aItemRewardrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintamount()Returns the value of theamountrecord component.net.minecraft.world.item.ItemStackcreateIconStack(net.minecraft.core.HolderLookup.Provider registries) Generates a visual ItemStack representing this reward for display in tooltips and menus.final booleanIndicates whether some other object is "equal to" this one.voidgrant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager) Grants the reward to the given server player.final inthashCode()Returns a hash code value for this object.static ItemRewardread(net.minecraft.network.FriendlyByteBuf buf) Reads anItemRewardfrom the network buffer.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the category type of this reward.voidwrite(net.minecraft.network.FriendlyByteBuf buf) Serializes this reward into a network buffer.
-
Constructor Details
-
Method Details
-
type
Description copied from interface:QuestRewardReturns the category type of this reward.- Specified by:
typein interfaceQuestReward- Returns:
- The
RewardType.
-
grant
public void grant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager) Description copied from interface:QuestRewardGrants the reward to the given server player.- Specified by:
grantin interfaceQuestReward- Parameters:
player- TheServerPlayerclaiming 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:QuestRewardGenerates a visual ItemStack representing this reward for display in tooltips and menus.- Specified by:
createIconStackin interfaceQuestReward- Parameters:
registries- The registry lookup provider.- Returns:
- An
ItemStackfor GUI rendering.
-
write
public void write(net.minecraft.network.FriendlyByteBuf buf) Description copied from interface:QuestRewardSerializes this reward into a network buffer.- Specified by:
writein interfaceQuestReward- Parameters:
buf- TheFriendlyByteBufto write into.
-
read
Reads anItemRewardfrom the network buffer.- Parameters:
buf- The buffer to read from.- Returns:
- The read
ItemReward.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
amount
public int amount()Returns the value of theamountrecord component.- Specified by:
amountin interfaceQuestReward- Returns:
- the value of the
amountrecord component
-