Record Class DisplayType<T extends Display>
java.lang.Object
java.lang.Record
net.darkhax.botanypots.common.api.data.display.types.DisplayType<T>
- Type Parameters:
T- The type of display.- Record Components:
typeId- The ID of the type.codec- A codec that serializes the display.stream- A stream codec that serializes the display.
public record DisplayType<T extends Display>(net.minecraft.resources.ResourceLocation typeId, com.mojang.serialization.MapCodec<T extends Display> codec, net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf,T extends Display> stream)
extends Record
Represents a type of display. Handles the serialization of the display and is used to bind renderers. Display types
must be registered.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<Display> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, Display> static final com.mojang.serialization.Codec<DisplayType<?>> static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf, ? extends DisplayType<? extends Display>> -
Constructor Summary
ConstructorsConstructorDescriptionDisplayType(net.minecraft.resources.ResourceLocation typeId, com.mojang.serialization.MapCodec<T> codec, net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, T> stream) Creates an instance of aDisplayTyperecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<T> codec()Returns the value of thecodecrecord component.final booleanIndicates whether some other object is "equal to" this one.static <T extends Display>
@Nullable DisplayType<T> get(net.minecraft.resources.ResourceLocation id) Gets a display type by its ID.final inthashCode()Returns a hash code value for this object.static <T extends Display>
DisplayType<T> register(net.minecraft.resources.ResourceLocation id, com.mojang.serialization.MapCodec<T> codec, net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, T> buffer) Registers a display type.net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, T> stream()Returns the value of thestreamrecord component.final StringtoString()Returns a string representation of this record class.net.minecraft.resources.ResourceLocationtypeId()Returns the value of thetypeIdrecord component.
-
Field Details
-
TYPE_CODEC
-
TYPE_STREAM
public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,? extends DisplayType<? extends Display>> TYPE_STREAM -
DISPLAY_STATE_CODEC
-
DISPLAY_STATE_STREAM
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf,Display> DISPLAY_STATE_STREAM -
LIST_CODEC
-
-
Constructor Details
-
Method Details
-
get
@Nullable public static <T extends Display> @Nullable DisplayType<T> get(net.minecraft.resources.ResourceLocation id) Gets a display type by its ID. Will be null if no type with the provided ID exists.- Type Parameters:
T- The type of the display.- Parameters:
id- The ID of the type to lookup.- Returns:
- The registered type or null if no type was found.
-
register
public static <T extends Display> DisplayType<T> register(net.minecraft.resources.ResourceLocation id, com.mojang.serialization.MapCodec<T> codec, net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, T> buffer) Registers a display type.- Type Parameters:
T- The type of display represented by the type.- Parameters:
id- The ID to register the type with.codec- The codec for the type.buffer- The stream codec for the type.- Returns:
- The registered display 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. All components in this record class are compared withObjects::equals(Object,Object). -
typeId
public net.minecraft.resources.ResourceLocation typeId()Returns the value of thetypeIdrecord component.- Returns:
- the value of the
typeIdrecord component
-
codec
Returns the value of thecodecrecord component.- Returns:
- the value of the
codecrecord component
-
stream
Returns the value of thestreamrecord component.- Returns:
- the value of the
streamrecord component
-