Package net.darkhax.bookshelf.api.util
Interface IInventoryHelper
public interface IInventoryHelper
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidapplyForEach(net.minecraft.world.Container inventory, BiConsumer<Integer, net.minecraft.world.item.ItemStack> action) Applies an action to every item within the inventory.default voidapplyForEach(net.minecraft.world.Container inventory, Consumer<net.minecraft.world.item.ItemStack> action) Applies an action to every item within the inventory.default booleancanItemsStack(net.minecraft.world.item.ItemStack original, net.minecraft.world.item.ItemStack toStack) Checks if two ItemStack may be stacked together.default net.minecraft.world.item.ItemStackdamageStack(net.minecraft.world.item.ItemStack stack, int amount, net.minecraft.world.entity.LivingEntity owner, net.minecraft.world.entity.EquipmentSlot slot) Damages an ItemStack by a set amount.default voidfill(net.minecraft.world.Container inventory, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> fillWith) Fills an inventory with a list of ItemStack.default net.minecraft.world.inventory.AbstractContainerMenugetCraftingContainer(net.minecraft.world.inventory.CraftingContainer container) Gets the internal menu context that is backing a crafting container.default net.minecraft.world.entity.player.PlayergetCraftingPlayer(net.minecraft.world.Container container) default net.minecraft.world.item.ItemStackgetCraftingRemainder(net.minecraft.world.item.ItemStack stack) default IInventoryAccessgetInventory(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction direction) Attempts to provide access to an inventory stored at the given position.default booleanhasCraftingRemainder(net.minecraft.world.item.ItemStack stack) booleanisFakePlayer(net.minecraft.world.entity.player.Player player) default booleanisUnbreakableItem(net.minecraft.world.item.ItemStack stack) default net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>keepDamageableItems(net.minecraft.world.inventory.CraftingContainer inv, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> keptItems, int damageAmount) default voidopenMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider) default voidopenMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider, Consumer<net.minecraft.network.FriendlyByteBuf> buf) voidopenMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider, Consumer<net.minecraft.network.FriendlyByteBuf> buf, boolean allowFakes) default net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>toList(net.minecraft.world.Container inventory) Creates a list view of a Container's inventory contents.
-
Method Details
-
getCraftingContainer
@Nullable default net.minecraft.world.inventory.AbstractContainerMenu getCraftingContainer(net.minecraft.world.inventory.CraftingContainer container) Gets the internal menu context that is backing a crafting container.- Parameters:
container- The crafting container to retrieve internal menu context from.- Returns:
- The internal menu, or null if the menu could not be found.
-
getCraftingPlayer
@Nullable default net.minecraft.world.entity.player.Player getCraftingPlayer(net.minecraft.world.Container container) -
damageStack
default net.minecraft.world.item.ItemStack damageStack(net.minecraft.world.item.ItemStack stack, int amount, @Nullable net.minecraft.world.entity.LivingEntity owner, @Nullable net.minecraft.world.entity.EquipmentSlot slot) Damages an ItemStack by a set amount.ItemStacks with the Unbreakable tag are treated as immune to stack damage as per Minecraft's base spec.
ItemStacks with the unbreaking enchantment will have a chance of ignoring the damage.
ItemStacks that do not have durability will not be modified.
Players in Creative Mode can not damage ItemStacks.
- Parameters:
stack- The ItemStack to damage.amount- The amount of damage to apply to the item.owner- The entity that owns the ItemStack. This is optional but will be used for certain events.slot- The slot the ItemStack is in. This is optional and used for the item break animation.
-
isUnbreakableItem
default boolean isUnbreakableItem(net.minecraft.world.item.ItemStack stack) -
keepDamageableItems
default net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> keepDamageableItems(net.minecraft.world.inventory.CraftingContainer inv, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> keptItems, int damageAmount) -
toList
default net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> toList(net.minecraft.world.Container inventory) Creates a list view of a Container's inventory contents.- Parameters:
inventory- The container to view.- Returns:
- A list view of the provided containers inventory contents.
-
fill
default void fill(net.minecraft.world.Container inventory, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> fillWith) Fills an inventory with a list of ItemStack. The inventory size and container size must be identical.- Parameters:
inventory- The inventory to fill.fillWith- The items to fill the inventory with.
-
applyForEach
default void applyForEach(net.minecraft.world.Container inventory, Consumer<net.minecraft.world.item.ItemStack> action) Applies an action to every item within the inventory.- Parameters:
inventory- The inventory container.action- The action to apply.
-
applyForEach
default void applyForEach(net.minecraft.world.Container inventory, BiConsumer<Integer, net.minecraft.world.item.ItemStack> action) Applies an action to every item within the inventory.- Parameters:
inventory- The inventory container.action- The action to apply.
-
canItemsStack
default boolean canItemsStack(net.minecraft.world.item.ItemStack original, net.minecraft.world.item.ItemStack toStack) Checks if two ItemStack may be stacked together.- Parameters:
original- The original stack.toStack- The stack attempting to be stacked into the original.- Returns:
- Can the two stacks be stacked together.
-
getInventory
@Nullable default IInventoryAccess getInventory(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction direction) Attempts to provide access to an inventory stored at the given position.- Parameters:
level- The world to query.pos- The position to look at.direction- The side of the inventory being accessed.- Returns:
- Access to the inventory at the given position.
-
openMenu
default void openMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider) -
openMenu
default void openMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider, Consumer<net.minecraft.network.FriendlyByteBuf> buf) -
openMenu
void openMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider, Consumer<net.minecraft.network.FriendlyByteBuf> buf, boolean allowFakes) -
getCraftingRemainder
default net.minecraft.world.item.ItemStack getCraftingRemainder(net.minecraft.world.item.ItemStack stack) -
hasCraftingRemainder
default boolean hasCraftingRemainder(net.minecraft.world.item.ItemStack stack) -
isFakePlayer
boolean isFakePlayer(net.minecraft.world.entity.player.Player player)
-