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.core.component.DataComponentPatch
Get the upgrade-specific NBT.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
setUpgradeData
(net.minecraft.core.component.DataComponentPatch data) Update the upgrade-specific data.
-
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:
-
getUpgradeData
net.minecraft.core.component.DataComponentPatch getUpgradeData()Get the upgrade-specific NBT.This is persisted between computer reboots and chunk loads.
- Returns:
- The upgrade's NBT.
- See Also:
-
setUpgradeData
void setUpgradeData(net.minecraft.core.component.DataComponentPatch data) Update the upgrade-specific data.- Parameters:
data
- The new upgrade data.- 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.
-