Class ItemMenuHost<T extends net.minecraft.world.item.Item>

java.lang.Object
appeng.api.implementations.menuobjects.ItemMenuHost<T>
All Implemented Interfaces:
IUpgradeableObject

public class ItemMenuHost<T extends net.minecraft.world.item.Item> extends Object implements IUpgradeableObject
Base interface for an adapter that connects an item stack in a player inventory with a menu that is opened by it.
  • Constructor Details

    • ItemMenuHost

      public ItemMenuHost(T item, net.minecraft.world.entity.player.Player player, appeng.menu.locator.ItemMenuHostLocator locator)
  • Method Details

    • getPlayer

      public net.minecraft.world.entity.player.Player getPlayer()
      Returns:
      The player holding the item.
    • getPlayerInventorySlot

      @Nullable public @Nullable Integer getPlayerInventorySlot()
      Returns:
      The index of the item hosting the menu in the players inventory. Null if the item is not directly accessible via the inventory.
    • getLocator

      @Nullable public @Nullable appeng.menu.locator.ItemMenuHostLocator getLocator()
    • getItem

      public T getItem()
    • getItemStack

      public net.minecraft.world.item.ItemStack getItemStack()
      Returns:
      The item stack hosting the menu. This can change.
    • isClientSide

      public boolean isClientSide()
      Returns:
      True if this host is on the client-side.
    • onBroadcastChanges

      public boolean onBroadcastChanges(net.minecraft.world.inventory.AbstractContainerMenu menu)
      Gives the item hosting the GUI a chance to do periodic actions when the menu is being ticked.
      Returns:
      False to close the menu.
    • ensureItemStillInSlot

      protected boolean ensureItemStillInSlot()
      Ensures that the item this menu was opened from has not changed.
    • drainPower

      public void drainPower()
      Can only be used with a host that implements IEnergySource only call once per broadcastChanges()
    • getPowerDrainPerTick

      protected double getPowerDrainPerTick()
      Get power drain per tick.
    • isOutOfPower

      public final boolean isOutOfPower()
    • getUpgrades

      public final IUpgradeInventory getUpgrades()
      Description copied from interface: IUpgradeableObject
      Gets the inventory that contains the upgrade cards for this upgradable object.
      Specified by:
      getUpgrades in interface IUpgradeableObject