2019-06-28 17:55:20 -04:00
|
|
|
CLASS net/minecraft/class_1263 net/minecraft/inventory/Inventory
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT A container of {@link ItemStack}s. In general, when a player stores an item stack
|
|
|
|
COMMENT and can retrieve the same item stack back, that stack is stored in an
|
|
|
|
COMMENT inventory. The inventory can be persistent, like chests or donkeys, or it can
|
|
|
|
COMMENT be created without backing storage, like the slots in crafting tables.
|
|
|
|
COMMENT It is the responsibility of the user to sync or save the contents of the
|
|
|
|
COMMENT inventory.
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>Entities and block entities that can hold item stacks generally
|
|
|
|
COMMENT implement this interface themselves, allowing hopper interactions. Call {@link
|
|
|
|
COMMENT net.minecraft.entity.player.PlayerEntity#getInventory} to get the player's
|
|
|
|
COMMENT inventory (including armors and offhand).
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>An inventory has a fixed size, and each element in the inventory is identified
|
|
|
|
COMMENT by the slot number, which is between zero and {@code size() - 1} like arrays.
|
|
|
|
COMMENT When a slot of the inventory is empty, it should be filled with {@link
|
|
|
|
COMMENT ItemStack#EMPTY}.
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>An implementation of this interface should have a field of {@link
|
|
|
|
COMMENT net.minecraft.util.collection.DefaultedList#ofSize(int, Object)} with the second
|
|
|
|
COMMENT argument as {@link ItemStack#EMPTY}, and implement methods by delegating to the
|
|
|
|
COMMENT list. The list itself should not be modified directly, and the list's size
|
|
|
|
COMMENT should remain constant throughout the lifetime of the inventory.
|
|
|
|
COMMENT Implementations must call {@link #markDirty} when the inventory is modified.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @apiNote If an inventory is needed for temporary storage, use {@link
|
|
|
|
COMMENT SimpleInventory}. For persistent storage in entities or block entities,
|
|
|
|
COMMENT use {@link net.minecraft.entity.vehicle.VehicleInventory} or
|
|
|
|
COMMENT {@link net.minecraft.block.entity.LockableContainerBlockEntity}.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @see net.minecraft.entity.vehicle.VehicleInventory
|
|
|
|
COMMENT @see net.minecraft.block.entity.LockableContainerBlockEntity
|
2021-04-02 08:01:06 -04:00
|
|
|
FIELD field_29952 MAX_COUNT_PER_STACK I
|
2024-01-18 10:07:47 -05:00
|
|
|
FIELD field_48319 DEFAULT_MAX_INTERACTION_RANGE F
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_18861 count (Lnet/minecraft/class_1792;)I
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return the number of times {@code item} occurs in this inventory
|
|
|
|
COMMENT across all stored stacks}
|
2019-05-05 18:31:29 -04:00
|
|
|
ARG 1 item
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_18862 containsAny (Ljava/util/Set;)Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether this inventory contains any of {@code items}}
|
|
|
|
COMMENT
|
|
|
|
COMMENT @see #containsAny(Predicate)
|
2019-05-05 18:31:29 -04:00
|
|
|
ARG 1 items
|
2022-04-19 06:06:11 -04:00
|
|
|
METHOD method_43255 (Ljava/util/Set;Lnet/minecraft/class_1799;)Z
|
|
|
|
ARG 1 stack
|
|
|
|
METHOD method_43256 containsAny (Ljava/util/function/Predicate;)Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether this inventory contains any of the stacks matching {@code
|
|
|
|
COMMENT predicate}}
|
|
|
|
COMMENT
|
|
|
|
COMMENT @see #containsAny(Set)
|
2022-04-19 06:06:11 -04:00
|
|
|
ARG 1 predicate
|
2023-02-17 02:09:31 -05:00
|
|
|
METHOD method_49104 canTransferTo (Lnet/minecraft/class_1263;ILnet/minecraft/class_1799;)Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether a hopper can transfer {@code stack} from {@code slot} to
|
|
|
|
COMMENT the hopper}
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>This returns {@code true} by default.
|
2023-02-17 02:09:31 -05:00
|
|
|
ARG 1 hopperInventory
|
|
|
|
ARG 2 slot
|
|
|
|
ARG 3 stack
|
2023-02-16 07:22:27 -05:00
|
|
|
METHOD method_49105 canPlayerUse (Lnet/minecraft/class_2586;Lnet/minecraft/class_1657;)Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether {@code player} can use this {@code blockEntity}}
|
|
|
|
COMMENT
|
|
|
|
COMMENT @apiNote This is used by block entities to implement {@link
|
|
|
|
COMMENT #canPlayerUse(PlayerEntity)}.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @implNote This method checks whether the given block entity exists and whether
|
|
|
|
COMMENT the player is within 8 blocks of the block entity.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @see #canPlayerUse(BlockEntity, PlayerEntity, int)
|
2023-02-16 07:22:27 -05:00
|
|
|
ARG 0 blockEntity
|
|
|
|
ARG 1 player
|
2024-01-17 11:52:02 -05:00
|
|
|
METHOD method_49106 canPlayerUse (Lnet/minecraft/class_2586;Lnet/minecraft/class_1657;F)Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether {@code player} can use this {@code blockEntity}}
|
|
|
|
COMMENT
|
|
|
|
COMMENT @apiNote This is used by block entities to implement {@link
|
|
|
|
COMMENT #canPlayerUse(PlayerEntity)}.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @implNote This method checks whether the given block entity exists and whether
|
|
|
|
COMMENT the player is within {@code range} blocks of the block entity.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @see #canPlayerUse(BlockEntity, PlayerEntity)
|
2023-02-16 07:22:27 -05:00
|
|
|
ARG 0 blockEntity
|
|
|
|
ARG 1 player
|
2024-01-17 21:27:51 -05:00
|
|
|
ARG 2 range
|
2019-06-28 17:55:20 -04:00
|
|
|
METHOD method_5431 markDirty ()V
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT Marks the inventory as modified. Implementations should call this method
|
|
|
|
COMMENT every time the inventory is changed in any way.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @apiNote Implementations should mark the inventory for synchronization or
|
|
|
|
COMMENT saving in this method. Since this is called frequently, it is not recommended to
|
|
|
|
COMMENT synchronize or save the inventory directly in this method. If this inventory is
|
|
|
|
COMMENT implemented in a block entity, then it should <strong>always</strong> call
|
|
|
|
COMMENT {@code super.markDirty();} to ensure the block entity gets saved.
|
|
|
|
COMMENT
|
2023-09-02 09:09:42 -04:00
|
|
|
COMMENT @see net.minecraft.block.entity.BlockEntity#markDirty
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5432 onClose (Lnet/minecraft/class_1657;)V
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT Called when the inventory is closed. Specifically, this is called inside
|
|
|
|
COMMENT {@link net.minecraft.screen.ScreenHandler#onClosed}. This does nothing
|
|
|
|
COMMENT by default.
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>The method is called in both the client and the server. However, because
|
|
|
|
COMMENT clientside screen handler is created with a {@link SimpleInventory},
|
|
|
|
COMMENT other implementations can (and the vanilla code does) assume that the method is called
|
|
|
|
COMMENT in the server.
|
2019-05-05 18:31:29 -04:00
|
|
|
ARG 1 player
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5434 removeStack (II)Lnet/minecraft/class_1799;
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT Removes a specific number of items from {@code slot}.
|
2020-03-27 14:04:46 -04:00
|
|
|
COMMENT
|
|
|
|
COMMENT @return the removed items as a stack
|
2019-01-11 19:30:17 -05:00
|
|
|
ARG 1 slot
|
2019-06-28 17:55:20 -04:00
|
|
|
ARG 2 amount
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5435 onOpen (Lnet/minecraft/class_1657;)V
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT Called when the inventory is opened. Specifically, this is called inside the
|
|
|
|
COMMENT {@link net.minecraft.screen.ScreenHandler} constructor. This does nothing
|
|
|
|
COMMENT by default.
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>The method is called in both the client and the server. However, because
|
|
|
|
COMMENT clientside screen handler is created with a {@link SimpleInventory},
|
|
|
|
COMMENT other implementations can (and the vanilla code does) assume that the method is called
|
|
|
|
COMMENT in the server.
|
2019-06-28 17:55:20 -04:00
|
|
|
ARG 1 player
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5437 isValid (ILnet/minecraft/class_1799;)Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether {@code stack} is valid for the {@code slot}}
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>Implementations can, for example, use this to check whether the item
|
|
|
|
COMMENT is in a specific tag. This returns {@code true} by default.
|
2018-11-04 07:22:38 -05:00
|
|
|
ARG 1 slot
|
2019-05-05 18:31:29 -04:00
|
|
|
ARG 2 stack
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5438 getStack (I)Lnet/minecraft/class_1799;
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return the stack currently stored at {@code slot}}
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>If the slot is empty, or is outside the bounds of this inventory,
|
|
|
|
COMMENT this returns {@link ItemStack#EMPTY}.
|
2019-06-28 17:55:20 -04:00
|
|
|
ARG 1 slot
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5439 size ()I
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return the size of the inventory}
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>The inventory should support the slot ID from {@code 0} to {@code size() - 1}.
|
|
|
|
COMMENT This should remain constant throughout the inventory's lifetime.
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5441 removeStack (I)Lnet/minecraft/class_1799;
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT Removes the stack currently stored at {@code slot}.
|
2020-03-27 14:04:46 -04:00
|
|
|
COMMENT
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT @return the stack previously stored at the indicated slot
|
2019-06-28 17:55:20 -04:00
|
|
|
ARG 1 slot
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5442 isEmpty ()Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether the inventory consists entirely of {@linkplain ItemStack#isEmpty
|
|
|
|
COMMENT empty item stacks}}
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5443 canPlayerUse (Lnet/minecraft/class_1657;)Z
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return whether {@code player} can use this inventory}
|
|
|
|
COMMENT
|
|
|
|
COMMENT <p>This is called by {@link net.minecraft.screen.ScreenHandler#canUse}.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @apiNote Implementations should check the distance between the inventory
|
|
|
|
COMMENT holder and {@code player}. For convenience, this interface offers two methods
|
|
|
|
COMMENT used by block entities to implement this check.
|
|
|
|
COMMENT
|
|
|
|
COMMENT @see #canPlayerUse(BlockEntity, PlayerEntity)
|
|
|
|
COMMENT @see #canPlayerUse(BlockEntity, PlayerEntity, int)
|
2019-05-05 18:31:29 -04:00
|
|
|
ARG 1 player
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5444 getMaxCountPerStack ()I
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT {@return the maximum {@linkplain ItemStack#getCount number of items} a stack
|
|
|
|
COMMENT can contain when placed inside this inventory}
|
2020-03-27 14:04:46 -04:00
|
|
|
COMMENT
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT <p>No slots may have more than this number of items. It is effectively the
|
|
|
|
COMMENT stacking limit for this inventory's slots.
|
2020-03-27 14:04:46 -04:00
|
|
|
METHOD method_5447 setStack (ILnet/minecraft/class_1799;)V
|
2023-08-24 19:01:48 -04:00
|
|
|
COMMENT Sets the stack stored at {@code slot} to {@code stack}.
|
2019-06-28 17:55:20 -04:00
|
|
|
ARG 1 slot
|
|
|
|
ARG 2 stack
|