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:
trueAfter calling playSound(), it returns:
falseExample output:
Before Sound: true
After Sound: falseThe Player object becoming non-extensible prevents scripts from adding new properties to the object afterward. For example:
player.myCustomProperty = truecan then throw:
TypeError: object is not extensibleThis 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
Create a behavior pack using
@minecraft/server.Subscribe to
world.afterEvents.worldLoad.Get a player using
world.getAllPlayers().Check
Object.isExtensible(player).Call
player.playSound("test").Check
Object.isExtensible(player)again.Observe that the result changes from
truetofalse.
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.
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