Package appeng.api.stacks
Class AEItemKey
java.lang.Object
appeng.api.stacks.AEKey
appeng.api.stacks.AEItemKey
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<AEItemKey> static final com.mojang.serialization.MapCodec<AEItemKey> We currently cannot directly useItemStack.SINGLE_ITEM_CODECsince 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.Fields inherited from class appeng.api.stacks.AEKey
OPTIONAL_STREAM_CODEC, STREAM_CODEC, TYPE_FIELD -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDrops(long amount, List<net.minecraft.world.item.ItemStack> drops, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) Adds the drops if the container holding this key is broken, such as an interface holding stacks.protected net.minecraft.network.chat.ComponentCompute the display name, which is used to sort by name in client terminal.booleanstatic AEKeyFilterfilter()static AEItemKeyfromPacket(net.minecraft.network.RegistryFriendlyByteBuf data) static @Nullable AEItemKeyfromTag(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.nbt.CompoundTag tag) <T> Tget(net.minecraft.core.component.DataComponentType<T> type) Get a data component attached to this key.intintnet.minecraft.resources.ResourceLocationgetId()net.minecraft.world.item.ItemgetItem()intnet.minecraft.world.item.ItemStackgetType()booleaninthashCode()static booleanbooleanis(net.minecraft.world.level.ItemLike item) booleanbooleanisTagged(net.minecraft.tags.TagKey<?> tag) If the underlying resource supports tagging, this method checks if the resource represented by this key is tagged by the given tag.static booleanbooleanmatches(net.minecraft.world.item.crafting.Ingredient ingredient) booleanmatches(net.minecraft.world.item.ItemStack stack) static @Nullable AEItemKeyof(net.minecraft.world.item.ItemStack stack) static AEItemKeyof(net.minecraft.world.level.ItemLike item) net.minecraft.world.item.ItemStacktoStack()net.minecraft.world.item.ItemStacktoStack(int count) toString()net.minecraft.nbt.CompoundTagtoTag(net.minecraft.core.HolderLookup.Provider registries) 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.net.minecraft.world.item.ItemStackWraps a key in an ItemStack that can be unwrapped into a key later.voidwriteToPacket(net.minecraft.network.RegistryFriendlyByteBuf data) Methods inherited from class appeng.api.stacks.AEKey
formatAmount, fromTagGeneric, fuzzyEquals, getAmountPerByte, getAmountPerOperation, getAmountPerUnit, getDisplayName, getModId, getUnitSymbol, matches, readKey, readOptionalKey, supportsFuzzyRangeSearch, toTagGeneric, writeKey, writeOptionalKey
-
Field Details
-
MAP_CODEC
We currently cannot directly useItemStack.SINGLE_ITEM_CODECsince 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
-
-
Method Details
-
of
-
matches
-
is
-
filter
-
getType
-
dropSecondary
- Specified by:
dropSecondaryin classAEKey- Returns:
- This object if it has no secondary component, otherwise a copy of this resource key with the secondary component removed.
-
equals
-
hashCode
public int hashCode() -
of
-
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:AEKeySerialized 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. -
getPrimaryKey
- Specified by:
getPrimaryKeyin classAEKey
-
getFuzzySearchValue
public int getFuzzySearchValue()- Overrides:
getFuzzySearchValuein classAEKey- 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:
-
getFuzzySearchMaxValue
public int getFuzzySearchMaxValue()- Overrides:
getFuzzySearchMaxValuein classAEKey- 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:
-
getId
public net.minecraft.resources.ResourceLocation getId() -
wrapForDisplayOrFilter
public net.minecraft.world.item.ItemStack wrapForDisplayOrFilter()Description copied from class:AEKeyWraps a key in an ItemStack that can be unwrapped into a key later.- Overrides:
wrapForDisplayOrFilterin classAEKey
-
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:AEKeyAdds 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 -
computeDisplayName
protected net.minecraft.network.chat.Component computeDisplayName()Description copied from class:AEKeyCompute the display name, which is used to sort by name in client terminal. Will be cached byAEKey.getDisplayName().- Specified by:
computeDisplayNamein classAEKey
-
isTagged
public boolean isTagged(net.minecraft.tags.TagKey<?> tag) Description copied from class:AEKeyIf the underlying resource supports tagging, this method checks if the resource represented by this key is tagged by the given tag. -
get
@Nullable public <T> T get(net.minecraft.core.component.DataComponentType<T> type) Description copied from class:AEKeyGet a data component attached to this key. It might be null. -
hasComponents
public boolean hasComponents()- Specified by:
hasComponentsin classAEKey- 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:
writeToPacketin classAEKey
-
fromPacket
-
toString
-