mojira.dev
MCPE-66389

getBlock() from scripting API fails unexpectedly

Attempted to call getBlock() for coordinates that reside within a ticking area in a single-player world.

Expected: getBlock() returns a Block object.

Actual: "Script Error: Something went wrong..."

Repro steps:

  • Create a behavior pack with the attached file as a server script

  • Create a circular ticking area named "mytickingarea" at 0 65 0 with a radius of 1 (seems to happen for any ticking area, actually, but this is what I did)

  • Teleport to 0 65 0 in survival mode (create a pillar if necessary)

  • Start destroying the block you're standing on

  • The script error will display

Β 

Β 

Attachments

Comments 9

Also I can add, that the same method with entity ticking area is working fine. The bug also happens on version 1.16.0.57.

Also executing getBlock({}, 0, 0, 0) crashes Minecraft completely.

I'm having the same issue, cannot get block from within a ticking area, it throws either using coordinates or blockPosition Object

[media]

yeah I am having a similar problem where the obj getblock returns is null I upvoted hop it gets fixed soon

Thank you for your report!
However, this issue has been temporarily resolved as Awaiting Response

Is this still an issue in the latest version?

If it is, please be sure to include steps to reproduce the problem:

Steps to Reproduce:
1.
2.
3.

Observed Results:
(Briefly describe what happens)

Expected Results:
(Briefly describe what should happen)

If your ticket does not look like the example given here, then it's likely to be closed as incomplete.

This ticket will automatically reopen when you reply.

Quick Links:
πŸ““ Issue Guidelines – πŸ’¬ Mojang Support – πŸ“§ Suggestions – πŸ“– Minecraft Wiki

I am also witnessing this issue, in v1.16.40.

Steps to Reproduce:

  1. Create a behaviour pack with a server side script:
    {{}}

    let serverSystem = server.registerSystem(0, 0);
    
    serverSystem.debug = function (msg) {
        let BroadcastEventData = serverSystem.createEventData("minecraft:display_chat_event");
        BroadcastEventData.data.message = msg;
        serverSystem.broadcastEvent("minecraft:display_chat_event", BroadcastEventData);    
    };
    
    serverSystem.initialize = function() {
        serverSystem.listenForEvent("minecraft:block_interacted_with", (eventData) => serverSystem.checkBlock(eventData));
    };
    
    serverSystem.checkBlock = function (eventData) {
        const { block_position } = eventData.data;
        const { x, y, z } = block_position;
        const tickingArea = this.getTickingArea();
        const block = this.getBlock(tickingArea, x, y, z);
        serverSystem.debug(JSON.stringify(block));
    };
    
    serverSystem.getTickingArea = function () {
        let tickingAreas = this.getComponent(server.level, 'minecraft:ticking_areas');
        return tickingAreas.data['custom'];
    };
  1. Install your behaviour pack

  2. Create a Creative world with experimental gameplay and cheats turned on.

  3. Enable your behaviour pack on your newly-created world

  4. Enter the world

  5. Create a ticking area:

    /tickingarea add circle ~ ~ ~ 1 custom
  1. Add a button of any kind to the ground immediately in front of you

  2. Interact with the button

Observed Results:

The text

<ServerScript> null

appears in the chat log.

Expected Results:

**A JSON representation of the block's properties should appear in the chat log.

Same issue here!

getBlock() returns null inΒ Minecraft Win10 ver.1.16.221

Issue is present in 1.17.10.21 as well exact same error message

update: I have found a workaround, by grabbing the players ticking area instead which is usually preferred anyways.

Β 

const world = this.getComponent(eventData.data.player, "minecraft:tick_world"); this.log(this.getBlock(world.data.ticking_area, x, y, z));

Thank you for your report!
After consideration, the issue is being closed as Won't Fix.

Please note that this is not the same as Working as Intended, as this bug report correctly describes behavior in the game that might not be the intended or desirable behavior, but it will not be fixed right now. Sometimes, this is because the issue reported is minor and/or impossible to change without large architectural changes to the code base.

Quick Links:
πŸ““ Bug Tracker Guidelines – πŸ’¬ Community Support – πŸ“§ Mojang Support (Technical Issues) – πŸ“§ Microsoft Support (Account Issues)
πŸ““ Project Summary – ✍️ Feedback and Suggestions – πŸ“– Game Wiki

Tim Winchester

(Unassigned)

436138

Confirmed

Windows

Windwos 10 Pro v.1903 Build 18362.657

scripting-api

1.17.10.21 Beta, 1.14.30 Hotfix, 1.16.40 Hotfix, 1.16.221 Hotfix

Retrieved