Record Class CountItemsInInventoryBonus
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.theme.power.bonus.CountItemsInInventoryBonus
- Record Components:
items- AHolderSetrepresenting the item(s) or item tag that should be counted within the target block entity's inventory.bonusPerItem- The fixed integer amount of enchanting power added for each matching item counted.
- All Implemented Interfaces:
PowerBonus
public record CountItemsInInventoryBonus(net.minecraft.core.HolderSet<net.minecraft.world.item.Item> items, int bonusPerItem)
extends Record
implements PowerBonus
A data-driven
PowerBonus implementation that calculates bonus enchanting power
based on the quantity of specific items found inside a power-providing block entity's inventory.
Typically applied to block entities that implement Container,
such as Chiseled Bookshelves holding Enchanted Books.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<CountItemsInInventoryBonus> The codec responsible for serializing and deserializing instances of this record from JSON. -
Constructor Summary
ConstructorsConstructorDescriptionCountItemsInInventoryBonus(net.minecraft.core.HolderSet<net.minecraft.world.item.Item> items, int bonusPerItem) Creates an instance of aCountItemsInInventoryBonusrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thebonusPerItemrecord component.final booleanIndicates whether some other object is "equal to" this one.com.mojang.serialization.MapCodec<? extends PowerBonus> getCodec()Retrieves theMapCodecresponsible for encoding and decoding this specific bonus implementation.Retrieves the unique identifier string associated with this specific bonus implementation.final inthashCode()Returns a hash code value for this object.net.minecraft.core.HolderSet<net.minecraft.world.item.Item> items()Returns the value of theitemsrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
The codec responsible for serializing and deserializing instances of this record from JSON.Uses
RegistryCodecs.homogeneousList(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<E>>, com.mojang.serialization.Codec<E>)to handle theHolderSetof items.
-
-
Constructor Details
-
CountItemsInInventoryBonus
public CountItemsInInventoryBonus(net.minecraft.core.HolderSet<net.minecraft.world.item.Item> items, int bonusPerItem) Creates an instance of aCountItemsInInventoryBonusrecord class.- Parameters:
items- the value for theitemsrecord componentbonusPerItem- the value for thebonusPerItemrecord component
-
-
Method Details
-
getTypeId
Retrieves the unique identifier string associated with this specific bonus implementation.- Specified by:
getTypeIdin interfacePowerBonus- Returns:
- The constant ID string for this bonus type:
"count_items_in_inventory".
-
getCodec
Retrieves theMapCodecresponsible for encoding and decoding this specific bonus implementation.- Specified by:
getCodecin interfacePowerBonus- Returns:
- The
MapCodecfor this bonus type.
-
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 '=='. -
items
public net.minecraft.core.HolderSet<net.minecraft.world.item.Item> items()Returns the value of theitemsrecord component.- Returns:
- the value of the
itemsrecord component
-
bonusPerItem
public int bonusPerItem()Returns the value of thebonusPerItemrecord component.- Returns:
- the value of the
bonusPerItemrecord component
-