Class AEKeyType

java.lang.Object
appeng.api.stacks.AEKeyType

public abstract class AEKeyType extends Object
Defines the properties of a specific subclass of AEKey. I.e. for AEItemKey, there is AEItemKeys.
  • Field Details

    • REGISTRY_KEY

      public static final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<AEKeyType>> REGISTRY_KEY
    • CODEC

      public static final com.mojang.serialization.Codec<AEKeyType> CODEC
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,AEKeyType> STREAM_CODEC
  • Constructor Details

    • AEKeyType

      public AEKeyType(net.minecraft.resources.ResourceLocation id, Class<? extends AEKey> keyClass, net.minecraft.network.chat.Component description)
  • Method Details

    • codec

      public abstract com.mojang.serialization.MapCodec<? extends AEKey> codec()
      A codec used to encode keys of this type.
    • items

      public static AEKeyType items()
      Returns:
      AE2's key space for AEItemKey.
    • fromRawId

      @Nullable public static @Nullable AEKeyType fromRawId(int id)
      Returns:
      See getRawId()
    • fluids

      public static AEKeyType fluids()
      Returns:
      AE2's key space for AEFluidKey.
    • getId

      public final net.minecraft.resources.ResourceLocation getId()
      Returns:
      The unique ID of this storage channel.
    • getKeyClass

      public final Class<? extends AEKey> getKeyClass()
    • getRawId

      public final byte getRawId()
    • getAmountPerOperation

      public int getAmountPerOperation()
      How much of this key will be transferred as part of a transfer operation. Used to balance item vs. fluids transfers.

      E.g. used by IO Ports to transfer 1000 mB, not 1 mB to match the item channel transferring a full bucket per operation.

    • getAmountPerByte

      public int getAmountPerByte()
      The amount of this key type that can be stored per byte used in a storage cell. Standard value for items is 8, and for fluids it's 8000.
    • readFromPacket

      @Nullable public abstract @Nullable AEKey readFromPacket(net.minecraft.network.RegistryFriendlyByteBuf input)
      Attempts to load a key of this type from the given packet buffer.
    • loadKeyFromTag

      @Nullable public @Nullable AEKey loadKeyFromTag(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.nbt.CompoundTag tag)
      Attempts to load a key of this type from the given tag.
    • tryCast

      @Nullable public final @Nullable AEKey tryCast(AEKey key)
      Does this key belong to this storage channel.
    • contains

      public final boolean contains(AEKey key)
      Returns whether the key is part of this key space.
      Returns:
      whether the key is part of this key space
    • supportsFuzzyRangeSearch

      public boolean supportsFuzzyRangeSearch()
      True to indicate that the AEKey class used by this storage channel supports range-based fuzzy search using AEKey.getFuzzySearchValue() and AEKey.getFuzzySearchMaxValue().

      For items this is used for damage-based search and filtering.

    • filter

      public final AEKeyFilter filter()
      Returns:
      A filter matching all keys of this type.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDescription

      public net.minecraft.network.chat.Component getDescription()
      Get the translated name of this key space.
    • getUnitSymbol

      @Nullable public @Nullable String getUnitSymbol()
      I.e. "B" for Buckets.
    • getAmountPerUnit

      public int getAmountPerUnit()
    • formatAmount

      public final String formatAmount(long amount, AmountFormat format)
      Format the amount into a user-readable string. See AmountFormat for an explanation of the different formats. Includes the unit if applicable.
    • getTagNames

      public Stream<net.minecraft.tags.TagKey<?>> getTagNames()
      Returns all tags that apply to keys of this type. Is an optional operation is keys of this type cannot have tags, and AEKey.isTagged(TagKey) is not implemented for this key type.
      See Also:
      • Registry.getTagNames()