Execute doesn't work in Functions
attempting to run a function with one results in "java.lang.NullPointerException"
this only happens once you reach the command. Commands previous work. This does not invalidate the function.
say foo execute at @s run tp ~ ~5 ~ say bar
prints:
[name of player] foo
java.lang.NullPointerException
and nothing else
Environment
Windows 10 Thinkpad
Linked Issues
is duplicated by1
Created Issue:
Execute doesn't work in Functions
attempting to run a function with one results in "java.lang.NullPointerException"
this only happens once you reach the command. Commands previous work. This does not invalidate the function.
' say foo execute at @s run tp ~ ~5 ~ say barprints:
foo
java.lang.NullPointerExceptionand nothing else
Environment
Windows 10 Thinkpad
attempting to run a function with one results in "java.lang.NullPointerException"
this only happens once you reach the command. Commands previous work. This does not invalidate the function.
'say foo execute at @s run tp ~ ~5 ~ say barprints:
foo
java.lang.NullPointerExceptionand nothing else
attempting to run a function with one results in "java.lang.NullPointerException"
this only happens once you reach the command. Commands previous work. This does not invalidate the function.
say foo execute at @s run tp ~ ~5 ~ say barprints:
foo
java.lang.NullPointerExceptionand nothing else
attempting to run a function with one results in "java.lang.NullPointerException"
this only happens once you reach the command. Commands previous work. This does not invalidate the function.
say foo execute at @s run tp ~ ~5 ~ say barprints:
[name of player] foo
java.lang.NullPointerExceptionand nothing else
is duplicated by
The bug
If an exception occurs in any command run by the gameLoopFunction, the server will crash. As vanilla commands usually do not throw exceptions, this issue will mostly cause problems on custom servers or other modified versions of the game.
Expected behavior
When the player executes the same function from chat, the exception is shown in chat and the server continues running. Something similar should happen for the gameLoopFunction, e.g. logging the exception when it occurs.
How to reproduce
- Create a new function.
- Add a command to the function that will throw an exception.
- In 17w45a, the execute command will cause a NullPointerException when used inside a function (see
MC-121674). - This is just an example, any exception occurring during command execution will work.
- In 17w45a, the execute command will cause a NullPointerException when used inside a function (see
- (Optional) Run the function from chat. The exception will be shown in chat, but otherwise nothing happens.
- Set that function as the gameLoopFunction. The server will crash immediately.
Provided by user-f2760:
[13:35:50] [Server thread/ERROR]: Couldn't execute command for @: teleport @e[x=-170,y=55,z=-115,dx=0,dy=5,dz=17,type=minecraft:villager] -150 55 -90 com.mojang.brigadier.exceptions.CommandSyntaxException: No entity was found at com.mojang.brigadier.exceptions.SimpleCommandExceptionType.create(SimpleCommandExceptionType.java:28) ~[minecraft_server.jar:?] at bp.b(SourceFile:51) ~[minecraft_server.jar:?] at oq.f(SourceFile:46) ~[minecraft_server.jar:?] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:117) ~[minecraft_server.jar:?] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:74) ~[minecraft_server.jar:?] at bl.a(SourceFile:169) [minecraft_server.jar:?] at aot.a(SourceFile:118) [minecraft_server.jar:?] at ary.c(SourceFile:248) [minecraft_server.jar:?] at ary.a(SourceFile:120) [minecraft_server.jar:?] at ary.b(SourceFile:93) [minecraft_server.jar:?] at pu.a(SourceFile:641) [minecraft_server.jar:?] at pu.d(SourceFile:220) [minecraft_server.jar:?] at net.minecraft.server.MinecraftServer.w(SourceFile:648) [minecraft_server.jar:?] at pf.w(SourceFile:349) [minecraft_server.jar:?] at net.minecraft.server.MinecraftServer.v(SourceFile:584) [minecraft_server.jar:?] at net.minecraft.server.MinecraftServer.run(SourceFile:489) [minecraft_server.jar:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_131] [13:35:50] [Server thread/ERROR]: Encountered an unexpected exception java.lang.NullPointerException: null at oe.a(SourceFile:404) ~[minecraft_server.jar:?] at oe.o(SourceFile:66) ~[minecraft_server.jar:?] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:117) ~[minecraft_server.jar:?] at bh$b.a(SourceFile:82) ~[minecraft_server.jar:?] at mm$a.a(SourceFile:187) ~[minecraft_server.jar:?] at mm.a(SourceFile:104) ~[minecraft_server.jar:?] at mm.N_(SourceFile:80) ~[minecraft_server.jar:?] at net.minecraft.server.MinecraftServer.w(SourceFile:678) ~[minecraft_server.jar:?] at pf.w(SourceFile:349) ~[minecraft_server.jar:?] at net.minecraft.server.MinecraftServer.v(SourceFile:584) ~[minecraft_server.jar:?] at net.minecraft.server.MinecraftServer.run(SourceFile:489) [minecraft_server.jar:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_131] [13:35:50] [Server thread/ERROR]: This crash report has been saved to: D:\Users\Steven\Desktop\Minecraft\Server\.\crash-reports\crash-2017-11-10_13.35.50-server.txt [13:35:50] [Server thread/INFO]: Stopping server [13:35:50] [Server thread/INFO]: Saving players [13:35:50] [Server thread/INFO]: Saving worlds [13:35:50] [Server thread/INFO]: Saving chunks for level 'medabots_server'/overworld [13:35:50] [Server thread/INFO]: Saving chunks for level 'medabots_server'/the_nether [13:35:50] [Server thread/INFO]: Saving chunks for level 'medabots_server'/the_end [13:35:50] [Server Shutdown Thread/INFO]: Stopping server [13:35:50] [Server Shutdown Thread/INFO]: Saving players [13:35:50] [Server Shutdown Thread/INFO]: Saving worlds [13:35:50] [Server Shutdown Thread/INFO]: Saving chunks for level 'medabots_server'/overworld [13:35:50] [Server Shutdown Thread/INFO]: Saving chunks for level 'medabots_server'/the_nether [13:35:50] [Server Shutdown Thread/INFO]: Saving chunks for level 'medabots_server'/the_end D:\Users\Steven\Desktop\Minecraft\Server>pause Press any key to continue . . .
Does this occur with selectors other than @s? In which case, this may be
MC-121627.it occurs with other selectors.
MC-121627is unrelated. It would happen if you do