Class ExtendedInventoryClientHandler

java.lang.Object
com.petrolpark.core.extendedinventory.ExtendedInventoryClientHandler

@Experimental public class ExtendedInventoryClientHandler extends Object
  • Field Details

    • INVENTORY_PADDING

      public static final int INVENTORY_PADDING
      The space between the edge of the Extended Inventory "window" and the actual Slot.
      See Also:
    • INVENTORY_SPACING

      public static final int INVENTORY_SPACING
      The space between the regular Inventory "window" and any Extended Inventory "window".
      See Also:
    • INVENTORY_HOTBAR_SPACING

      public static final int INVENTORY_HOTBAR_SPACING
      The vertical space between the main Inventory and Hotbar Slots.
      See Also:
    • currentScreen

      public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen<?> currentScreen
      The Screen currently being rendered with extra Slots, or null if no Screen showing extra Slots is being rendered.
  • Constructor Details

    • ExtendedInventoryClientHandler

      public ExtendedInventoryClientHandler()
  • Method Details

    • onClientTick

      public final void onClientTick(net.neoforged.neoforge.client.event.ClientTickEvent.Pre event)
      Tick the Extended Inventory, client side. This:
      • Checks to see if the render settings of the Extended Inventory has been changed in the configs
      • Consumes Hotbar key presses

      Parameters:
      event -
    • refreshClientInventoryMenu

      public static void refreshClientInventoryMenu(ExtendedInventory inv)
      Refresh the locations of the Extended Inventory Slots in the Survival Inventory only.
      Parameters:
      inv - The Player's Extended Inventory
    • handleExtendedInventorySizeChange

      public static void handleExtendedInventorySizeChange(ExtraInventorySizeChangePacket packet)
      Syncronize the additional Inventory Slots and Hotbar Slots on the client so they match the server. This should be done whenever attributes are synced anyway, but we have this just in case.
      Parameters:
      packet -
    • getLeftExtraHotbarSlots

      public static final int getLeftExtraHotbarSlots(int totalExtraHotbarSlots)
      The number of additional Hotbar Slots to the left of the Vanilla Hotbar.
      Parameters:
      totalExtraHotbarSlots - The number of extra Hotbar Slots on either side of the vanilla hotbar
    • getRightExtraHotbarSlots

      public static final int getRightExtraHotbarSlots(int totalExtraHotbarSlots)
      The number of additional Hotbar Slots to the right of the Vanilla Hotbar.
      Parameters:
      totalExtraHotbarSlots - The number of extra Hotbar Slots on either side of the vanilla hotbar
    • isExtraInventoryOnLeft

      public static final boolean isExtraInventoryOnLeft()
      Where the extra non-Hotbar Slots of the Extended Inventory are.
      Returns:
      true on left, false on right
    • getExtraInventoryWidth

      public static final int getExtraInventoryWidth()
      The number of Slots wide non-hotbar section of the Extended Inventory is.
    • getExtraHotbarSlotLocations

      public static final ExtendedInventoryClientHandler.ExtraHotbarSlotLocations getExtraHotbarSlotLocations()
      How the additional Hotbar Slots should be arranged according to the Player's configs.
    • getExtraHotbarPrioritySlots

      public static final int getExtraHotbarPrioritySlots()
      See Also:
    • getExtraInventoryClientSettings

      public ExtendedInventoryClientHandler.ExtraInventoryClientSettings getExtraInventoryClientSettings()
      See Also:
    • getLeftHotbarLocation

      public static final net.minecraft.client.renderer.Rect2i getLeftHotbarLocation(ExtendedInventory inv, net.minecraft.client.renderer.Rect2i screenArea, int hotbarY)
      The location of the very top left of the "window" for Extended Inventory Hotbar Slots on the left.
      Returns:
      null if there are no Hotbar Slots rendered on the left
    • getRightHotbarLocation

      public static final net.minecraft.client.renderer.Rect2i getRightHotbarLocation(ExtendedInventory inv, net.minecraft.client.renderer.Rect2i screenArea, int hotbarY)
      The location of the very top left of the "window" for Extended Inventory Hotbar Slots on the right.
      Returns:
      null if there are no Hotbar Slots rendered on the right
    • getHotbarLocation

      protected static final net.minecraft.client.renderer.Rect2i getHotbarLocation(net.minecraft.client.renderer.Rect2i screenArea, int hotbarY, int xOffset, int slots)
      The location of an Extended Inventory Hotbar "window" with padding applied.
    • getCombinedInventoryHotbarLocation

      public static final net.minecraft.client.renderer.Rect2i getCombinedInventoryHotbarLocation(ExtendedInventory inv, net.minecraft.client.renderer.Rect2i screenArea, int hotbarY)
      The location of a combined "window" for both the main Extended Inventory Slots and the Hotbar Slots on the same side.
      Returns:
      null if the main Extended Inventory section is too short to merge with the Hotbar "window", or if there is no Hotbar "window" on the side of the main Inventory.
    • getInventoryLocation

      public static final net.minecraft.client.renderer.Rect2i getInventoryLocation(ExtendedInventory inv, net.minecraft.client.renderer.Rect2i screenArea, int hotbarY)
      The location of the "window" for the Extended Inventory Slots that are not on the hotbar.
      Returns:
      null if there are no Slots of that description
    • getScreenArea

      public static final net.minecraft.client.renderer.Rect2i getScreenArea(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen<?> screen)
      Get the maximum space the given Screen (without the Extended Inventory "windows" added on) occupies, accounting for any sticky-outy bits.
    • refreshExtraInventoryAreas

      public void refreshExtraInventoryAreas(ExtendedInventory inv)
      Refresh the locations of the "windows" for the Extended Inventory Slots on the current Screen.
    • findHotbarY

      public static int findHotbarY(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen<?> screen)
      Search the Slots of the given Screen to find where the (non-Extended) Inventory's Hotbar is rendered.
    • getLeftmostX

      public int getLeftmostX()
      The leftmost point of any Extended Inventory "windows".
    • addSlotsToClientMenu

      public void addSlotsToClientMenu(ExtendedInventory inv, net.minecraft.world.inventory.AbstractContainerMenu menu)
      Add Slots corresponding to those of the Extended Inventory to a Menu, on the client side. Unlike with ExtendedInventory.refreshPlayerInventoryMenuServer(Player), the location is important.
      Parameters:
      inv -
      menu -
      See Also:
    • addSlotsToClientMenu

      public void addSlotsToClientMenu(ExtendedInventory inv, Consumer<net.minecraft.world.inventory.Slot> slotAdder, ExtendedInventory.SlotFactory slotFactory)
      Add Slots corresponding to those of the Extended Inventory to a Menu, on the client side. Unlike with ExtendedInventory.refreshPlayerInventoryMenuServer(Player), the location is important.
      Parameters:
      inv -
      slotAdder -
      slotFactory -
      See Also:
    • onScreenInitPost

      public void onScreenInitPost(net.neoforged.neoforge.client.event.ScreenEvent.Init.Post event)
      Before opening a Screen, add the additional Slots (if they are not already added).
      Parameters:
      event -
    • onScreenRenderPre

      public void onScreenRenderPre(net.neoforged.neoforge.client.event.ScreenEvent.Render.Pre event)
      Render the "window" backgrounds and Slot backgrounds of Extended Inventory Slots.
      Parameters:
      event -
    • onScreenClosing

      public void onScreenClosing(net.neoforged.neoforge.client.event.ScreenEvent.Closing event)
      Upon closing a Screen, forget which Screen should have extra Slots rendered for it.
      Parameters:
      event -
    • renderExtraHotbarBackground

      public static void renderExtraHotbarBackground(net.minecraft.client.gui.GuiGraphics graphics, net.minecraft.client.DeltaTracker deltaTracker)
      Render the borders for the Extended Inventory Slots on the Hotbar.
    • renderExtraHotbar

      public static void renderExtraHotbar(net.minecraft.client.gui.GuiGraphics graphics, net.minecraft.client.DeltaTracker deltaTracker)
      Render the Slot icons and actual Items in the Extended Inventory Hotbar Slots. Also render the selected Slot (again).
    • getGuiExtraAreas

      public List<net.minecraft.client.renderer.Rect2i> getGuiExtraAreas()
      The spaces on the screen taken up by the Extended Inventory "windows". JEI needs to know these. We also use them to move the Recipe Book out of the way.