Interface IPocketUpgrade

All Superinterfaces:
UpgradeBase
All Known Implementing Classes:
AbstractPocketUpgrade

public interface IPocketUpgrade extends UpgradeBase
A peripheral which can be equipped to the back side of a pocket computer.

Pocket upgrades are defined in two stages. First, one creates a IPocketUpgrade subclass and corresponding UpgradeType instance, which are then registered in a Minecraft registry.

You then write a JSON file in your mod's data/ folder. This is then parsed when the world is loaded, and the upgrade registered internally.

  • Field Details

    • REGISTRY

      static final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<IPocketUpgrade>> REGISTRY
  • Method Details

    • typeRegistry

      static net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<UpgradeType<? extends IPocketUpgrade>>> typeRegistry()
      The registry key for pocket upgrade types.
      Returns:
      The registry key.
    • getType

      UpgradeType<? extends IPocketUpgrade> getType()
      Get the type of this upgrade.
      Specified by:
      getType in interface UpgradeBase
      Returns:
      The type of this upgrade.
    • createPeripheral

      @Nullable IPeripheral createPeripheral(IPocketAccess access)
      Creates a peripheral for the pocket computer.

      The peripheral created will be stored for the lifetime of the upgrade, will be passed an argument to update(IPocketAccess, IPeripheral) and will be attached, detached and have methods called in the same manner as an ordinary peripheral.

      Parameters:
      access - The access object for the pocket item stack.
      Returns:
      The newly created peripheral.
      See Also:
    • update

      default void update(IPocketAccess access, @Nullable IPeripheral peripheral)
      Called when the pocket computer item stack updates.
      Parameters:
      access - The access object for the pocket item stack.
      peripheral - The peripheral for this upgrade.
      See Also:
    • onRightClick

      default boolean onRightClick(net.minecraft.world.level.Level world, IPocketAccess access, @Nullable IPeripheral peripheral)
      Called when the pocket computer is right clicked.
      Parameters:
      world - The world the computer is in.
      access - The access object for the pocket item stack.
      peripheral - The peripheral for this upgrade.
      Returns:
      true to stop the GUI from opening, otherwise false. You should always provide some code path which returns false, such as requiring the player to be sneaking - otherwise they will be unable to access the GUI.
      See Also: