Class InventoryTracker

java.lang.Object
me.agent.vgui.core.internal.InventoryTracker

public final class InventoryTracker extends Object
Caches each player's backend-owned inventory by observing window-0 packets. Every backend connection has a generation: switching invalidates the old cache, packets captured for an older generation are rejected, and SET_SLOT updates are ignored until the new backend supplies a complete WINDOW_ITEMS baseline.

Window 0 layout: 0 = craft result, 1-4 = craft grid, 5-8 = armor, 9-35 = main inventory, 36-44 = hotbar, 45 = offhand.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Marks the latest backend generation connected and ready to accept a baseline.
    void
    Ends a failed connection attempt without reviving the invalidated old cache.
    long
    Invalidates the current cache before a backend connection attempt.
    void
    Drops every cached player, used when the owning bootstrap shuts down.
    void
    evict(UUID uuid)
    Drops all connection and inventory state for a disconnected player.
    long
    Current backend generation, captured by packet listeners before an update.
    boolean
    Whether a backend transition is in progress; proxy views should not open yet.
    com.github.retrooper.packetevents.protocol.item.ItemStack[]
    The 36 main-inventory + hotbar items in container-window order.
    void
    setSlot(UUID uuid, int slot, com.github.retrooper.packetevents.protocol.item.ItemStack item)
    Records a single window-0 slot update for the current generation.
    void
    setSlot(UUID uuid, long generation, int slot, com.github.retrooper.packetevents.protocol.item.ItemStack item)
    Records a slot update only for a live generation with a full baseline.
    void
    windowItems(UUID uuid, long generation, List<com.github.retrooper.packetevents.protocol.item.ItemStack> items)
    Records a full window-0 packet only if its captured generation is still live.
    void
    windowItems(UUID uuid, List<com.github.retrooper.packetevents.protocol.item.ItemStack> items)
    Records a full window-0 contents packet for the current generation.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InventoryTracker

      public InventoryTracker()
  • Method Details

    • beginBackendSwitch

      public long beginBackendSwitch(UUID uuid)
      Invalidates the current cache before a backend connection attempt.
    • backendConnected

      public long backendConnected(UUID uuid)
      Marks the latest backend generation connected and ready to accept a baseline.
    • backendSwitchAborted

      public void backendSwitchAborted(UUID uuid)
      Ends a failed connection attempt without reviving the invalidated old cache.
    • generation

      public long generation(UUID uuid)
      Current backend generation, captured by packet listeners before an update.
    • isSwitching

      public boolean isSwitching(UUID uuid)
      Whether a backend transition is in progress; proxy views should not open yet.
    • windowItems

      public void windowItems(UUID uuid, List<com.github.retrooper.packetevents.protocol.item.ItemStack> items)
      Records a full window-0 contents packet for the current generation.
    • windowItems

      public void windowItems(UUID uuid, long generation, List<com.github.retrooper.packetevents.protocol.item.ItemStack> items)
      Records a full window-0 packet only if its captured generation is still live.
    • setSlot

      public void setSlot(UUID uuid, int slot, com.github.retrooper.packetevents.protocol.item.ItemStack item)
      Records a single window-0 slot update for the current generation.
    • setSlot

      public void setSlot(UUID uuid, long generation, int slot, com.github.retrooper.packetevents.protocol.item.ItemStack item)
      Records a slot update only for a live generation with a full baseline. This prevents late old-backend deltas from seeding a newly connected cache.
    • mainAndHotbar

      public com.github.retrooper.packetevents.protocol.item.ItemStack[] mainAndHotbar(UUID uuid)
      The 36 main-inventory + hotbar items in container-window order. An empty snapshot is returned until the current backend provides a complete baseline.
    • evict

      public void evict(UUID uuid)
      Drops all connection and inventory state for a disconnected player.
    • clear

      public void clear()
      Drops every cached player, used when the owning bootstrap shuts down.