Class ScrollingInventoryContainer<E>
java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
org.cyclops.cyclopscore.inventory.container.ContainerExtended
org.cyclops.cyclopscore.inventory.container.InventoryContainer
org.cyclops.cyclopscore.inventory.container.ScrollingInventoryContainer<E>
- All Implemented Interfaces:
WidgetScrollBar.IScrollCallback
,IContainerButtonClickAcceptorServer<ContainerExtended>
,IValueNotifiable
,IValueNotifier
public abstract class ScrollingInventoryContainer<E>
extends InventoryContainer
implements WidgetScrollBar.IScrollCallback
An inventory container that has a scrollbar and searchfield.
Terminology:
row: The row index from visible elements.
elementIndex: The element index in all available elements
visible: Currently on-screen by the user, maximum amount of elements is determined by the pageSize
filtered: All items that are browsable by the user, might be more than the pageSize allows what leads to a scrollbar.
unfiltered: All items, pattern searching will happen in this list.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Predicate for matching items used to search. -
Field Summary
Fields inherited from class org.cyclops.cyclopscore.inventory.container.InventoryContainer
inventory
Fields inherited from class org.cyclops.cyclopscore.inventory.container.ContainerExtended
ITEMBOX, offsetX, offsetY, player
Fields inherited from class net.minecraft.world.inventory.AbstractContainerMenu
CARRIED_SLOT_SIZE, containerId, QUICKCRAFT_HEADER_CONTINUE, QUICKCRAFT_HEADER_END, QUICKCRAFT_HEADER_START, QUICKCRAFT_TYPE_CHARITABLE, QUICKCRAFT_TYPE_CLONE, QUICKCRAFT_TYPE_GREEDY, SLOT_CLICKED_OUTSIDE, slots
-
Constructor Summary
ConstructorDescriptionScrollingInventoryContainer
(net.minecraft.world.inventory.MenuType<?> type, int id, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.world.Container inventory, List<E> items, ScrollingInventoryContainer.IItemPredicate<E> filterer) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
additionalApplies
(E item) An additional conditional that can be added for filtering items.protected void
enableElementAt
(int visibleIndex, int elementIndex, E element) After scrolling, this will be called to make items visible.int
int
int
abstract int
int
int
getVisibleElement
(int row) Get the currently visible element at the given row.boolean
isElementVisible
(int row) Check if the given element is visible.void
onScroll
(int firstRow) void
void
updateFilter
(String searchString) Update the filtered items.Methods inherited from class org.cyclops.cyclopscore.inventory.container.InventoryContainer
getContainerInventory, getSizeInventory, isAssertInventorySize, removed, stillValid
Methods inherited from class org.cyclops.cyclopscore.inventory.container.ContainerExtended
addInventory, addPlayerArmorInventory, addPlayerInventory, addSlot, addSlotListener, adjustPhantomSlot, broadcastChanges, clicked, createNewSlot, fillPhantomSlot, getNextValueId, getPlayerIInventory, getSlotRange, getSlotStart, getValue, getValueIds, getValueNotifiableType, initializeValues, moveItemStackTo, onButtonClick, onUpdate, putButtonAction, quickMoveStack, registerSyncedVariable, resetQuickCraft, setGuiValueListener, setSlotPosX, setSlotPosY, setValue
Methods inherited from class net.minecraft.world.inventory.AbstractContainerMenu
addDataSlot, addDataSlots, broadcastFullState, canDragTo, canItemQuickReplace, canTakeItemForPickAll, checkContainerDataCount, checkContainerSize, clearContainer, clickMenuButton, createCarriedSlotAccess, findSlot, getCarried, getItems, getQuickcraftHeader, getQuickcraftMask, getQuickCraftPlaceCount, getQuickcraftType, getRedstoneSignalFromBlockEntity, getRedstoneSignalFromContainer, getSlot, getStateId, getType, incrementStateId, initializeContents, isValidQuickcraftType, isValidSlotIndex, removeSlotListener, resumeRemoteUpdates, sendAllDataToRemote, setCarried, setData, setItem, setRemoteCarried, setRemoteSlot, setRemoteSlotNoCopy, setSynchronizer, slotsChanged, stillValid, suppressRemoteUpdates, transferState
-
Constructor Details
-
ScrollingInventoryContainer
public ScrollingInventoryContainer(@Nullable net.minecraft.world.inventory.MenuType<?> type, int id, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.world.Container inventory, List<E> items, ScrollingInventoryContainer.IItemPredicate<E> filterer)
-
-
Method Details
-
getUnfilteredItems
-
getFilteredItems
-
getUnfilteredItemCount
public int getUnfilteredItemCount() -
getFilteredItemCount
public int getFilteredItemCount() -
getFirstElement
public int getFirstElement() -
getColumns
public int getColumns()- Returns:
- The maximum amount of columns to show.
-
getScrollStepSize
public int getScrollStepSize()- Returns:
- The stepsize for scrolling.
-
onScroll
public void onScroll(int firstRow) - Specified by:
onScroll
in interfaceWidgetScrollBar.IScrollCallback
-
getPageSize
public abstract int getPageSize()- Returns:
- The allowed page size.
-
enableElementAt
After scrolling, this will be called to make items visible.- Parameters:
visibleIndex
- The visible item index.elementIndex
- The absolute element index.element
- The element to show.
-
isElementVisible
public boolean isElementVisible(int row) Check if the given element is visible.- Parameters:
row
- The row the the given element is at.- Returns:
- If it is visible.
-
getVisibleElement
Get the currently visible element at the given row.- Parameters:
row
- The row the the given element is at.- Returns:
- The elements
-
refreshFilter
public void refreshFilter() -
updateFilter
Update the filtered items.- Parameters:
searchString
- The input string to search by.
-
filter
-
additionalApplies
An additional conditional that can be added for filtering items.- Parameters:
item
- The item to check.- Returns:
- If the item should be shown.
-