Mojira Archive
MCM-1909

[Scripting] Native Minecraft class properties no longer accessible as properties

Partner Rank
Important (2)

Partner Team Reporting
Logdotzip

Verification Builds
Client: 1.21.70.20_RC1 UWP_x86_Win10
(Note: This was tested on the x86 client as x64 is not available.)
Scripting: @minecraft/server: 1.16.0
Beta API: OFF

Summary
We received a bug report for Telelanterns from a player playing in the 1.21.70 Preview version of the client. It appeared that, when when trying to serialize the Waypoint's dimension into a dynamic property, an empty object now appeared in its place. This caused our script to fail when trying to load the data.

Tracing the issue higher, we realized that properties of Minecraft native classes, like mc.Entity & mc.Dimension, no longer store their properties, like `entity.typeId` or `dimension.id` respectively, on the class object itself anymore. However, they are still accessible directly. We suspect they have been changed to getters or direct calls to the engine.

This affects operations such as:

  • `JSON.stringify(dimension)`
  • `const spread = { ...entity }`
  • `Object.keys(entity)`
  • `Object.values(entity)`
  • `Object.entries(entity)`

This change is nebulous in its real-world occurrences but there is no forewarning or pre-runtime errors, like Typescript, that occur to notify developers that this will happen. It is assumed that this is not version-locked changed to scripting either.

Impact
The Telelanterns Add-On has submitted a patch just to fix this issue for a bug report by a player in the Preview versions.
All content will require an internal re-review to check whether this non-version-locked issue affects them negatively. If such cases found in the summary are identified, I assume the fixes to be half a dozen lines or less.

Repro Steps:

  1. Download the attached Behavior Pack Add-On.
  2. Open up the Preview version of Minecraft.
  3. Attach the Behavior Pack to a new world.
  4. Run `/reload` when situated in-world.

Repro Rate
This issue occurs 100% of the time.

Observed Results
The operations over the properties of the native classes results in nullish data.

Expected Results
The operations over the properties of the native classes results in an object of keys and values, as observed in 1.21.60.28_RC0 & prior.
The mc.Player class (a subclass of mc.Entity) should serialize as`{"id":"<playerId>","typeId":"minecraft:player"}`.
The mc.Dimension class should serialize as `{"id":"minecraft:overworld"}`.

Attachments
Before (regression build) and After (affected build) screenshots.
Sample Behavior Pack to reproduce the issue.

Regression Builds
1.21.60.28_RC0 UWP_x64_Win10

Unresolved

Mihro

2025-02-06, 09:10 PM

2025-02-09, 03:56 AM

0

0

server

Future Release

-