Package dan200.computercraft.api.pocket
Interface IPocketAccess
@NonExtendable
public interface IPocketAccess
Wrapper class for pocket computers.
-
Method Summary
Modifier and TypeMethodDescriptionint
Get the colour of this pocket computer as a RGB number.@Nullable net.minecraft.world.entity.Entity
Gets the entity holding this item.net.minecraft.server.level.ServerLevel
getLevel()
Get the level in which the pocket computer exists.int
getLight()
Get the colour of this pocket computer's light as a RGB number.net.minecraft.world.phys.Vec3
Get the position of the pocket computer.@Nullable UpgradeData<IPocketUpgrade>
Get the currently equipped upgrade.net.minecraft.nbt.CompoundTag
Get the upgrade-specific NBT.Map<net.minecraft.resources.ResourceLocation,
IPeripheral> Deprecated, for removal: This API element is subject to removal in a future version.This is a relic of a previous API, which no longer makes sense with newer versions of ComputerCraft.void
Remove the current peripheral and create a new one.void
setColour
(int colour) Set the colour of the pocket computer to a RGB number.void
setLight
(int colour) Set the colour of the pocket computer's light to a RGB number.void
setUpgrade
(@Nullable UpgradeData<IPocketUpgrade> upgrade) Set the upgrade for this pocket computer, also updating the item stack.void
Mark the upgrade-specific NBT as dirty.
-
Method Details
-
getLevel
net.minecraft.server.level.ServerLevel getLevel()Get the level in which the pocket computer exists.- Returns:
- The pocket computer's level.
-
getPosition
net.minecraft.world.phys.Vec3 getPosition()Get the position of the pocket computer.- Returns:
- The pocket computer's position.
-
getEntity
@Nullable net.minecraft.world.entity.Entity getEntity()Gets the entity holding this item.This must be called on the server thread.
- Returns:
- The holding entity, or
null
if none exists.
-
getColour
int getColour()Get the colour of this pocket computer as a RGB number.- Returns:
- The colour this pocket computer is. This will be a RGB colour between
0x000000
and0xFFFFFF
or -1 if it has no colour. - See Also:
-
setColour
void setColour(int colour) Set the colour of the pocket computer to a RGB number.- Parameters:
colour
- The colour this pocket computer should be changed to. This should be a RGB colour between0x000000
and0xFFFFFF
or -1 to reset to the default colour.- See Also:
-
getLight
int getLight()Get the colour of this pocket computer's light as a RGB number.- Returns:
- The colour this light is. This will be a RGB colour between
0x000000
and0xFFFFFF
or -1 if it has no colour. - See Also:
-
setLight
void setLight(int colour) Set the colour of the pocket computer's light to a RGB number.- Parameters:
colour
- The colour this modem's light will be changed to. This should be a RGB colour between0x000000
and0xFFFFFF
or -1 to reset to the default colour.- See Also:
-
getUpgrade
@Nullable UpgradeData<IPocketUpgrade> getUpgrade()Get the currently equipped upgrade.- Returns:
- The currently equipped upgrade.
- See Also:
-
setUpgrade
Set the upgrade for this pocket computer, also updating the item stack.Note this method is not thread safe - it must be called from the server thread.
- Parameters:
upgrade
- The new upgrade to set it to, may benull
.- See Also:
-
getUpgradeNBTData
net.minecraft.nbt.CompoundTag getUpgradeNBTData()Get the upgrade-specific NBT.This is persisted between computer reboots and chunk loads.
- Returns:
- The upgrade's NBT.
- See Also:
-
updateUpgradeNBTData
void updateUpgradeNBTData()Mark the upgrade-specific NBT as dirty.- See Also:
-
invalidatePeripheral
void invalidatePeripheral()Remove the current peripheral and create a new one.You may wish to do this if the methods available change, for instance when the owning entity changes.
-
getUpgrades
@Deprecated(forRemoval=true) Map<net.minecraft.resources.ResourceLocation,IPeripheral> getUpgrades()Deprecated, for removal: This API element is subject to removal in a future version.This is a relic of a previous API, which no longer makes sense with newer versions of ComputerCraft.Get a list of all upgrades for the pocket computer.- Returns:
- A collection of all upgrade names.
-