Package net.minecraft.world.item
Record Class Instrument
java.lang.Object
java.lang.Record
net.minecraft.world.item.Instrument
public record Instrument(Holder<SoundEvent> soundEvent, int useDuration, float range)
extends Record
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<Holder<Instrument>> static final com.mojang.serialization.Codec<Instrument> static final StreamCodec<RegistryFriendlyByteBuf, Instrument> private final floatThe field for therangerecord component.private final Holder<SoundEvent> The field for thesoundEventrecord component.static final StreamCodec<RegistryFriendlyByteBuf, Holder<Instrument>> private final intThe field for theuseDurationrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionInstrument(Holder<SoundEvent> soundEvent, int useDuration, float range) Creates an instance of aInstrumentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.floatrange()Returns the value of therangerecord component.Returns the value of thesoundEventrecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of theuseDurationrecord component.
-
Field Details
-
soundEvent
The field for thesoundEventrecord component. -
useDuration
private final int useDurationThe field for theuseDurationrecord component. -
range
private final float rangeThe field for therangerecord component. -
DIRECT_CODEC
-
DIRECT_STREAM_CODEC
-
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
Instrument
Creates an instance of aInstrumentrecord class.- Parameters:
soundEvent- the value for thesoundEventrecord componentuseDuration- the value for theuseDurationrecord componentrange- the value for therangerecord component
-
-
Method Details
-
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 '=='. -
soundEvent
Returns the value of thesoundEventrecord component.- Returns:
- the value of the
soundEventrecord component
-
useDuration
public int useDuration()Returns the value of theuseDurationrecord component.- Returns:
- the value of the
useDurationrecord component
-
range
public float range()Returns the value of therangerecord component.- Returns:
- the value of the
rangerecord component
-