mojira.dev
MCPE-241525

Player.playSound() makes the Player object non-extensible

Calling Player.playSound() causes the JavaScript Player object to become non-extensible.

This can be reproduced with the following minimal behavior pack script:

import { world } from "@minecraft/server"

world.afterEvents.worldLoad.subscribe(() => {
    const players = world.getAllPlayers()

    for (const player of players) {
        console.warn("Before Sound: ", Object.isExtensible(player))

        player.playSound("test")

        console.warn("After Sound: ", Object.isExtensible(player))
    }
})

Before calling playSound(), Object.isExtensible(player) returns:

true

After calling playSound(), it returns:

false

Example output:

Before Sound: true
After Sound: false

The Player object becoming non-extensible prevents scripts from adding new properties to the object afterward. For example:

player.myCustomProperty = true

can then throw:

TypeError: object is not extensible

This appears to happen specifically after calling player.playSound(). Other operations performed afterward do not appear to be responsible for the change.

Expected behavior

Calling Player.playSound() should not change the extensibility of the JavaScript Player object. Object.isExtensible(player) should remain true unless the script explicitly makes the object non-extensible.

Actual behavior

Player.playSound() changes the Player object from extensible to non-extensible.

Reproduction

  1. Create a behavior pack using @minecraft/server.

  2. Subscribe to world.afterEvents.worldLoad.

  3. Get a player using world.getAllPlayers().

  4. Check Object.isExtensible(player).

  5. Call player.playSound("test").

  6. Check Object.isExtensible(player) again.

  7. Observe that the result changes from true to false.

Impact

This can break scripts that attach custom properties to Player objects or define properties on them dynamically. The change is particularly problematic because the object becomes non-extensible as a side effect of an unrelated API call.

Linked issues

Comments 1

Las vallas de madera no se conectan correctamente.

Y también cuado sales y guardas el mundo apareces sin objetos y en una capa negativa entre bloques

momar3455

(Unassigned)

Unconfirmed

Windows

Windows 11

26.40

Retrieved