Class ItemMenuHost
java.lang.Object
appeng.api.implementations.menuobjects.ItemMenuHost
- All Implemented Interfaces:
IUpgradeableObject
Base interface for an adapter that connects an item stack in a player inventory with a menu that is opened by it.
-
Constructor Summary
ConstructorsConstructorDescriptionItemMenuHost(net.minecraft.world.entity.player.Player player, @Nullable Integer slot, net.minecraft.world.item.ItemStack itemStack) -
Method Summary
Modifier and TypeMethodDescriptionbooleanCan only be used with a host that implementsIEnergySourceonly call once per broadcastChanges()protected booleanEnsures that the item stack hosting the menu is still in the expected player inventory slot.net.minecraft.world.item.ItemStacknet.minecraft.world.entity.player.Player@Nullable IntegergetSlot()final IUpgradeInventoryGets the inventory that contains the upgrade cards for this upgradable object.booleanbooleanonBroadcastChanges(net.minecraft.world.inventory.AbstractContainerMenu menu) Gives the item hosting the GUI a chance to do periodic actions when the menu is being ticked.protected voidsetPowerDrainPerTick(double powerDrainPerTick) Sets how much AE is drained per tick.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface appeng.api.upgrades.IUpgradeableObject
getInstalledUpgrades, isUpgradedWith
-
Constructor Details
-
ItemMenuHost
public ItemMenuHost(net.minecraft.world.entity.player.Player player, @Nullable @Nullable Integer slot, net.minecraft.world.item.ItemStack itemStack)
-
-
Method Details
-
getPlayer
public net.minecraft.world.entity.player.Player getPlayer()- Returns:
- The player holding the item.
-
getSlot
- Returns:
- The index of the item hosting the menu in the
playersinventory. Null if the item is not directly accessible via the inventory.
-
getItemStack
public net.minecraft.world.item.ItemStack getItemStack()- Returns:
- The item stack hosting the menu.
-
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 stack hosting the menu is still in the expected player inventory slot. If necessary, referential equality is restored by overwriting the item in the player inventory if it is equal to the expected item.- Returns:
- True if
getItemStack()is still in the expected slot.
-
drainPower
public boolean drainPower()Can only be used with a host that implementsIEnergySourceonly call once per broadcastChanges() -
setPowerDrainPerTick
protected void setPowerDrainPerTick(double powerDrainPerTick) Sets how much AE is drained per tick. -
getUpgrades
Description copied from interface:IUpgradeableObjectGets the inventory that contains the upgrade cards for this upgradable object.- Specified by:
getUpgradesin interfaceIUpgradeableObject
-