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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<Display>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf,Display>
     
    static final com.mojang.serialization.Codec<List<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

    Constructors
    Constructor
    Description
    DisplayType(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 a DisplayType record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.mojang.serialization.MapCodec<T>
    Returns the value of the codec record component.
    final boolean
    Indicates 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 int
    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>
    Returns the value of the stream record component.
    final String
    Returns a string representation of this record class.
    net.minecraft.resources.ResourceLocation
    Returns the value of the typeId record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • TYPE_CODEC

      public static final com.mojang.serialization.Codec<DisplayType<?>> 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

      public static final com.mojang.serialization.Codec<Display> DISPLAY_STATE_CODEC
    • DISPLAY_STATE_STREAM

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf,Display> DISPLAY_STATE_STREAM
    • LIST_CODEC

      public static final com.mojang.serialization.Codec<List<Display>> LIST_CODEC
  • Constructor Details

    • DisplayType

      public DisplayType(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 a DisplayType record class.
      Parameters:
      typeId - the value for the typeId record component
      codec - the value for the codec record component
      stream - the value for the stream record component
  • 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • typeId

      public net.minecraft.resources.ResourceLocation typeId()
      Returns the value of the typeId record component.
      Returns:
      the value of the typeId record component
    • codec

      public com.mojang.serialization.MapCodec<T> codec()
      Returns the value of the codec record component.
      Returns:
      the value of the codec record component
    • stream

      public net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf,T> stream()
      Returns the value of the stream record component.
      Returns:
      the value of the stream record component