mojira.dev
MCPE-185196

Obscure script API crash regarding dimension-run commands

I found a very specific bug regarding the Minecraft Server-API (1.12.0-beta).

If the execute command is run on a dimension & the command run by the execute command fails THEN the game will crash.

Expected Behavior:

Command silently fails.

Observed Behavior:

Game crashes if: 1. Command run on a dimension 2. Command is an execute command 3. The chained command fails

All three criterea must be met for the game to crash as seen in my example video.

How to reproduce:

Run "dimension.runCommand(<cmd>)" in a script with any command that fulfills the crash condition. Command used in my example: "execute run give @a[hasitem={item=stick}] apple" (no target found, so the command failed).

Alternate way to reproduce:

Download the “MCPE-185196” mcaddon file, install it on a version of Minecraft that supports the 1.12.0-beta server API, enable it on a world with beta APIs, then click/use the brick item to crash the game. Look into the main.js file in the add-on & you will see all that it is doing is running the failing command on the dimension.

 

Workaround:

For anyone who needs a workaround, you can effectively run a command on a dimension without directly running with .runCommand method. You can do this by summoning an entity in the dimension, running the command on the entity, then removing the entity in the same tick. Here is what I use:

let dummy = Context.dimension.spawnEntity('minecraft:snowball', Context.location);
dummy.runCommand(cmd);
dummy.remove();

Attachments

Comments 7

Does this require an addon? I do not have a dimension command from what I can see
If it requires an addon, please attach it.

@Greymagic27 the crash can only occur when the command is run on a dimension, the add-on I am using in the video is only there to evaluate/run Javascript during run time for easier testing.

I have provided an alternate way to reproduce the crash & the addon you should use to do so.

@Greymagic27 the crash can only occur when the command is run on a dimension, the add-on I am using in the video is only there to evaluate/run Javascript during run time for easier testing.

I have provided an alternate way to reproduce the crash & the addon you should use to do so.

From the changelog:

Fixed bug that caused the game to crash when executing a run command from the runCommand() and Dimension.runCommandAsync() scripting APIs

PhosXD

(Unassigned)

Unconfirmed

iOS

iPadOS 17.5.1

command, crash, scripting-api

1.21.2 Hotfix

1.21.20

Retrieved