Interface Palette<T>

All Known Implementing Classes:
ArrayPalette, BiMapPalette, IdListPalette, SingularPalette

public interface Palette<T>
A palette maps objects from and to small integer IDs that uses less number of bits to make storage smaller.

While the objects palettes handle are already represented by integer IDs, shrinking IDs in cases where only a few appear can further reduce storage space and network traffic volume.

See Also:
Mappings:
Namespace Name
named net/minecraft/world/chunk/Palette
intermediary net/minecraft/class_2837
official eaf
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An interface for easy creation of palettes.
  • Method Summary

    Modifier and Type
    Method
    Description
    copy(PaletteResizeListener<T> resizeListener)
     
    get(int id)
    Returns the object associated with the given id.
    int
    Returns the serialized size of this palette in a byte buf, in bytes.
    int
    Returns the size of the palette.
    boolean
    hasAny(Predicate<T> predicate)
    Returns true if any entry in this palette passes the predicate.
    int
    index(T object)
    Returns the ID of an object in this palette.
    void
    Initializes this palette from the buf.
    void
    Writes this palette to the buf.
  • Method Details

    • index

      int index(T object)
      Returns the ID of an object in this palette.

      If the object does not yet exist in this palette, this palette will register the object. If the palette is too small to include this object, a resize listener will be called and this palette may be discarded.

      Parameters:
      object - the object to look up
      Returns:
      the ID of an object in this palette
      Mappings:
      Namespace Name Mixin selector
      named index Lnet/minecraft/world/chunk/Palette;index(Ljava/lang/Object;)I
      intermediary method_12291 Lnet/minecraft/class_2837;method_12291(Ljava/lang/Object;)I
      official a Leaf;a(Ljava/lang/Object;)I
    • hasAny

      boolean hasAny(Predicate<T> predicate)
      Returns true if any entry in this palette passes the predicate.
      Returns:
      true if any entry in this palette passes the predicate
      Mappings:
      Namespace Name Mixin selector
      named hasAny Lnet/minecraft/world/chunk/Palette;hasAny(Ljava/util/function/Predicate;)Z
      intermediary method_19525 Lnet/minecraft/class_2837;method_19525(Ljava/util/function/Predicate;)Z
      official a Leaf;a(Ljava/util/function/Predicate;)Z
    • get

      T get(int id)
      Returns the object associated with the given id.
      Parameters:
      id - the ID to look up
      Returns:
      the object associated with the given id
      Throws:
      EntryMissingException - if this ID does not exist in this palette
      Mappings:
      Namespace Name Mixin selector
      named get Lnet/minecraft/world/chunk/Palette;get(I)Ljava/lang/Object;
      intermediary method_12288 Lnet/minecraft/class_2837;method_12288(I)Ljava/lang/Object;
      official a Leaf;a(I)Ljava/lang/Object;
    • readPacket

      void readPacket(PacketByteBuf buf)
      Initializes this palette from the buf. Clears the preexisting data in this palette.
      Parameters:
      buf - the packet byte buffer
      Mappings:
      Namespace Name Mixin selector
      named readPacket Lnet/minecraft/world/chunk/Palette;readPacket(Lnet/minecraft/network/PacketByteBuf;)V
      intermediary method_12289 Lnet/minecraft/class_2837;method_12289(Lnet/minecraft/class_2540;)V
      official a Leaf;a(Lws;)V
    • writePacket

      void writePacket(PacketByteBuf buf)
      Writes this palette to the buf.
      Parameters:
      buf - the packet byte buffer
      Mappings:
      Namespace Name Mixin selector
      named writePacket Lnet/minecraft/world/chunk/Palette;writePacket(Lnet/minecraft/network/PacketByteBuf;)V
      intermediary method_12287 Lnet/minecraft/class_2837;method_12287(Lnet/minecraft/class_2540;)V
      official b Leaf;b(Lws;)V
    • getPacketSize

      int getPacketSize()
      Returns the serialized size of this palette in a byte buf, in bytes.
      Returns:
      the serialized size of this palette in a byte buf, in bytes
      Mappings:
      Namespace Name Mixin selector
      named getPacketSize Lnet/minecraft/world/chunk/Palette;getPacketSize()I
      intermediary method_12290 Lnet/minecraft/class_2837;method_12290()I
      official a Leaf;a()I
    • getSize

      int getSize()
      Returns the size of the palette.
      Returns:
      the size of the palette
      Mappings:
      Namespace Name Mixin selector
      named getSize Lnet/minecraft/world/chunk/Palette;getSize()I
      intermediary method_12197 Lnet/minecraft/class_2837;method_12197()I
      official b Leaf;b()I
    • copy

      Palette<T> copy(PaletteResizeListener<T> resizeListener)
      Mappings:
      Namespace Name Mixin selector
      named copy Lnet/minecraft/world/chunk/Palette;copy(Lnet/minecraft/world/chunk/PaletteResizeListener;)Lnet/minecraft/world/chunk/Palette;
      intermediary method_39956 Lnet/minecraft/class_2837;method_39956(Lnet/minecraft/class_2835;)Lnet/minecraft/class_2837;
      official a Leaf;a(Leag;)Leaf;