Class ExtendedInventory

java.lang.Object
net.minecraft.world.entity.player.Inventory
com.petrolpark.core.extendedinventory.ExtendedInventory
All Implemented Interfaces:
net.minecraft.world.Clearable, net.minecraft.world.Container, net.minecraft.world.Nameable

@Experimental public class ExtendedInventory extends net.minecraft.world.entity.player.Inventory
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
    static interface 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>
     

    Fields inherited from class net.minecraft.world.entity.player.Inventory

    ALL_ARMOR_SLOTS, armor, HELMET_SLOT_ONLY, INVENTORY_SIZE, items, NOT_FOUND_INDEX, offhand, player, POP_TIME_DURATION, selected, SLOT_OFFHAND

    Fields inherited from interface net.minecraft.world.Container

    DEFAULT_DISTANCE_BUFFER
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExtendedInventory(net.minecraft.world.entity.player.Player player)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(int slot, net.minecraft.world.item.ItemStack stack)
    Copied from Minecraft source code
    void
    addExtraInventorySlotsToMenu(Consumer<net.minecraft.world.inventory.Slot> slotAdder, ExtendedInventory.SlotFactory slotFactory, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY)
     
    void
    addExtraInventorySlotsToMenu(net.minecraft.world.inventory.AbstractContainerMenu menu, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY)
     
    void
     
    boolean
    contains(net.minecraft.tags.TagKey<net.minecraft.world.item.Item> tag)
     
    boolean
    contains(net.minecraft.world.item.ItemStack stack)
     
    void
     
    static final boolean
     
    static final boolean
    enabled(net.minecraft.world.flag.FeatureFlagSet flagSet)
     
    void
    fillStackedContents(net.minecraft.world.entity.player.StackedContents stackedContents)
     
    int
    findSlot(Predicate<net.minecraft.world.item.ItemStack> stackPredicate)
    Search for a slot in the vanilla and extended Inventories (i.e.
    int
    findSlotMatchingItem(net.minecraft.world.item.ItemStack stack)
     
    int
    findSlotMatchingUnusedItem(net.minecraft.world.item.ItemStack stack)
     
    void
    forEach(Consumer<? super net.minecraft.world.item.ItemStack> action)
     
    get(net.minecraft.world.entity.player.Player player)
     
    int
     
    float
    getDestroySpeed(net.minecraft.world.level.block.state.BlockState state)
     
    int
    The number of additional hotbar Slots beyond the usual 9.
    int
     
    int
     
    int
    The total hotbar size, vanilla + extra slots
    net.minecraft.world.item.ItemStack
    getItem(int slotIndex)
     
    net.minecraft.world.item.ItemStack
     
    int
    The Slot index of the currently selected Slot
    protected int
    getSlotIndex(int hotbarIndex)
    Get the Slot index of the given index in the displayed hotbar - how far right the selected slot is, considering the sides on which the extra slots are
    int
    getSlotWithRemainingSpace(net.minecraft.world.item.ItemStack stack)
     
    int
     
    boolean
     
    boolean
    isFullHotbarSlot(int index)
    Whether the given slot index is part of the extended hotbar
    static boolean
    Whether the given Slot index corresponds to a vanilla hotbar Slot.
    void
    load(net.minecraft.nbt.ListTag listTag)
     
    static void
    onOpenContainer(net.neoforged.neoforge.event.entity.player.PlayerContainerEvent.Open event)
     
    static void
    onPlayerJoinsWorld(net.neoforged.neoforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent event)
     
    void
    pickSlot(int index)
    Stick an Item from the Inventory in the hotbar
    static void
    refreshPlayerInventoryMenu(net.minecraft.world.entity.player.Player player, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY)
     
    static void
    refreshPlayerInventoryMenuServer(net.minecraft.world.entity.player.Player player)
     
    net.minecraft.world.item.ItemStack
    removeItem(int slotIndex, int count)
     
    void
    removeItem(net.minecraft.world.item.ItemStack stack)
     
    net.minecraft.world.item.ItemStack
    removeItemNoUpdate(int slotIndex)
     
    void
    replaceWith(net.minecraft.world.entity.player.Inventory playerInventory)
     
    net.minecraft.nbt.ListTag
    save(net.minecraft.nbt.ListTag listTag)
     
    void
    setExtraHotbarSlots(int extraSlots)
     
    void
     
    void
    setItem(int slotIndex, net.minecraft.world.item.ItemStack stack)
     
    void
    setPickedItem(net.minecraft.world.item.ItemStack stack)
    Pick an Item in Creative mode
    Stream<net.minecraft.world.item.ItemStack>
     
    static boolean
    supportsExtraInventory(net.minecraft.world.inventory.AbstractContainerMenu menu)
     
    void
    swapPaint(double scroll)
     
    void
     
    void
     
    void
    updateSize(boolean forceSync)
     

    Methods inherited from class net.minecraft.world.entity.player.Inventory

    add, addResource, addResource, clearOrCountMatchingItems, contains, getArmor, getName, getSelectionSize, getTimesChanged, hasRemainingSpaceForItem, isHotbarSlot, placeItemBackInInventory, placeItemBackInInventory, removeFromSelected, setChanged, stillValid

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.world.Container

    canPlaceItem, canTakeItem, countItem, getMaxStackSize, getMaxStackSize, hasAnyMatching, hasAnyOf, startOpen, stopOpen

    Methods inherited from interface net.minecraft.world.Nameable

    getCustomName, getDisplayName, hasCustomName
  • Field Details

    • extraItems

      public net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> extraItems
  • Constructor Details

    • ExtendedInventory

      public ExtendedInventory(net.minecraft.world.entity.player.Player player)
  • Method Details

    • enabled

      public static final boolean enabled()
    • enabled

      public static final boolean enabled(net.minecraft.world.flag.FeatureFlagSet flagSet)
    • get

      public static Optional<ExtendedInventory> get(net.minecraft.world.entity.player.Player player)
      Parameters:
      player -
      Returns:
      The Player's Extended Inventory
    • updateSize

      public void updateSize()
    • updateSize

      public void updateSize(boolean forceSync)
    • refreshPlayerInventoryMenu

      public static void refreshPlayerInventoryMenu(net.minecraft.world.entity.player.Player player, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY)
    • refreshPlayerInventoryMenuServer

      public static void refreshPlayerInventoryMenuServer(net.minecraft.world.entity.player.Player player)
    • isVanillaHotbarSlot

      public static boolean isVanillaHotbarSlot(int index)
      Whether the given Slot index corresponds to a vanilla hotbar Slot.
      Parameters:
      index -
      Returns:
      false if the Slot is not in the vanilla hotbar, even if there are additional hotbar Slots
    • setExtraInventorySize

      public void setExtraInventorySize(int size)
      Parameters:
      size - The additional Slots beyond what the Player would usually have
    • setExtraHotbarSlots

      public void setExtraHotbarSlots(int extraSlots)
      Parameters:
      extraSlots - The additional Slots beyond what the Player would usually have
    • getExtraHotbarSlots

      public int getExtraHotbarSlots()
      The number of additional hotbar Slots beyond the usual 9.
    • getExtraInventoryStartSlotIndex

      public int getExtraInventoryStartSlotIndex()
    • isFullHotbarSlot

      public boolean isFullHotbarSlot(int index)
      Whether the given slot index is part of the extended hotbar
      Parameters:
      index -
      Returns:
      true if it's a vanilla or extended index
    • getHotbarSize

      public int getHotbarSize()
      The total hotbar size, vanilla + extra slots
      See Also:
    • getSlotIndex

      protected int getSlotIndex(int hotbarIndex)
      Get the Slot index of the given index in the displayed hotbar - how far right the selected slot is, considering the sides on which the extra slots are
      Parameters:
      hotbarIndex - A number from 0 to 8 + getExtraHotbarSlots()
    • getSelectedHotbarIndex

      public int getSelectedHotbarIndex()
      The Slot index of the currently selected Slot
      Returns:
    • onPlayerJoinsWorld

      public static void onPlayerJoinsWorld(net.neoforged.neoforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent event)
    • onOpenContainer

      public static void onOpenContainer(net.neoforged.neoforge.event.entity.player.PlayerContainerEvent.Open event)
    • supportsExtraInventory

      public static boolean supportsExtraInventory(net.minecraft.world.inventory.AbstractContainerMenu menu)
    • addExtraInventorySlotsToMenu

      public void addExtraInventorySlotsToMenu(net.minecraft.world.inventory.AbstractContainerMenu menu, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY)
    • addExtraInventorySlotsToMenu

      public void addExtraInventorySlotsToMenu(Consumer<net.minecraft.world.inventory.Slot> slotAdder, ExtendedInventory.SlotFactory slotFactory, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY)
    • forEach

      public void forEach(Consumer<? super net.minecraft.world.item.ItemStack> action)
    • stream

      public Stream<net.minecraft.world.item.ItemStack> stream()
    • getSelected

      public net.minecraft.world.item.ItemStack getSelected()
      Overrides:
      getSelected in class net.minecraft.world.entity.player.Inventory
    • getFreeSlot

      public int getFreeSlot()
      Overrides:
      getFreeSlot in class net.minecraft.world.entity.player.Inventory
    • setPickedItem

      public void setPickedItem(@Nonnull net.minecraft.world.item.ItemStack stack)
      Pick an Item in Creative mode
      Overrides:
      setPickedItem in class net.minecraft.world.entity.player.Inventory
    • pickSlot

      public void pickSlot(int index)
      Stick an Item from the Inventory in the hotbar
      Overrides:
      pickSlot in class net.minecraft.world.entity.player.Inventory
    • findSlotMatchingItem

      public int findSlotMatchingItem(@Nonnull net.minecraft.world.item.ItemStack stack)
      Overrides:
      findSlotMatchingItem in class net.minecraft.world.entity.player.Inventory
    • findSlotMatchingUnusedItem

      public int findSlotMatchingUnusedItem(@Nonnull net.minecraft.world.item.ItemStack stack)
      Overrides:
      findSlotMatchingUnusedItem in class net.minecraft.world.entity.player.Inventory
    • findSlot

      public int findSlot(Predicate<net.minecraft.world.item.ItemStack> stackPredicate)
      Search for a slot in the vanilla and extended Inventories (i.e. not armor or offhand)
      Parameters:
      stackPredicate -
    • getSuitableHotbarSlot

      public int getSuitableHotbarSlot()
      Overrides:
      getSuitableHotbarSlot in class net.minecraft.world.entity.player.Inventory
    • swapPaint

      public void swapPaint(double scroll)
      Overrides:
      swapPaint in class net.minecraft.world.entity.player.Inventory
    • getSlotWithRemainingSpace

      public int getSlotWithRemainingSpace(@Nonnull net.minecraft.world.item.ItemStack stack)
      Overrides:
      getSlotWithRemainingSpace in class net.minecraft.world.entity.player.Inventory
    • tick

      public void tick()
      Overrides:
      tick in class net.minecraft.world.entity.player.Inventory
    • add

      public boolean add(int slot, @Nonnull net.minecraft.world.item.ItemStack stack)
      Copied from Minecraft source code
      Overrides:
      add in class net.minecraft.world.entity.player.Inventory
    • removeItem

      public net.minecraft.world.item.ItemStack removeItem(int slotIndex, int count)
      Specified by:
      removeItem in interface net.minecraft.world.Container
      Overrides:
      removeItem in class net.minecraft.world.entity.player.Inventory
    • removeItem

      public void removeItem(@Nonnull net.minecraft.world.item.ItemStack stack)
      Overrides:
      removeItem in class net.minecraft.world.entity.player.Inventory
    • removeItemNoUpdate

      public net.minecraft.world.item.ItemStack removeItemNoUpdate(int slotIndex)
      Specified by:
      removeItemNoUpdate in interface net.minecraft.world.Container
      Overrides:
      removeItemNoUpdate in class net.minecraft.world.entity.player.Inventory
    • setItem

      public void setItem(int slotIndex, @Nonnull net.minecraft.world.item.ItemStack stack)
      Specified by:
      setItem in interface net.minecraft.world.Container
      Overrides:
      setItem in class net.minecraft.world.entity.player.Inventory
    • getDestroySpeed

      public float getDestroySpeed(@Nonnull net.minecraft.world.level.block.state.BlockState state)
      Overrides:
      getDestroySpeed in class net.minecraft.world.entity.player.Inventory
    • save

      public net.minecraft.nbt.ListTag save(@Nonnull net.minecraft.nbt.ListTag listTag)
      Overrides:
      save in class net.minecraft.world.entity.player.Inventory
    • load

      public void load(@Nonnull net.minecraft.nbt.ListTag listTag)
      Overrides:
      load in class net.minecraft.world.entity.player.Inventory
    • getContainerSize

      public int getContainerSize()
      Specified by:
      getContainerSize in interface net.minecraft.world.Container
      Overrides:
      getContainerSize in class net.minecraft.world.entity.player.Inventory
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface net.minecraft.world.Container
      Overrides:
      isEmpty in class net.minecraft.world.entity.player.Inventory
    • getItem

      public net.minecraft.world.item.ItemStack getItem(int slotIndex)
      Specified by:
      getItem in interface net.minecraft.world.Container
      Overrides:
      getItem in class net.minecraft.world.entity.player.Inventory
    • dropAll

      public void dropAll()
      Overrides:
      dropAll in class net.minecraft.world.entity.player.Inventory
    • contains

      public boolean contains(@Nonnull net.minecraft.world.item.ItemStack stack)
      Overrides:
      contains in class net.minecraft.world.entity.player.Inventory
    • contains

      public boolean contains(@Nonnull net.minecraft.tags.TagKey<net.minecraft.world.item.Item> tag)
      Overrides:
      contains in class net.minecraft.world.entity.player.Inventory
    • replaceWith

      public void replaceWith(@Nonnull net.minecraft.world.entity.player.Inventory playerInventory)
      Overrides:
      replaceWith in class net.minecraft.world.entity.player.Inventory
    • clearContent

      public void clearContent()
      Specified by:
      clearContent in interface net.minecraft.world.Clearable
      Overrides:
      clearContent in class net.minecraft.world.entity.player.Inventory
    • fillStackedContents

      public void fillStackedContents(@Nonnull net.minecraft.world.entity.player.StackedContents stackedContents)
      Overrides:
      fillStackedContents in class net.minecraft.world.entity.player.Inventory