Class TerminalStorageTabIngredientComponentClient<T,M>

java.lang.Object
org.cyclops.integratedterminals.core.terminalstorage.TerminalStorageTabIngredientComponentClient<T,M>
Type Parameters:
T - The instance type.
M - The matching condition parameter.
All Implemented Interfaces:
ITerminalStorageTabClient<TerminalStorageSlotIngredient<T,M>>
Direct Known Subclasses:
TerminalStorageTabIngredientComponentItemStackCraftingClient

public class TerminalStorageTabIngredientComponentClient<T,M> extends Object implements ITerminalStorageTabClient<TerminalStorageSlotIngredient<T,M>>
A client-side storage terminal ingredient tab.
  • Field Details

    • ingredientComponent

      protected final org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T,M> ingredientComponent
    • container

      protected final ContainerTerminalStorageBase container
  • Constructor Details

    • TerminalStorageTabIngredientComponentClient

      public TerminalStorageTabIngredientComponentClient(ContainerTerminalStorageBase container, net.minecraft.resources.ResourceLocation name, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?> ingredientComponent)
  • Method Details

    • onToolTip

      public static void onToolTip(net.minecraftforge.event.entity.player.ItemTooltipEvent event)
    • loadButtons

      protected void loadButtons(List<ITerminalButton<?,?,?>> buttons)
    • getIngredientComponent

      public org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T,M> getIngredientComponent()
    • onSelect

      public void onSelect(int channel)
      Description copied from interface: ITerminalStorageTabClient
      When this tab is selected by the player.
      Specified by:
      onSelect in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - The channel.
    • onDeselect

      public void onDeselect(int channel)
      Description copied from interface: ITerminalStorageTabClient
      When this tab is deselected by the player.
      Specified by:
      onDeselect in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - The channel.
    • getName

      public net.minecraft.resources.ResourceLocation getName()
      Specified by:
      getName in interface ITerminalStorageTabClient<T>
      Returns:
      The unique tab name, as inherited from ITerminalStorageTab.getName().
    • getIcon

      public net.minecraft.world.item.ItemStack getIcon()
      Specified by:
      getIcon in interface ITerminalStorageTabClient<T>
      Returns:
      An icon for the tab.
    • getTooltip

      public List<net.minecraft.network.chat.Component> getTooltip()
      Specified by:
      getTooltip in interface ITerminalStorageTabClient<T>
      Returns:
      A tooltip when hovering over the icon.
    • getInstanceFilter

      public String getInstanceFilter(int channel)
      Description copied from interface: ITerminalStorageTabClient
      Get the currently active filter.
      Specified by:
      getInstanceFilter in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - The channel to get the filter for.
      Returns:
      The active filter.
    • getInstanceFilterMetadata

    • resetFilteredIngredientsViews

      public void resetFilteredIngredientsViews(int channel)
    • resetFilteredIngredientsViews

      public void resetFilteredIngredientsViews(int channel, boolean resetPausedSortingOrder)
      Reset the filtered ingredients views of the given channel.
      Parameters:
      channel - A channel id.
      resetPausedSortingOrder - If the ingredient order that is used to keep ingredient positions stable while sorting is paused should be forgotten as well. This should only be false for changes that are not caused by the user, as user-triggered changes should always be applied immediately.
    • isSortingPaused

      public boolean isSortingPaused()
      Returns:
      If the automatic re-sorting of ingredients is currently paused.
    • updateSortingPausedState

      protected void updateSortingPausedState(int channel)
      Check if sorting has been paused or resumed since the last call, and re-sort all ingredient views when sorting has been resumed.
      Parameters:
      channel - A channel id.
    • setInstanceFilter

      public void setInstanceFilter(int channel, String filter)
      Description copied from interface: ITerminalStorageTabClient
      Set a filter for instances in slots.
      Specified by:
      setInstanceFilter in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - The channel to filter in.
      filter - A string-based filter, which could be a regex.
    • getRawUnfilteredIngredientsView

      public org.cyclops.cyclopscore.ingredient.collection.IIngredientCollapsedCollectionMutable<T,M> getRawUnfilteredIngredientsView(int channel)
    • getCraftingOptions

      @Nullable public Collection<HandlerWrappedTerminalCraftingOption<T>> getCraftingOptions(int channel)
    • createUnfilteredIngredientsView

      public List<TerminalStorageTabIngredientComponentClient.InstanceWithMetadata<T>> createUnfilteredIngredientsView(int channel)
    • getUniqueCraftingOptionOutputs

      public Collection<T> getUniqueCraftingOptionOutputs(ITerminalCraftingOption<T> craftingOption)
    • getFilteredIngredientsView

      protected List<TerminalStorageTabIngredientComponentClient.InstanceWithMetadata<T>> getFilteredIngredientsView(int channel)
    • sortByPreviousOrder

      protected void sortByPreviousOrder(List<TerminalStorageTabIngredientComponentClient.InstanceWithMetadata<T>> ingredientsView, List<TerminalStorageTabIngredientComponentClient.InstanceWithMetadata<T>> previousView, @Nullable Comparator<T> sorter)
      Sort the given ingredients view based on the order of a previously shown ingredients view. Ingredients that were present in the previous view keep their position, independent of their quantity, while new ingredients are appended at the end.
      Parameters:
      ingredientsView - The ingredients view to sort in-place.
      previousView - A previously shown ingredients view.
      sorter - An optional sorter that is used for ordering the new ingredients.
    • withoutQuantity

      Create a copy of the given ingredient with a fixed quantity, so that it can be used as a quantity-independent key.
      Parameters:
      instanceWithMetadata - An ingredient with metadata.
      Returns:
      A quantity-independent copy.
    • transformIngredientsView

    • getSlots

      public List<TerminalStorageSlotIngredient<T,M>> getSlots(int channel, int offset, int limit)
      Description copied from interface: ITerminalStorageTabClient
      Get a subset of slots.
      Specified by:
      getSlots in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - A channel id.
      offset - A slot offset.
      limit - A slot limit.
      Returns:
      A list of slots, can be empty.
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface ITerminalStorageTabClient<T>
      Returns:
      If this tab is enabled.
    • getSlotInstance

      public Optional<T> getSlotInstance(int channel, int index)
    • getSlot

      public Optional<TerminalStorageSlotIngredient<T,M>> getSlot(int channel, int index)
    • getSlotCount

      public int getSlotCount(int channel)
      Description copied from interface: ITerminalStorageTabClient
      Get the total number of slots in the given channel
      Specified by:
      getSlotCount in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - A channel id.
      Returns:
      A slot count.
    • getStatus

      public String getStatus(int channel)
      Specified by:
      getStatus in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - A channel id.
      Returns:
      A status string.
    • onChange

      public void onChange(int channel, org.cyclops.integrateddynamics.api.ingredient.IIngredientComponentStorageObservable.Change changeType, org.cyclops.cyclopscore.ingredient.collection.IngredientArrayList<T,M> ingredients, boolean enabled)
      Receiver an ingredients change event.
      Parameters:
      channel - A channel id.
      changeType - A change type.
      ingredients - A list of changed ingredients.
      enabled - If this tab is enabled.
    • updateActiveInstance

      protected void updateActiveInstance(Optional<T> lastInstance, int channel)
    • addCraftingOptions

      public void addCraftingOptions(int channel, List<HandlerWrappedTerminalCraftingOption<T>> craftingOptions, boolean reset, boolean firstChannel)
    • findActiveSlotId

      protected int findActiveSlotId(int channel, T instance)
    • handleActiveIngredientUpdate

      public void handleActiveIngredientUpdate(int channel, T activeInstance)
      Called by the server when a (remainder) active storage ingredient needs to be set.
      Parameters:
      channel - The channel.
      activeInstance - The active instance.
    • getMaxQuantity

      public long getMaxQuantity(int channel)
      Get the total maximum allowed quantity in the given channel.
      Parameters:
      channel - A channel id.
      Returns:
      The max quantity.
    • setMaxQuantity

      public void setMaxQuantity(int channel, long maxQuantity)
      Set the max quantity in the given channel.
      Parameters:
      channel - A channel id.
      maxQuantity - The new max quantity.
    • getTotalQuantity

      public long getTotalQuantity(int channel)
      Get the total instance quantities in the given channel.
      Parameters:
      channel - A channel id.
      Returns:
      The total quantity.
    • getChannels

      public int[] getChannels()
      Specified by:
      getChannels in interface ITerminalStorageTabClient<T>
      Returns:
      All available channels.
    • resetActiveSlot

      public void resetActiveSlot()
      Description copied from interface: ITerminalStorageTabClient
      Unselect the active storage slot.
      Specified by:
      resetActiveSlot in interface ITerminalStorageTabClient<T>
    • handleClick

      public boolean handleClick(net.minecraft.world.inventory.AbstractContainerMenu container, int channel, int hoveringStorageSlot, int mouseButton, boolean hasClickedOutside, boolean hasClickedInStorage, int hoveredContainerSlot, boolean isQuickMove)
      Description copied from interface: ITerminalStorageTabClient
      Called when a mouse click happens in a gui.
      Specified by:
      handleClick in interface ITerminalStorageTabClient<T>
      Parameters:
      container - The active container.
      channel - The active channel.
      hoveringStorageSlot - The storage slot id that is being hovered. -1 if none.
      mouseButton - The mouse button.
      hasClickedOutside - If the player has clicked outside the gui.
      hasClickedInStorage - If the player has clicked inside the storage space. This can be true even if the storage slot is -1.
      hoveredContainerSlot - The container slot id that is being hovered. -1 if none.
      isQuickMove - If the click comes from a quickMoveStack action
      Returns:
      If further click processing should stop.
    • handleScroll

      public boolean handleScroll(net.minecraft.world.inventory.AbstractContainerMenu container, int channel, int hoveringStorageSlot, double delta, boolean hasClickedOutside, boolean hasClickedInStorage, int hoveredContainerSlot)
      Description copied from interface: ITerminalStorageTabClient
      Called when a mouse scroll happens in a gui.
      Specified by:
      handleScroll in interface ITerminalStorageTabClient<T>
      Parameters:
      container - The active container.
      channel - The active channel.
      hoveringStorageSlot - The storage slot id that is being hovered. -1 if none.
      delta - The scroll delta.
      hasClickedOutside - If the player has clicked outside the gui.
      hasClickedInStorage - If the player has clicked inside the storage space. This can be true even if the storage slot is -1.
      hoveredContainerSlot - The container slot id that is being hovered. -1 if none.
      Returns:
      If further click processing should stop.
    • getActiveSlotId

      public int getActiveSlotId()
      Specified by:
      getActiveSlotId in interface ITerminalStorageTabClient<T>
      Returns:
      The active storage slot id.
    • getActiveSlotQuantity

      public int getActiveSlotQuantity()
      Specified by:
      getActiveSlotQuantity in interface ITerminalStorageTabClient<T>
      Returns:
      The active storage slot quantity.
    • setActiveSlotQuantity

      public void setActiveSlotQuantity(int quantity)
      Description copied from interface: ITerminalStorageTabClient
      Set the active quantity.
      Specified by:
      setActiveSlotQuantity in interface ITerminalStorageTabClient<T>
      Parameters:
      quantity - A quantity to set.
    • getButtons

      public List<ITerminalButton<?,?,?>> getButtons()
      Specified by:
      getButtons in interface ITerminalStorageTabClient<T>
      Returns:
      Buttons that are available for this tab.
    • getInstanceSorter

      @Nullable public Comparator<T> getInstanceSorter()
    • getRowColumnProvider

      public ITerminalRowColumnProvider getRowColumnProvider()
      Specified by:
      getRowColumnProvider in interface ITerminalStorageTabClient<T>
      Returns:
      The current provider of row and column count.
    • onCommonSlotRender

      public void onCommonSlotRender(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen gui, net.minecraft.client.gui.GuiGraphics guiGraphics, ContainerScreenTerminalStorage.DrawLayer layer, float partialTick, int x, int y, int mouseX, int mouseY, int slot, ITerminalStorageTabCommon tabCommon)
      Specified by:
      onCommonSlotRender in interface ITerminalStorageTabClient<T>
    • getViewHandler

      protected IIngredientComponentTerminalStorageHandler<T,M> getViewHandler()
    • isSlotValidForDraggingInto

      public boolean isSlotValidForDraggingInto(int channel, net.minecraft.world.inventory.Slot slot)
      Description copied from interface: ITerminalStorageTabClient
      Check if we can drag over the current slot with an active instance.
      Specified by:
      isSlotValidForDraggingInto in interface ITerminalStorageTabClient<T>
      Parameters:
      channel - The active channel.
      slot - The slot to drag over.
      Returns:
      If we can drag over the slot.
    • computeDraggingQuantity

      public int computeDraggingQuantity(Set<net.minecraft.world.inventory.Slot> dragSlots, int dragMode, net.minecraft.world.item.ItemStack stack, int quantity)
      Description copied from interface: ITerminalStorageTabClient
      Calculate the quantity that will be added to the given stack based on the drag mode and the given list of slots.
      Specified by:
      computeDraggingQuantity in interface ITerminalStorageTabClient<T>
      Parameters:
      dragSlots - The list of slots to drag over.
      dragMode - The drag mode.
      stack - The stack to calculate the quantity for.
      quantity - The available quantity to drag.
      Returns:
      The quantity that will be added.
    • dragIntoSlot

      public int dragIntoSlot(net.minecraft.world.inventory.AbstractContainerMenu container, int channel, net.minecraft.world.inventory.Slot slot, int quantity, boolean simulate)
      Description copied from interface: ITerminalStorageTabClient
      Drag the given quantity into the given slot with the currently active instance.
      Specified by:
      dragIntoSlot in interface ITerminalStorageTabClient<T>
      Parameters:
      container - The active container.
      channel - The active channel.
      slot - The slot to drag into.
      quantity - The quantity to insert.
      simulate - If insertion should only be simulated.
      Returns:
      The quantity that was inserted.
    • resetScale

      public void resetScale()
    • getLastChangeId

      public int getLastChangeId()