Record Class AddIfBlockStateBonus
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.theme.power.bonus.AddIfBlockStateBonus
- Record Components:
property- The name of thePropertyto check on the block state (e.g.,"lit"or"has_book").value- The expected string representation of the property's value for the bonus to apply (e.g.,"true").bonus- The flat integer amount of enchanting power to add if the condition is met.
- All Implemented Interfaces:
PowerBonus
public record AddIfBlockStateBonus(String property, String value, int bonus)
extends Record
implements PowerBonus
A data-driven
PowerBonus implementation that adds a fixed bonus amount
to the enchanting power if a specific block state property on the power-providing block
matches a designated string value.
Useful for conditional power, such as granting a bonus only if a candle is lit (lit = "true").
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<AddIfBlockStateBonus> The codec responsible for serializing and deserializing instances of this record from JSON. -
Constructor Summary
ConstructorsConstructorDescriptionAddIfBlockStateBonus(String property, String value, int bonus) Creates an instance of aAddIfBlockStateBonusrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintbonus()Returns the value of thebonusrecord 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.property()Returns the value of thepropertyrecord component.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Field Details
-
CODEC
The codec responsible for serializing and deserializing instances of this record from JSON.
-
-
Constructor Details
-
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:
"add_if_block_state".
-
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 '=='. -
property
Returns the value of thepropertyrecord component.- Returns:
- the value of the
propertyrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
bonus
public int bonus()Returns the value of thebonusrecord component.- Returns:
- the value of the
bonusrecord component
-