mojira.dev
MCPE-237183

cannot read world dynamicProperties in blockComponentRegistry.registerCustomComponent()

Steps to reproduce

  1. make sure “enable content log GUI” & “show content log GUI on error during load” are enabled

  2. import the world in zip

  3. enter the world and wait for seconds

  4. you may see the console.log and error on the screen

What happened

The error content said “unexpected token at main.js:15”. Let’s turn to main.js:

import { system, world } from "@minecraft/server";

system.beforeEvents.startup.subscribe(ini => {
  ini.blockComponentRegistry.registerCustomComponent("gm:structure_spawner", {onTick: (t, p) => {
    system.run(()=>{
      let block = t.block
      let loc = block.location
      let mode = p.params["spawn_type"]
      let playersInRange = t.dimension.getEntities({location: loc, maxDistance: 16, type: "minecraft:player"})
      if (block.permutation.getState("gm:file_name") !== "empty") {
        if (playersInRange.length > 0) {
          t.dimension.spawnParticle("minecraft:basic_flame_particle", loc)
          t.dimension.spawnParticle("minecraft:basic_smoke_particle", loc)
          console.log(world.getDynamicProperty(block.permutation.getState("gm:file_name")),block.permutation.getState("gm:file_name"),1,world.getDynamicPropertyIds(),1)
          let pool = JSON.parse(world.getDynamicProperty(block.permutation.getState("gm:file_name")))

In the console.log, we got “undefined sp:slot1 1 1”. An array of world dynamicPropertyIds should be displayed between the two “1”. However, it’s blank, which means no dynamicPropertyId is returned. But in the world, we have dynamicproperties “sp:slot1”, “sp:slot2” and ”cmd:has_prime”.

As for the lost packs in the world, I’ll provide them in another file, the lost packs didn’t cause the issue.

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media][media][media]

mingwangdada

(Unassigned)

Unconfirmed

Multiple

26.3

Retrieved