Class AEItemKey

java.lang.Object
appeng.api.stacks.AEKey
appeng.api.stacks.AEItemKey

public final class AEItemKey extends AEKey
  • Field Details

    • MAP_CODEC

      public static final com.mojang.serialization.MapCodec<AEItemKey> MAP_CODEC
      We currently cannot directly use ItemStack.SINGLE_ITEM_CODEC since it is wrapped up in a lazy codec, which prevents the dispatch codec from recognizing it as a MapCodec, making it unable to inline the fields.
    • CODEC

      public static final com.mojang.serialization.Codec<AEItemKey> CODEC
  • Method Details

    • of

      @Nullable public static @Nullable AEItemKey of(net.minecraft.world.item.ItemStack stack)
    • matches

      public static boolean matches(AEKey what, net.minecraft.world.item.ItemStack itemStack)
    • is

      public static boolean is(AEKey what)
    • filter

      public static AEKeyFilter filter()
    • getType

      public AEKeyType getType()
      Specified by:
      getType in class AEKey
      Returns:
      An object giving additional properties about the type of key.
    • dropSecondary

      public AEItemKey dropSecondary()
      Specified by:
      dropSecondary in class AEKey
      Returns:
      This object if it has no secondary component, otherwise a copy of this resource key with the secondary component removed.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • of

      public static AEItemKey of(net.minecraft.world.level.ItemLike item)
    • is

      public boolean is(net.minecraft.world.level.ItemLike item)
    • matches

      public boolean matches(net.minecraft.world.item.ItemStack stack)
    • matches

      public boolean matches(net.minecraft.world.item.crafting.Ingredient ingredient)
    • getReadOnlyStack

      public net.minecraft.world.item.ItemStack getReadOnlyStack()
      Returns:
      The ItemStack represented by this key. NEVER MUTATE THIS
    • toStack

      public net.minecraft.world.item.ItemStack toStack()
    • toStack

      public net.minecraft.world.item.ItemStack toStack(int count)
    • getItem

      public net.minecraft.world.item.Item getItem()
    • fromTag

      @Nullable public static @Nullable AEItemKey fromTag(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.nbt.CompoundTag tag)
    • toTag

      public net.minecraft.nbt.CompoundTag toTag(net.minecraft.core.HolderLookup.Provider registries)
      Description copied from class: AEKey
      Serialized keys MUST NOT contain keys that start with #, because this prefix can be used to add additional data into the same tag as the key.
      Specified by:
      toTag in class AEKey
    • getPrimaryKey

      public Object getPrimaryKey()
      Specified by:
      getPrimaryKey in class AEKey
    • getFuzzySearchValue

      public int getFuzzySearchValue()
      Overrides:
      getFuzzySearchValue in class AEKey
      Returns:
      If AEKey.getFuzzySearchMaxValue() is greater than 0, this is the value in the range of [0,getFuzzyModeMaxValue] used to index keys by. Used by fuzzy mode search with percentage ranges.
      See Also:
      • ItemStack.getMaxDamage()
    • getFuzzySearchMaxValue

      public int getFuzzySearchMaxValue()
      Overrides:
      getFuzzySearchMaxValue in class AEKey
      Returns:
      The upper bound for values returned by AEKey.getFuzzySearchValue(). If it is equal to 0, no fuzzy range-search is possible for this type of key.
      See Also:
      • ItemStack.getDamageValue()
    • getId

      public net.minecraft.resources.ResourceLocation getId()
      Specified by:
      getId in class AEKey
      Returns:
      The ID of the resource identified by this key.
    • wrapForDisplayOrFilter

      public net.minecraft.world.item.ItemStack wrapForDisplayOrFilter()
      Description copied from class: AEKey
      Wraps a key in an ItemStack that can be unwrapped into a key later.
      Overrides:
      wrapForDisplayOrFilter in class AEKey
    • addDrops

      public void addDrops(long amount, List<net.minecraft.world.item.ItemStack> drops, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Description copied from class: AEKey
      Adds the drops if the container holding this key is broken, such as an interface holding stacks. Item stacks should be placed in the list and not spawned directly into the world
      Specified by:
      addDrops in class AEKey
      Parameters:
      amount - Amount to drop
      drops - Drop list to append to, in case of ItemStack drops
      level - World where the stacks were being held
      pos - Position where the stacks were being held
    • computeDisplayName

      protected net.minecraft.network.chat.Component computeDisplayName()
      Description copied from class: AEKey
      Compute the display name, which is used to sort by name in client terminal. Will be cached by AEKey.getDisplayName().
      Specified by:
      computeDisplayName in class AEKey
    • isTagged

      public boolean isTagged(net.minecraft.tags.TagKey<?> tag)
      Description copied from class: AEKey
      If the underlying resource supports tagging, this method checks if the resource represented by this key is tagged by the given tag.
      Overrides:
      isTagged in class AEKey
    • get

      @Nullable public <T> T get(net.minecraft.core.component.DataComponentType<T> type)
      Description copied from class: AEKey
      Get a data component attached to this key. It might be null.
      Overrides:
      get in class AEKey
    • hasComponents

      public boolean hasComponents()
      Specified by:
      hasComponents in class AEKey
      Returns:
      true if this key has *any* components attached.
    • isDamaged

      public boolean isDamaged()
      Returns:
      True if the item represented by this key is damaged.
    • getMaxStackSize

      public int getMaxStackSize()
    • writeToPacket

      public void writeToPacket(net.minecraft.network.RegistryFriendlyByteBuf data)
      Specified by:
      writeToPacket in class AEKey
    • fromPacket

      public static AEItemKey fromPacket(net.minecraft.network.RegistryFriendlyByteBuf data)
    • toString

      public String toString()
      Overrides:
      toString in class Object