Package dan200.computercraft.api.pocket
Interface IPocketUpgrade
- All Superinterfaces:
UpgradeBase
- All Known Implementing Classes:
AbstractPocketUpgrade
A peripheral which can be equipped to the back side of a pocket computer.
Pocket upgrades are defined in two stages. First, on creates a IPocketUpgrade
subclass and corresponding
PocketUpgradeSerialiser
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.
-
Method Summary
Modifier and TypeMethodDescription@Nullable IPeripheral
createPeripheral
(IPocketAccess access) Creates a peripheral for the pocket computer.default boolean
onRightClick
(net.minecraft.world.level.Level world, IPocketAccess access, @Nullable IPeripheral peripheral) Called when the pocket computer is right clicked.default void
update
(IPocketAccess access, @Nullable IPeripheral peripheral) Called when the pocket computer item stack updates.Methods inherited from interface dan200.computercraft.api.upgrades.UpgradeBase
getCraftingItem, getUnlocalisedAdjective, getUpgradeData, getUpgradeID, getUpgradeItem, isItemSuitable
-
Method Details
-
createPeripheral
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
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 returnsfalse
, such as requiring the player to be sneaking - otherwise they will be unable to access the GUI.- See Also:
-