Class ExtendedInventoryClientHandler
java.lang.Object
com.petrolpark.core.extendedinventory.ExtendedInventoryClientHandler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final recordstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionnet.minecraft.client.gui.screens.inventory.AbstractContainerScreen<?> The Screen currently being rendered with extra Slots, ornullif no Screen showing extra Slots is being rendered.static final intThe vertical space between the main Inventory and Hotbar Slots.static final intThe space between the edge of the Extended Inventory "window" and the actual Slot.static final intThe space between the regular Inventory "window" and any Extended Inventory "window". -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSlotsToClientMenu(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.voidaddSlotsToClientMenu(ExtendedInventory inv, net.minecraft.world.inventory.AbstractContainerMenu menu) Add Slots corresponding to those of the Extended Inventory to a Menu, on the client side.static intfindHotbarY(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.static final net.minecraft.client.renderer.Rect2igetCombinedInventoryHotbarLocation(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.static final intHow the additional Hotbar Slots should be arranged according to the Player's configs.static final intThe number of Slots wide non-hotbar section of the Extended Inventory is.List<net.minecraft.client.renderer.Rect2i> The spaces on the screen taken up by the Extended Inventory "windows".protected static final net.minecraft.client.renderer.Rect2igetHotbarLocation(net.minecraft.client.renderer.Rect2i screenArea, int hotbarY, int xOffset, int slots) The location of an Extended Inventory Hotbar "window" with padding applied.static final net.minecraft.client.renderer.Rect2igetInventoryLocation(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.static final intgetLeftExtraHotbarSlots(int totalExtraHotbarSlots) The number of additional Hotbar Slots to the left of the Vanilla Hotbar.static final net.minecraft.client.renderer.Rect2igetLeftHotbarLocation(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.intThe leftmost point of any Extended Inventory "windows".static final intgetRightExtraHotbarSlots(int totalExtraHotbarSlots) The number of additional Hotbar Slots to the right of the Vanilla Hotbar.static final net.minecraft.client.renderer.Rect2igetRightHotbarLocation(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.static final net.minecraft.client.renderer.Rect2igetScreenArea(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.static voidSyncronize the additional Inventory Slots and Hotbar Slots on the client so they match the server.static final booleanWhere the extra non-Hotbar Slots of the Extended Inventory are.final voidonClientTick(net.neoforged.neoforge.client.event.ClientTickEvent.Pre event) Tick the Extended Inventory, client side.voidonScreenClosing(net.neoforged.neoforge.client.event.ScreenEvent.Closing event) Upon closing a Screen, forget which Screen should have extra Slots rendered for it.voidonScreenInitPost(net.neoforged.neoforge.client.event.ScreenEvent.Init.Post event) Before opening a Screen, add the additional Slots (if they are not already added).voidonScreenRenderPre(net.neoforged.neoforge.client.event.ScreenEvent.Render.Pre event) Render the "window" backgrounds and Slot backgrounds of Extended Inventory Slots.static voidRefresh the locations of the Extended Inventory Slots in the Survival Inventory only.voidRefresh the locations of the "windows" for the Extended Inventory Slots on thecurrent Screen.static voidrenderExtraHotbar(net.minecraft.client.gui.GuiGraphics graphics, net.minecraft.client.DeltaTracker deltaTracker) Render the Slot icons and actual Items in the Extended Inventory Hotbar Slots.static voidrenderExtraHotbarBackground(net.minecraft.client.gui.GuiGraphics graphics, net.minecraft.client.DeltaTracker deltaTracker) Render the borders for the Extended Inventory Slots on the Hotbar.
-
Field Details
-
INVENTORY_PADDING
public static final int INVENTORY_PADDINGThe space between the edge of the Extended Inventory "window" and the actual Slot.- See Also:
-
INVENTORY_SPACING
public static final int INVENTORY_SPACINGThe space between the regular Inventory "window" and any Extended Inventory "window".- See Also:
-
INVENTORY_HOTBAR_SPACING
public static final int INVENTORY_HOTBAR_SPACINGThe vertical space between the main Inventory and Hotbar Slots.- See Also:
-
currentScreen
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen<?> currentScreenThe Screen currently being rendered with extra Slots, ornullif 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 settingsof the Extended Inventory has been changed in the configs - Consumes Hotbar key presses
- Parameters:
event-
- Checks to see if the
-
refreshClientInventoryMenu
Refresh the locations of the Extended Inventory Slots in the Survival Inventory only.- Parameters:
inv- The Player's Extended Inventory
-
handleExtendedInventorySizeChange
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:
trueon left,falseon 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:
nullif 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:
nullif 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:
nullif 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:
nullif 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
Refresh the locations of the "windows" for the Extended Inventory Slots on thecurrent 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 withExtendedInventory.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 withExtendedInventory.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
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.
-