Class Inventories
Inventory implementations or for working
with inventories.- Mappings:
Namespace Name named net/minecraft/inventory/Inventoriesintermediary net/minecraft/class_1262official bql
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidreadNbt(NbtCompound nbt, DefaultedList<ItemStack> stacks, RegistryWrapper.WrapperLookup registries) Readsnbtand sets the elements ofstacksaccordingly.static intRemoves a number, not exceedingmaxCount, of items from an inventory based on a predicate and returns that number.static intRemoves a number, not exceedingmaxCount, of items from an item stack based on a predicate and returns that number.static ItemStackremoveStack(List<ItemStack> stacks, int slot) Sets the stack atslottoItemStack.EMPTYand returns the old stack.static ItemStacksplitStack(List<ItemStack> stacks, int slot, int amount) Returns the copy of the stack split from the stack atslot.static NbtCompoundwriteNbt(NbtCompound nbt, DefaultedList<ItemStack> stacks, boolean setIfEmpty, RegistryWrapper.WrapperLookup registries) Writes the inventory tonbt.static NbtCompoundwriteNbt(NbtCompound nbt, DefaultedList<ItemStack> stacks, RegistryWrapper.WrapperLookup registries) Writes the inventory tonbt.
-
Field Details
-
ITEMS_NBT_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector named ITEMS_NBT_KEYLnet/minecraft/inventory/Inventories;ITEMS_NBT_KEY:Ljava/lang/String;intermediary field_49719Lnet/minecraft/class_1262;field_49719:Ljava/lang/String;official aLbql;a:Ljava/lang/String;
-
-
Constructor Details
-
Inventories
public Inventories()
-
-
Method Details
-
splitStack
Returns the copy of the stack split from the stack atslot.This returns
ItemStack.EMPTYwhenslotis out of bounds, the stack at the slot is empty, or whenamount <= 0.- Returns:
- the copy of the stack split from the stack at
slot - See Also:
- API Note:
- This is used to implement
Inventory.removeStack(int, int). This should not otherwise be used directly. - Mappings:
Namespace Name Mixin selector named splitStackLnet/minecraft/inventory/Inventories;splitStack(Ljava/util/List;II)Lnet/minecraft/item/ItemStack;intermediary method_5430Lnet/minecraft/class_1262;method_5430(Ljava/util/List;II)Lnet/minecraft/class_1799;official aLbql;a(Ljava/util/List;II)Lcuq;
-
removeStack
Sets the stack atslottoItemStack.EMPTYand returns the old stack.This returns
ItemStack.EMPTYwhenslotis out of bounds.- Returns:
- the stack previously at
slot - API Note:
- This is used to implement
Inventory.removeStack(int). This should not otherwise be used directly. - Mappings:
Namespace Name Mixin selector named removeStackLnet/minecraft/inventory/Inventories;removeStack(Ljava/util/List;I)Lnet/minecraft/item/ItemStack;intermediary method_5428Lnet/minecraft/class_1262;method_5428(Ljava/util/List;I)Lnet/minecraft/class_1799;official aLbql;a(Ljava/util/List;I)Lcuq;
-
writeNbt
public static NbtCompound writeNbt(NbtCompound nbt, DefaultedList<ItemStack> stacks, RegistryWrapper.WrapperLookup registries) Writes the inventory tonbt. This method will always write to the NBT, even ifstacksonly contains empty stacks.See
writeNbt(NbtCompound, DefaultedList, boolean, RegistryWrapper.WrapperLookup)for the serialization format.- Returns:
- the passed
nbt - See Also:
- Mappings:
Namespace Name Mixin selector named writeNbtLnet/minecraft/inventory/Inventories;writeNbt(Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/util/collection/DefaultedList;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Lnet/minecraft/nbt/NbtCompound;intermediary method_5426Lnet/minecraft/class_1262;method_5426(Lnet/minecraft/class_2487;Lnet/minecraft/class_2371;Lnet/minecraft/class_7225$class_7874;)Lnet/minecraft/class_2487;official aLbql;a(Lub;Ljv;Ljo$a;)Lub;
-
writeNbt
public static NbtCompound writeNbt(NbtCompound nbt, DefaultedList<ItemStack> stacks, boolean setIfEmpty, RegistryWrapper.WrapperLookup registries) Writes the inventory tonbt.The inventory is serialized as a list of non-empty item stacks. In addition, each compound has a byte entry with the key
Slot, indicating the slot. The list is then written tonbtunder the keyItems.If
setIfEmptyisfalseand each stack instacksis empty, thennbtwill not be modified at all. Otherwise, theItemsentry will always be present.- Returns:
- the passed
nbt - See Also:
- Mappings:
Namespace Name Mixin selector named writeNbtLnet/minecraft/inventory/Inventories;writeNbt(Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/util/collection/DefaultedList;ZLnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Lnet/minecraft/nbt/NbtCompound;intermediary method_5427Lnet/minecraft/class_1262;method_5427(Lnet/minecraft/class_2487;Lnet/minecraft/class_2371;ZLnet/minecraft/class_7225$class_7874;)Lnet/minecraft/class_2487;official aLbql;a(Lub;Ljv;ZLjo$a;)Lub;
-
readNbt
public static void readNbt(NbtCompound nbt, DefaultedList<ItemStack> stacks, RegistryWrapper.WrapperLookup registries) Readsnbtand sets the elements ofstacksaccordingly.See
writeNbt(NbtCompound, DefaultedList, boolean, RegistryWrapper.WrapperLookup)for the serialization format. If the slot is out of bounds, it is ignored.- See Also:
- Mappings:
Namespace Name Mixin selector named readNbtLnet/minecraft/inventory/Inventories;readNbt(Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/util/collection/DefaultedList;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Vintermediary method_5429Lnet/minecraft/class_1262;method_5429(Lnet/minecraft/class_2487;Lnet/minecraft/class_2371;Lnet/minecraft/class_7225$class_7874;)Vofficial bLbql;b(Lub;Ljv;Ljo$a;)V
-
remove
public static int remove(Inventory inventory, Predicate<ItemStack> shouldRemove, int maxCount, boolean dryRun) Removes a number, not exceedingmaxCount, of items from an inventory based on a predicate and returns that number.- Parameters:
dryRun- whether to return the number of items which would have been removed without actually removing them- Returns:
- the number of items removed
- Mappings:
Namespace Name Mixin selector named removeLnet/minecraft/inventory/Inventories;remove(Lnet/minecraft/inventory/Inventory;Ljava/util/function/Predicate;IZ)Iintermediary method_29234Lnet/minecraft/class_1262;method_29234(Lnet/minecraft/class_1263;Ljava/util/function/Predicate;IZ)Iofficial aLbql;a(Lbqk;Ljava/util/function/Predicate;IZ)I
-
remove
public static int remove(ItemStack stack, Predicate<ItemStack> shouldRemove, int maxCount, boolean dryRun) Removes a number, not exceedingmaxCount, of items from an item stack based on a predicate and returns that number.- Parameters:
dryRun- whether to return the number of items which would have been removed without actually removing them- Returns:
- the number of items removed
- Mappings:
Namespace Name Mixin selector named removeLnet/minecraft/inventory/Inventories;remove(Lnet/minecraft/item/ItemStack;Ljava/util/function/Predicate;IZ)Iintermediary method_29235Lnet/minecraft/class_1262;method_29235(Lnet/minecraft/class_1799;Ljava/util/function/Predicate;IZ)Iofficial aLbql;a(Lcuq;Ljava/util/function/Predicate;IZ)I
-