user
User
¶
Bases: Player
Enhanced Minecraft Player class with utility methods
Note
Use hasattr to check for attribute availability before accessing them,
as some attributes may not always be present.
| ATTRIBUTE | DESCRIPTION |
|---|---|
username |
The player's username.
TYPE:
|
gamemode |
Current gamemode ID (0: survival, 1: creative, 2: adventure, 3: spectator).
TYPE:
|
dimension |
Current dimension ID (-1: nether, 0: overworld, 1: end).
TYPE:
|
health |
Player's current health points.
TYPE:
|
food |
Player's current food (hunger) level.
TYPE:
|
food_saturation |
Player's current food saturation level.
TYPE:
|
level |
Player's experience level.
TYPE:
|
total_experience |
Total accumulated experience points.
TYPE:
|
experience_bar |
Progress on the experience bar (0.0 to 1.0).
TYPE:
|
held_slot |
Index of the currently held inventory slot.
TYPE:
|
spawn_point |
Player's current spawn point coordinates. |
invulnerable |
Whether the player is invulnerable.
TYPE:
|
flying |
Whether the player is currently flying.
TYPE:
|
allow_flying |
Whether the player is allowed to fly.
TYPE:
|
creative_mode |
Whether the player is in creative mode.
TYPE:
|
flying_speed |
The player's flying speed multiplier.
TYPE:
|
fov_modifier |
Field of view modifier affecting the player's view.
TYPE:
|
air
property
¶
air: int
Remaining air ticks.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Number of air ticks remaining before drowning |
custom_name
property
¶
is_custom_name_visible
property
¶
is_custom_name_visible: bool
Whether custom name is visible above entity.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if custom name should be displayed above the entity |
is_silent
property
¶
is_silent: bool
Whether entity makes sounds.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity is silent and won't produce sounds |
no_gravity
property
¶
no_gravity: bool
Whether entity is affected by gravity.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity ignores gravity effects |
max_health
property
¶
max_health: float
Maximum health attribute value.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Maximum health points for this entity |
movement_speed
property
¶
movement_speed: float
Movement speed attribute value.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Movement speed multiplier for this entity |
armor
property
¶
armor: float
Armor attribute value.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Armor points providing damage reduction |
attack_speed
property
¶
attack_speed: float
Attack speed attribute value.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Attack speed multiplier for this entity |
on_fire
property
¶
on_fire: bool
Whether entity is on fire (bit 0).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity is currently on fire |
crouched
property
¶
crouched: bool
Whether entity is crouching (bit 1).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity is in crouching state |
sprinting
property
¶
sprinting: bool
Whether entity is sprinting (bit 3).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity is currently sprinting |
invisible
property
¶
invisible: bool
Whether entity is invisible (bit 5).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity has invisibility effect active |
glowing
property
¶
glowing: bool
Whether entity is glowing (bit 6).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity has glowing outline effect |
flying_with_elytra
property
¶
flying_with_elytra: bool
Whether entity is flying with elytra (bit 7).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity is gliding with elytra wings |
equipment
property
¶
has_equipment
property
¶
has_equipment: bool
Check if the entity has any equipment.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity has equipment, False otherwise. |
hand_states
property
¶
hand_states: int
Hand state bit mask.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Bit mask containing hand usage states |
potion_effect_color
property
¶
potion_effect_color: int
Potion effect particle color.
| RETURNS | DESCRIPTION |
|---|---|
int
|
RGB color value for potion effect particles |
is_potion_effect_ambient
property
¶
is_potion_effect_ambient: bool
Whether potion effect is ambient.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if potion effect particles are ambient (less visible) |
arrows_in_entity
property
¶
arrows_in_entity: int
Number of arrows stuck in entity.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Count of arrows visually stuck in the entity |
is_hand_active
property
¶
is_hand_active: bool
Whether hand is active (using item).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if entity is currently using an item with their hand |
active_hand
property
¶
active_hand: int
Which hand is active (0=main, 1=off).
| RETURNS | DESCRIPTION |
|---|---|
int
|
Hand index: 0 for main hand, 1 for off-hand |
info
property
¶
info: Optional[tab.PlayerInfo]
Get additional player information from the server's tab list.
| RETURNS | DESCRIPTION |
|---|---|
Optional[tab.TabPlayer]
|
The player's tab list entry if they are currently online and visible in the tab list, None otherwise. |
additional_hearts
property
¶
additional_hearts: float
Additional hearts.
| RETURNS | DESCRIPTION |
|---|---|
float
|
The number of additional hearts the player has. |
displayed_skin_parts
property
¶
displayed_skin_parts: int
Displayed skin parts bit mask.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Bit mask representing which skin parts are displayed. |
main_hand
property
¶
main_hand: int
Main hand preference.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The main hand preference (0=left, 1=right). |
left_shoulder_entity
property
¶
right_shoulder_entity
property
¶
cape_enabled
property
¶
cape_enabled: bool
Whether cape is enabled (bit 0).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the cape is enabled, False otherwise. |
jacket_enabled
property
¶
jacket_enabled: bool
Whether jacket is enabled (bit 1).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the jacket is enabled, False otherwise. |
left_sleeve_enabled
property
¶
left_sleeve_enabled: bool
Whether left sleeve is enabled (bit 2).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the left sleeve is enabled, False otherwise. |
right_sleeve_enabled
property
¶
right_sleeve_enabled: bool
Whether right sleeve is enabled (bit 3).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the right sleeve is enabled, False otherwise. |
left_pants_leg_enabled
property
¶
left_pants_leg_enabled: bool
Whether left pants leg is enabled (bit 4).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the left pants leg is enabled, False otherwise. |
right_pants_leg_enabled
property
¶
right_pants_leg_enabled: bool
Whether right pants leg is enabled (bit 5).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the right pants leg is enabled, False otherwise. |
hat_enabled
property
¶
hat_enabled: bool
Whether hat is enabled (bit 6).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the hat is enabled, False otherwise. |
is_left_handed
property
¶
is_left_handed: bool
Whether player is left-handed (main hand = 0).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the player is left-handed, False otherwise. |
is_right_handed
property
¶
is_right_handed: bool
Whether player is right-handed (main hand = 1).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the player is right-handed, False otherwise. |
has_left_shoulder_parrot
property
¶
has_left_shoulder_parrot: bool
Whether player has a parrot on left shoulder.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if there's an entity on the left shoulder, False otherwise. |
has_right_shoulder_parrot
property
¶
has_right_shoulder_parrot: bool
Whether player has a parrot on right shoulder.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if there's an entity on the right shoulder, False otherwise. |
translate
async
¶
translate(
position: Optional[Vector3D[float]] = None,
rotation: Optional[Rotation] = None,
on_ground: bool = True,
) -> None
Update the player's position and/or rotation.
| PARAMETER | DESCRIPTION |
|---|---|
position
|
The new position to set for the player. |
rotation
|
The new rotation to set for the player. |
on_ground
|
Whether the player is currently on the ground. When this changes from False to True, fall damage may be applied based on the distance fallen.
TYPE:
|
sneak
async
¶
sneak(state: bool = True) -> None
Perform sneaking action.
| PARAMETER | DESCRIPTION |
|---|---|
state
|
True to start sneaking, False to stop sneaking. Default is True.
TYPE:
|
sprint
async
¶
sprint(state: bool = True) -> None
Perform sprinting action.
| PARAMETER | DESCRIPTION |
|---|---|
state
|
True to start sprinting, False to stop sprinting. Default is True.
TYPE:
|
action
async
¶
action(action_id: Literal[2, 6, 7, 8]) -> None
Perform an entity action.
| PARAMETER | DESCRIPTION |
|---|---|
action_id
|
The ID of the action to perform. Valid values include: Text Only
TYPE:
|
jump_boost
|
Jump strength (0-100) used only with action_id 5.
TYPE:
|
interact_with
async
¶
interact_with(
entity: BaseEntity, hand: Literal[0, 1] = 0
) -> None
Perform a right-click interaction with an entity.
| PARAMETER | DESCRIPTION |
|---|---|
entity
|
The target entity.
TYPE:
|
hand
|
Hand used to interact (0 = main hand, 1 = off-hand).
TYPE:
|
attack
async
¶
attack(entity: BaseEntity) -> None
Perform a left-click attack on an entity.
| PARAMETER | DESCRIPTION |
|---|---|
entity
|
The target entity.
TYPE:
|
interact_at
async
¶
interact_at(
entity: BaseEntity,
hitbox: Vector3D[float],
hand: Literal[0, 1] = 0,
) -> None
Perform a precise interaction at a specific location on an entity.
| PARAMETER | DESCRIPTION |
|---|---|
entity
|
The target entity.
TYPE:
|
hitbox
|
The coordinates on the entity's hitbox. |
hand
|
Hand used to interact (0 = main hand, 1 = off-hand).
TYPE:
|
swing_arm
async
¶
swing_arm(hand: Literal[0, 1] = 0) -> None
Swing the player's arm.
| PARAMETER | DESCRIPTION |
|---|---|
hand
|
Hand to swing (0 = main hand, 1 = off-hand).
TYPE:
|
use_item
async
¶
use_item(hand: Literal[0, 1] = 0) -> None
Use the item in the specified hand.
This sends a Use Item packet to the server, which is triggered when right-clicking with an item. This can be used for: - Eating food - Drinking potions - Using tools (bow, fishing rod, etc.) - Placing blocks - Activating items
| PARAMETER | DESCRIPTION |
|---|---|
hand
|
Hand to use the item with (0 = main hand, 1 = off hand).
TYPE:
|
spectate_entity
async
¶
spectate_entity(target_uuid: str) -> None
Teleport to and spectate an entity.
This sends a Spectate packet to the server to teleport the player to the specified entity. The player must be in spectator mode for this to work. The entity can be in any dimension - if necessary, the player will be respawned in the correct world.
| PARAMETER | DESCRIPTION |
|---|---|
target_uuid
|
The UUID of the entity to teleport to and spectate. While commonly used for players, this can be any entity UUID. The packet will be ignored if the entity cannot be found, isn't loaded, or if the player attempts to teleport to themselves.
TYPE:
|
release_item_use
async
¶
Use the currently held item.
For example, shooting a bow, finishing eating, or using buckets.
start_digging
async
¶
cancel_digging
async
¶
finish_digging
async
¶
drop_item_stack
async
¶
Drop the entire item stack.
This corresponds to pressing the drop key with a modifier to drop the full stack. Position is set to (0, 0, 0) and face is set to down (0) as per protocol.
drop_item
async
¶
Drop a single item.
This corresponds to pressing the drop key without modifiers. Position is set to (0, 0, 0) and face is set to down (0) as per protocol.
swap_item_in_hand
async
¶
Swap item to the second hand.
Used to swap or assign an item to the offhand slot. Position is set to (0, 0, 0) and face is set to down (0) as per protocol.
toggle_flight
async
¶
Toggle flight mode on/off.
This automatically handles the flight state based on current abilities. Only works if the player has flight permissions (creative mode, etc.).
change_held_slot
async
¶
change_held_slot(slot: int) -> None
Change the selected hotbar slot.
| PARAMETER | DESCRIPTION |
|---|---|
slot
|
The hotbar slot to select (0-8).
TYPE:
|
interact_with_block
async
¶
interact_with_block(
position: Vector3D[int],
face: int,
hand: Literal[0, 1] = 0,
cursor: Vector3D[float] = None,
) -> None
Interact with a block (right-click action).
This function handles all types of block interactions including placing blocks, opening containers, activating mechanisms, using doors, and other right-click actions.
| PARAMETER | DESCRIPTION |
|---|---|
position
|
The position of the block to interact with. |
face
|
The face of the block being targeted.
TYPE:
|
hand
|
Hand to use for the interaction: - 0: main hand - 1: off-hand
TYPE:
|
cursor
|
The cursor position on the targeted face, with coordinates from 0.0 to 1.0. If not provided, defaults to center of the face (0.5, 0.5, 0.5). |
Notes
Behavior depends on your held item and the block. Examples: - Placing blocks
-
Opening containers (chests, furnaces)
-
Activating buttons, levers, redstone
-
Using tools on blocks
Ensure you have permission to interact with blocks or open containers.