Record Class ConstantValue
java.lang.Object
java.lang.Record
net.minecraft.world.level.storage.loot.providers.number.ConstantValue
- All Implemented Interfaces:
LootContextUser, NumberProvider, Validatable
A
NumberProvider that provides a constant value.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ConstantValue> static final com.mojang.serialization.MapCodec<ConstantValue> private final floatThe field for thevaluerecord component. -
Constructor Summary
ConstructorsConstructorDescriptionConstantValue(float value) Creates an instance of aConstantValuerecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<ConstantValue> codec()final booleanIndicates whether some other object is "equal to" this one.static ConstantValueexactly(float value) floatgetFloat(LootContext random) final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.floatvalue()Returns the value of thevaluerecord component.Methods inherited from interface LootContextUser
getReferencedContextParams, validateMethods inherited from interface NumberProvider
getInt
-
Field Details
-
value
private final float valueThe field for thevaluerecord component. -
MAP_CODEC
-
INLINE_CODEC
-
-
Constructor Details
-
ConstantValue
public ConstantValue(float value) Creates an instance of aConstantValuerecord class.- Parameters:
value- the value for thevaluerecord component
-
-
Method Details
-
codec
- Specified by:
codecin interfaceNumberProvider
-
getFloat
- Specified by:
getFloatin interfaceNumberProvider
-
exactly
-
toString
-
hashCode
-
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. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
value
public float value()Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-