JSPrismarine
    Preparing search index...

    Class PlayerInternal

    Represents a Player entity.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    attributes: Attributes = ...

    Entity attributes.

    chunkSendQueue: Set<Chunk> = ...
    device: null | Device = null
    gamemode: Gametype = Gametype.WORLD_DEFAULT
    headYaw: number
    inventory: HumanInventory = ...
    locale: string = ''
    metadata: Metadata = ...

    Entity metadata.

    pitch: number
    platformChatId: string = ''
    randomId: number = 0
    runtimeId: bigint
    server: Server
    skin: null | Skin = null
    uuid: string
    viewDistance: number = 0
    x: number = 0

    The X coordinate.

    xuid: string = ''
    y: number

    The Y coordinate.

    yaw: number
    z: number = 0

    The Z coordinate.

    MOB_ID: string = 'minecraft:player'

    The entity's namespace ID.

    runtimeIdCount: bigint = 0n

    The global runtime id counter.

    Accessors

    Methods

    • Get the entity's formatted name.

      Returns string

      The entity's formatted name (including prefix & suffix).

      const formattedName = entity.getFormattedUsername();
      console.log(`Entity formatted name: ${formattedName}`); // Entity formatted name: Sheep
    • Get the entity's (potentially custom) name.

      Returns string

      The entity's name without formatting (usually prefix & suffix).

      const name = entity.getName();
      console.log(`Entity name: ${name}`);
    • Check if the entity is a console instance.

      Returns boolean

      true if the entity is console-controlled, otherwise false.

      if (entity.isConsole()) {
      console.log('Entity is a console');
      } else {
      console.log('Entity is not a console');
      }
    • Check if the entity is a player.

      Returns boolean

      true if the entity is player-controlled, otherwise false.

      if (entity.isPlayer()) {
      console.log('Entity is a player');
      } else {
      console.log('Entity is not a player');
      }
    • Used to match vanilla behavior, will send chunks with an initial view radius of VANILLA_DEFAULT_SPAWN_RADIUS.

      Returns Promise<void>

    • Send a chat message to the client.

      Parameters

      • message: string

        the message

      • type: TextType = TextType.Raw
      • parameters: string[] = []
      • needsTranslation: boolean = false

      Returns Promise<void>

    • Set the position.

      Parameters

      • options: {
            headYaw?: number;
            pitch?: number;
            position: Vector3;
            type?: MovementType;
            yaw?: number;
        }

        The options to set the position.

        • OptionalheadYaw?: number

          The new head yaw.

        • Optionalpitch?: number

          The new pitch.

        • position: Vector3

          The new position.

        • Optionaltype?: MovementType

          The movement type.

        • Optionalyaw?: number

          The new yaw.

      • Optionalbroadcast: boolean = true

        Whether to broadcast the position change.

      Returns Promise<void>

      This will notify the player's client about the position change.

    • Set the x position.

      Parameters

      • x: number

        The x coordinate.

      • Optionalsuppress: boolean = false

        If true, the client won't be notified about the position change.

      Returns Promise<void>

      A promise that resolves when the x position is set.

      await entity.setX(10);
      

      This method will also send the position update to the client if suppress is false.

    • Set the y position.

      Parameters

      • y: number

        The y coordinate.

      • Optionalsuppress: boolean = false

        If true, the client won't be notified about the position change.

      Returns Promise<void>

      A promise that resolves when the y position is set.

      await entity.setY(10);
      

      This method will also send the position update to the client if suppress is false.

    • Set the z position.

      Parameters

      • z: number

        The z coordinate.

      • Optionalsuppress: boolean = false

        If true, the client won't be notified about the position change.

      Returns Promise<void>

      A promise that resolves when the z position is set.

      await entity.setZ(10);
      

      This method will also send the position update to the client if suppress is false.

    • Fired every tick from the event subscription in the constructor.

      Parameters

      • tick: number

      Returns Promise<void>

      A promise that resolves when the update is complete.

      entity.update(10);
      
    • Creates a new Vector3 instance from an object with x, y, and z properties.

      Parameters

      • obj: { x: number; y: number; z: number }

        The object containing x, y, and z properties.

      Returns Vector3

      A new Vector3 instance.

    Lifecycle