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 ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionnet.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_OFFHANDFields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_BUFFER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int slot, net.minecraft.world.item.ItemStack stack) Copied fromMinecraft source codevoidaddExtraInventorySlotsToMenu(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) voidaddExtraInventorySlotsToMenu(net.minecraft.world.inventory.AbstractContainerMenu menu, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY) voidbooleancontains(net.minecraft.tags.TagKey<net.minecraft.world.item.Item> tag) booleancontains(net.minecraft.world.item.ItemStack stack) voiddropAll()static final booleanenabled()static final booleanenabled(net.minecraft.world.flag.FeatureFlagSet flagSet) voidfillStackedContents(net.minecraft.world.entity.player.StackedContents stackedContents) intSearch for a slot in the vanilla and extended Inventories (i.e.intfindSlotMatchingItem(net.minecraft.world.item.ItemStack stack) intfindSlotMatchingUnusedItem(net.minecraft.world.item.ItemStack stack) voidstatic Optional<ExtendedInventory> get(net.minecraft.world.entity.player.Player player) intfloatgetDestroySpeed(net.minecraft.world.level.block.state.BlockState state) intThe number of additional hotbar Slots beyond the usual 9.intintintThe total hotbar size, vanilla + extra slotsnet.minecraft.world.item.ItemStackgetItem(int slotIndex) net.minecraft.world.item.ItemStackintThe Slot index of the currently selected Slotprotected intgetSlotIndex(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 areintgetSlotWithRemainingSpace(net.minecraft.world.item.ItemStack stack) intbooleanisEmpty()booleanisFullHotbarSlot(int index) Whether the given slot index is part of the extended hotbarstatic booleanisVanillaHotbarSlot(int index) Whether the given Slot index corresponds to a vanilla hotbar Slot.voidload(net.minecraft.nbt.ListTag listTag) static voidonOpenContainer(net.neoforged.neoforge.event.entity.player.PlayerContainerEvent.Open event) static voidonPlayerJoinsWorld(net.neoforged.neoforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent event) voidpickSlot(int index) Stick an Item from the Inventory in the hotbarstatic voidrefreshPlayerInventoryMenu(net.minecraft.world.entity.player.Player player, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY) static voidrefreshPlayerInventoryMenuServer(net.minecraft.world.entity.player.Player player) net.minecraft.world.item.ItemStackremoveItem(int slotIndex, int count) voidremoveItem(net.minecraft.world.item.ItemStack stack) net.minecraft.world.item.ItemStackremoveItemNoUpdate(int slotIndex) voidreplaceWith(net.minecraft.world.entity.player.Inventory playerInventory) net.minecraft.nbt.ListTagsave(net.minecraft.nbt.ListTag listTag) voidsetExtraHotbarSlots(int extraSlots) voidsetExtraInventorySize(int size) voidsetItem(int slotIndex, net.minecraft.world.item.ItemStack stack) voidsetPickedItem(net.minecraft.world.item.ItemStack stack) Pick an Item in Creative modeStream<net.minecraft.world.item.ItemStack> stream()static booleansupportsExtraInventory(net.minecraft.world.inventory.AbstractContainerMenu menu) voidswapPaint(double scroll) voidtick()voidvoidupdateSize(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, stillValidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.Container
canPlaceItem, canTakeItem, countItem, getMaxStackSize, getMaxStackSize, hasAnyMatching, hasAnyOf, startOpen, stopOpenMethods 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
- 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:
falseif 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:
trueif 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 from0to8 + 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
-
stream
-
getSelected
public net.minecraft.world.item.ItemStack getSelected()- Overrides:
getSelectedin classnet.minecraft.world.entity.player.Inventory
-
getFreeSlot
public int getFreeSlot()- Overrides:
getFreeSlotin classnet.minecraft.world.entity.player.Inventory
-
setPickedItem
public void setPickedItem(@Nonnull net.minecraft.world.item.ItemStack stack) Pick an Item in Creative mode- Overrides:
setPickedItemin classnet.minecraft.world.entity.player.Inventory
-
pickSlot
public void pickSlot(int index) Stick an Item from the Inventory in the hotbar- Overrides:
pickSlotin classnet.minecraft.world.entity.player.Inventory
-
findSlotMatchingItem
public int findSlotMatchingItem(@Nonnull net.minecraft.world.item.ItemStack stack) - Overrides:
findSlotMatchingItemin classnet.minecraft.world.entity.player.Inventory
-
findSlotMatchingUnusedItem
public int findSlotMatchingUnusedItem(@Nonnull net.minecraft.world.item.ItemStack stack) - Overrides:
findSlotMatchingUnusedItemin classnet.minecraft.world.entity.player.Inventory
-
findSlot
Search for a slot in the vanilla and extended Inventories (i.e. not armor or offhand)- Parameters:
stackPredicate-
-
getSuitableHotbarSlot
public int getSuitableHotbarSlot()- Overrides:
getSuitableHotbarSlotin classnet.minecraft.world.entity.player.Inventory
-
swapPaint
public void swapPaint(double scroll) - Overrides:
swapPaintin classnet.minecraft.world.entity.player.Inventory
-
getSlotWithRemainingSpace
public int getSlotWithRemainingSpace(@Nonnull net.minecraft.world.item.ItemStack stack) - Overrides:
getSlotWithRemainingSpacein classnet.minecraft.world.entity.player.Inventory
-
tick
public void tick()- Overrides:
tickin classnet.minecraft.world.entity.player.Inventory
-
add
public boolean add(int slot, @Nonnull net.minecraft.world.item.ItemStack stack) Copied fromMinecraft source code- Overrides:
addin classnet.minecraft.world.entity.player.Inventory
-
removeItem
public net.minecraft.world.item.ItemStack removeItem(int slotIndex, int count) - Specified by:
removeItemin interfacenet.minecraft.world.Container- Overrides:
removeItemin classnet.minecraft.world.entity.player.Inventory
-
removeItem
public void removeItem(@Nonnull net.minecraft.world.item.ItemStack stack) - Overrides:
removeItemin classnet.minecraft.world.entity.player.Inventory
-
removeItemNoUpdate
public net.minecraft.world.item.ItemStack removeItemNoUpdate(int slotIndex) - Specified by:
removeItemNoUpdatein interfacenet.minecraft.world.Container- Overrides:
removeItemNoUpdatein classnet.minecraft.world.entity.player.Inventory
-
setItem
public void setItem(int slotIndex, @Nonnull net.minecraft.world.item.ItemStack stack) - Specified by:
setItemin interfacenet.minecraft.world.Container- Overrides:
setItemin classnet.minecraft.world.entity.player.Inventory
-
getDestroySpeed
public float getDestroySpeed(@Nonnull net.minecraft.world.level.block.state.BlockState state) - Overrides:
getDestroySpeedin classnet.minecraft.world.entity.player.Inventory
-
save
public net.minecraft.nbt.ListTag save(@Nonnull net.minecraft.nbt.ListTag listTag) - Overrides:
savein classnet.minecraft.world.entity.player.Inventory
-
load
public void load(@Nonnull net.minecraft.nbt.ListTag listTag) - Overrides:
loadin classnet.minecraft.world.entity.player.Inventory
-
getContainerSize
public int getContainerSize()- Specified by:
getContainerSizein interfacenet.minecraft.world.Container- Overrides:
getContainerSizein classnet.minecraft.world.entity.player.Inventory
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacenet.minecraft.world.Container- Overrides:
isEmptyin classnet.minecraft.world.entity.player.Inventory
-
getItem
public net.minecraft.world.item.ItemStack getItem(int slotIndex) - Specified by:
getItemin interfacenet.minecraft.world.Container- Overrides:
getItemin classnet.minecraft.world.entity.player.Inventory
-
dropAll
public void dropAll()- Overrides:
dropAllin classnet.minecraft.world.entity.player.Inventory
-
contains
public boolean contains(@Nonnull net.minecraft.world.item.ItemStack stack) - Overrides:
containsin classnet.minecraft.world.entity.player.Inventory
-
contains
public boolean contains(@Nonnull net.minecraft.tags.TagKey<net.minecraft.world.item.Item> tag) - Overrides:
containsin classnet.minecraft.world.entity.player.Inventory
-
replaceWith
public void replaceWith(@Nonnull net.minecraft.world.entity.player.Inventory playerInventory) - Overrides:
replaceWithin classnet.minecraft.world.entity.player.Inventory
-
clearContent
public void clearContent()- Specified by:
clearContentin interfacenet.minecraft.world.Clearable- Overrides:
clearContentin classnet.minecraft.world.entity.player.Inventory
-
fillStackedContents
public void fillStackedContents(@Nonnull net.minecraft.world.entity.player.StackedContents stackedContents) - Overrides:
fillStackedContentsin classnet.minecraft.world.entity.player.Inventory
-