Class Inventories
Inventory
implementations or for working
with inventories.- Mappings:
Namespace Name named net/minecraft/inventory/Inventories
intermediary net/minecraft/class_1262
official bxd
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
readData
(ReadView view, DefaultedList<ItemStack> stacks) Readsnbt
and sets the elements ofstacks
accordingly.static int
Removes a number, not exceedingmaxCount
, of items from an inventory based on a predicate and returns that number.static int
Removes a number, not exceedingmaxCount
, of items from an item stack based on a predicate and returns that number.static ItemStack
removeStack
(List<ItemStack> stacks, int slot) Sets the stack atslot
toItemStack.EMPTY
and returns the old stack.static ItemStack
splitStack
(List<ItemStack> stacks, int slot, int amount) Returns the copy of the stack split from the stack atslot
.static void
writeData
(WriteView view, DefaultedList<ItemStack> stacks) Writes the inventory tonbt
.static void
writeData
(WriteView view, DefaultedList<ItemStack> stacks, boolean setIfEmpty) Writes the inventory tonbt
.
-
Field Details
-
ITEMS_NBT_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector named ITEMS_NBT_KEY
Lnet/minecraft/inventory/Inventories;ITEMS_NBT_KEY:Ljava/lang/String;
intermediary field_49719
Lnet/minecraft/class_1262;field_49719:Ljava/lang/String;
official a
Lbxd;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.EMPTY
whenslot
is 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 splitStack
Lnet/minecraft/inventory/Inventories;splitStack(Ljava/util/List;II)Lnet/minecraft/item/ItemStack;
intermediary method_5430
Lnet/minecraft/class_1262;method_5430(Ljava/util/List;II)Lnet/minecraft/class_1799;
official a
Lbxd;a(Ljava/util/List;II)Ldcv;
-
removeStack
Sets the stack atslot
toItemStack.EMPTY
and returns the old stack.This returns
ItemStack.EMPTY
whenslot
is 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 removeStack
Lnet/minecraft/inventory/Inventories;removeStack(Ljava/util/List;I)Lnet/minecraft/item/ItemStack;
intermediary method_5428
Lnet/minecraft/class_1262;method_5428(Ljava/util/List;I)Lnet/minecraft/class_1799;
official a
Lbxd;a(Ljava/util/List;I)Ldcv;
-
writeData
Writes the inventory tonbt
. This method will always write to the NBT, even ifstacks
only contains empty stacks.See
invalid reference
#writeNbt(NbtCompound, DefaultedList, boolean, RegistryWrapper.WrapperLookup)
- See Also:
- Mappings:
Namespace Name Mixin selector named writeData
Lnet/minecraft/inventory/Inventories;writeData(Lnet/minecraft/storage/WriteView;Lnet/minecraft/util/collection/DefaultedList;)V
intermediary method_5426
Lnet/minecraft/class_1262;method_5426(Lnet/minecraft/class_11372;Lnet/minecraft/class_2371;)V
official a
Lbxd;a(Lfdc;Lju;)V
-
writeData
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 tonbt
under the keyItems
.If
setIfEmpty
isfalse
and each stack instacks
is empty, thennbt
will not be modified at all. Otherwise, theItems
entry will always be present.- See Also:
- Mappings:
Namespace Name Mixin selector named writeData
Lnet/minecraft/inventory/Inventories;writeData(Lnet/minecraft/storage/WriteView;Lnet/minecraft/util/collection/DefaultedList;Z)V
intermediary method_5427
Lnet/minecraft/class_1262;method_5427(Lnet/minecraft/class_11372;Lnet/minecraft/class_2371;Z)V
official a
Lbxd;a(Lfdc;Lju;Z)V
-
readData
Readsnbt
and sets the elements ofstacks
accordingly.See
invalid reference
#writeNbt(NbtCompound, DefaultedList, boolean, RegistryWrapper.WrapperLookup)
- See Also:
- Mappings:
Namespace Name Mixin selector named readData
Lnet/minecraft/inventory/Inventories;readData(Lnet/minecraft/storage/ReadView;Lnet/minecraft/util/collection/DefaultedList;)V
intermediary method_5429
Lnet/minecraft/class_1262;method_5429(Lnet/minecraft/class_11368;Lnet/minecraft/class_2371;)V
official a
Lbxd;a(Lfda;Lju;)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 remove
Lnet/minecraft/inventory/Inventories;remove(Lnet/minecraft/inventory/Inventory;Ljava/util/function/Predicate;IZ)I
intermediary method_29234
Lnet/minecraft/class_1262;method_29234(Lnet/minecraft/class_1263;Ljava/util/function/Predicate;IZ)I
official a
Lbxd;a(Lbxc;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 remove
Lnet/minecraft/inventory/Inventories;remove(Lnet/minecraft/item/ItemStack;Ljava/util/function/Predicate;IZ)I
intermediary method_29235
Lnet/minecraft/class_1262;method_29235(Lnet/minecraft/class_1799;Ljava/util/function/Predicate;IZ)I
official a
Lbxd;a(Ldcv;Ljava/util/function/Predicate;IZ)I
-