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, 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.resources.ResourceKey
<net.minecraft.core.Registry<IPocketUpgrade>> -
Method Summary
Modifier and TypeMethodDescription@Nullable IPeripheral
createPeripheral
(IPocketAccess access) Creates a peripheral for the pocket computer.UpgradeType
<? extends IPocketUpgrade> getType()
Get the type of this upgrade.default boolean
onRightClick
(net.minecraft.world.level.Level world, IPocketAccess access, @Nullable IPeripheral peripheral) Called when the pocket computer is right clicked.static net.minecraft.resources.ResourceKey
<net.minecraft.core.Registry<UpgradeType<? extends IPocketUpgrade>>> The registry key for pocket upgrade types.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
getAdjective, getCraftingItem, getUpgradeData, getUpgradeItem, isItemSuitable
-
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 interfaceUpgradeBase
- Returns:
- The type of this upgrade.
-
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:
-