mojira.dev
MC-122608

Minecraft crashes when typing in a block-related command in front of an entity

The bug

Minecraft crashes when typing in a block-related command when standing in front of an entity/looking at an entity, for instance /execute store result block.
The game crashes as soon as it tries to autocomplete the coordinates.

Crash report

17w48a\: [^crash-2017-11-27_20.12.01-client.txt]

Description: charTyped event handler

java.lang.NullPointerException: charTyped event handler
	at bwu.a(SourceFile:76)
	at ci.listSuggestions(SourceFile:66)
	at com.mojang.brigadier.tree.ArgumentCommandNode.listSuggestions(ArgumentCommandNode.java:65)
	at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:345)
	at bpi.h(SourceFile:163)
	at bpi.a(SourceFile:97)
	at bpi$$Lambda$591/1168769758.accept(Unknown Source)
	at bnr.a(SourceFile:146)
	at bnr.b(SourceFile:141)
	at bnr.charTyped(SourceFile:375)
	at bon.charTyped(SourceFile:40)
	at bmj.a(SourceFile:360)
	at bmj$$Lambda$597/1579858776.run(Unknown Source)
	at bqg.a(SourceFile:428)
	at bmj.a(SourceFile:360)
	at bmj$$Lambda$107/1263927050.invoke(Unknown Source)
	at org.lwjgl.glfw.GLFWCharModsCallbackI.callback(GLFWCharModsCallbackI.java:23)
	at org.lwjgl.system.JNI.invokeV(Native Method)
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:2520)
	at bmw.a(SourceFile:282)
	at bmm.b(SourceFile:846)
	at bmm.a(SourceFile:381)
	at net.minecraft.client.main.Main.main(SourceFile:134)

Linked issues

MC-122672 Game crashes when typing "execute if block ..." Resolved MC-122778 /setblock when you standing in the same location of other entity crashs the game Resolved MC-122825 Looking at an entity while typing a block-related command crashes the game Resolved MC-122878 Chat Subcommand Chain Crashes Game Resolved MC-123019 Type /execute if block and then type space crashes the game Resolved

Attachments

Comments 9

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

We do not have enough information to find the cause of this issue.
Please attach the crash report found in [.minecraft|http://hopper.minecraft.net/help/guides/finding-minecraft-data-folder]/crash-reports/crash-<DATE>-client.txt here.

Click here to find out where your .minecraft folder is.
If you don't have a current crash report, please attach the launcher log which is located at [.minecraft|http://hopper.minecraft.net/help/guides/finding-minecraft-data-folder]/launcher_log.txt.

Please also provide the exact command used.

Once you have replied, the report will be reopened automatically.

Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki

Oh, I missed that, now it's there.
And that is the exact command. When typing a space at the end of the command part/continue writing the command, the game crashes immediately because then there would be the coordinate tab completion.

Huh, doesn't crash for me.

A short video about the bug:

[media]

. At the end, I type a space and it crashes.

Alright, missed the "near an entity" part, now it crashed for me as well. Exceptionally weird.

According to MC-122672, this crash occurs with /execute if block as well.

I'm guessing something along the lines of crashing from typing execute as @e[type=armor_stand,tag=InfLava1,tag=Source] at @s if block ~ ~ ~ air run data merge entity @s {Tags:["InfLava1","Cooldown"]}. When you hit tab after block it is covered by this bug report?

@@unknown, yes that should be the same bug since it is a block position which can be tab completed. You can also try comparing the stack traces of the crash reports, for the same version class and method names as well as line numbers should be the same. Between versions at least the line numbers often remain the same.

My guess (though it's hard to tell from obfuscated class and method names): the code is doing a raytrace in order to find block coordinates. But ray traces also stop when they reach an entity, in which case there is no block result in the RayTraceResult, and the block position is null. If that's not handled, then trying to get any coordinates from the now-null BlockPos will cause an NPE.

ETA This would also explain why it only happens with block-based commands, but not other commands like /tp or /summon: Brigadier (the command parser) allows decimal coordinates for entity-based commands, and as such it's probably using the RayTraceResult's hitVec value. This is a vector which is never null because whether the ray trace hits an entity or a block, the hitVec contains the exact double-precision point of impact. But for block-related commands, Brigadier expects only integer values, so it's not using the hitVec but instead the blockPos – which again, doesn't exist if the ray trace hits an entity instead of a block.

Maximilian Herczegh

Nathan Adams

Confirmed

coordinates, crash, tab-completion

Minecraft 17w48a, Minecraft 17w49a, Minecraft 17w49b, Minecraft 17w50a, Minecraft 18w01a

Minecraft 18w02a

Retrieved