Class AbstractRegisterEntry<T>

java.lang.Object
com.hexagram2021.chromosomelib.registry.AbstractRegisterEntry<T>
Type Parameters:
T - the type of the entry
All Implemented Interfaces:
Supplier<T>, net.minecraft.core.Holder<T>

public abstract class AbstractRegisterEntry<T> extends Object implements net.minecraft.core.Holder<T>, Supplier<T>
Abstract register entry.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.core.Holder

    net.minecraft.core.Holder.Direct<T extends Object>, net.minecraft.core.Holder.Kind, net.minecraft.core.Holder.Reference<T extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final net.minecraft.resources.ResourceKey<T>
    resource key of the entry
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractRegisterEntry(net.minecraft.resources.ResourceKey<T> key)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract net.minecraft.core.Holder<T>
    Get the vanilla holder of the entry.
     
    abstract boolean
    canSerializeIn(net.minecraft.core.HolderOwner<T> owner)
     
    static <T> int
    compare(net.minecraft.core.Holder<T> a, net.minecraft.core.Holder<T> b)
    Compare two holders.
    boolean
     
    static boolean
    equals(net.minecraft.core.Holder<?> a, net.minecraft.core.Holder<?> b)
    Compare two holders.
    get()
     
    int
     
    static int
    hashCode(net.minecraft.core.Holder<?> holder)
    Get the hash code of the holder.
    net.minecraft.resources.ResourceLocation
    id()
    Get the id of the entry.
    boolean
    is(Predicate<net.minecraft.resources.ResourceKey<T>> filter)
     
    boolean
    is(net.minecraft.resources.ResourceKey<T> key)
     
    boolean
    is(net.minecraft.resources.ResourceLocation id)
     
    abstract boolean
    is(net.minecraft.tags.TagKey<T> tag)
     
    abstract boolean
     
    net.minecraft.resources.ResourceKey<T>
    key()
    Get the key of the entry.
    net.minecraft.core.Holder.Kind
     
    static <T> it.unimi.dsi.fastutil.objects.Object2IntMap<net.minecraft.core.Holder<T>>
    Create a tree map with the comparator.
    static <T, V> Map<net.minecraft.core.Holder<T>,V>
    Create a tree map with the comparator.
    static <T> Set<net.minecraft.core.Holder<T>>
    Create a tree set with the comparator.
    abstract Stream<net.minecraft.tags.TagKey<T>>
     
     
    com.mojang.datafixers.util.Either<net.minecraft.resources.ResourceKey<T>,T>
     
    Optional<net.minecraft.resources.ResourceKey<T>>
     
    abstract T
     

    Methods inherited from class java.lang.Object

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

    • key

      protected final net.minecraft.resources.ResourceKey<T> key
      resource key of the entry
  • Constructor Details

    • AbstractRegisterEntry

      protected AbstractRegisterEntry(net.minecraft.resources.ResourceKey<T> key)
      Constructor.
      Parameters:
      key - resource key of the entry
  • Method Details

    • is

      public boolean is(net.minecraft.resources.ResourceLocation id)
      Specified by:
      is in interface net.minecraft.core.Holder<T>
      Parameters:
      id - id to check
      Returns:
      true if the entry matches the id.
    • is

      public boolean is(net.minecraft.resources.ResourceKey<T> key)
      Specified by:
      is in interface net.minecraft.core.Holder<T>
      Parameters:
      key - key to check
      Returns:
      true if the entry matches the key.
    • is

      public boolean is(Predicate<net.minecraft.resources.ResourceKey<T>> filter)
      Specified by:
      is in interface net.minecraft.core.Holder<T>
      Parameters:
      filter - filter to check
      Returns:
      true if the entry matches the filter.
    • is

      public abstract boolean is(net.minecraft.tags.TagKey<T> tag)
      Specified by:
      is in interface net.minecraft.core.Holder<T>
      Parameters:
      tag - tag to check
      Returns:
      true if the entry is in the tag.
    • tags

      public abstract Stream<net.minecraft.tags.TagKey<T>> tags()
      Specified by:
      tags in interface net.minecraft.core.Holder<T>
      Returns:
      tags of the entry.
    • isBound

      public abstract boolean isBound()
      Specified by:
      isBound in interface net.minecraft.core.Holder<T>
      Returns:
      true if the entry is bound.
    • unwrap

      public com.mojang.datafixers.util.Either<net.minecraft.resources.ResourceKey<T>,T> unwrap()
      Specified by:
      unwrap in interface net.minecraft.core.Holder<T>
      Returns:
      resource key of the entry.
      See Also:
      • Holder.Reference.unwrap()
    • unwrapKey

      public Optional<net.minecraft.resources.ResourceKey<T>> unwrapKey()
      Specified by:
      unwrapKey in interface net.minecraft.core.Holder<T>
      Returns:
      resource key of the entry.
      See Also:
      • Holder.Reference.unwrapKey()
    • kind

      public net.minecraft.core.Holder.Kind kind()
      Specified by:
      kind in interface net.minecraft.core.Holder<T>
      Returns:
      kind of the entry.
      See Also:
      • Holder.Reference.kind()
    • canSerializeIn

      public abstract boolean canSerializeIn(net.minecraft.core.HolderOwner<T> owner)
      Specified by:
      canSerializeIn in interface net.minecraft.core.Holder<T>
      Parameters:
      owner - owner of the entry
      Returns:
      true if the entry can be serialized in the owner.
      See Also:
      • Holder.Reference.canSerializeIn(net.minecraft.core.HolderOwner<T>)
    • value

      public abstract T value()
      Specified by:
      value in interface net.minecraft.core.Holder<T>
      Returns:
      value of the entry.
      See Also:
      • Holder.value()
    • get

      public T get()
      Specified by:
      get in interface Supplier<T>
      Returns:
      value of the entry.
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      Parameters:
      obj - another object
      Returns:
      true if the object is equal to this object.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      hash code of the entry.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      string representation of the entry.
    • asHolder

      public abstract net.minecraft.core.Holder<T> asHolder()
      Get the vanilla holder of the entry.
      Returns:
      vanilla holder of the entry.
    • asOptional

      public Optional<T> asOptional()
      Returns:
      optional of the entry. null if the entry is not bound.
    • id

      public net.minecraft.resources.ResourceLocation id()
      Get the id of the entry.
      Returns:
      id of the entry.
    • key

      public net.minecraft.resources.ResourceKey<T> key()
      Get the key of the entry.
      Returns:
      key of the entry.
    • equals

      public static boolean equals(net.minecraft.core.Holder<?> a, net.minecraft.core.Holder<?> b)
      Compare two holders.
      Parameters:
      a - first holder
      b - second holder
      Returns:
      true if the holders are equal. false otherwise.
    • hashCode

      public static int hashCode(net.minecraft.core.Holder<?> holder)
      Get the hash code of the holder.
      Parameters:
      holder - to get the hash code
      Returns:
      hash code of the holder.
    • compare

      public static <T> int compare(net.minecraft.core.Holder<T> a, net.minecraft.core.Holder<T> b)
      Compare two holders.
      Type Parameters:
      T - the type of the entry
      Parameters:
      a - first holder
      b - second holder
      Returns:
      the result of the comparison.
    • newHolderTreeMap

      public static <T, V> Map<net.minecraft.core.Holder<T>,V> newHolderTreeMap()
      Create a tree map with the comparator. Users should use this instead of Maps.newIdentityHashMap().
      Type Parameters:
      T - the type of the entry
      V - the type of the value
      Returns:
      a tree map with the comparator.
    • newHolderTreeSet

      public static <T> Set<net.minecraft.core.Holder<T>> newHolderTreeSet()
      Create a tree set with the comparator. Users should use this instead of Sets.newIdentityHashSet().
      Type Parameters:
      T - the type of the entry
      Returns:
      a tree set with the comparator.
    • newHolderObject2IntTreeMap

      public static <T> it.unimi.dsi.fastutil.objects.Object2IntMap<net.minecraft.core.Holder<T>> newHolderObject2IntTreeMap()
      Create a tree map with the comparator. Users should use this instead of Maps.newIdentityHashMap().
      Type Parameters:
      T - the type of the entry
      Returns:
      a tree map with the comparator.