mojira.dev
MC-311594

Some number providers produce an unexpected error when used in `/compute`

/compute default float {type:"enchantment_level",amount:5}

This command fails with “An unexpected error occurred while trying to execute that command.” No clues appear in the log.

I don’t expect this command to succeed because enchantment context is not available, however it should not have an unexpected error (indicating an exception was swallowed).

Comments 1

The exception’s stack trace:

java.util.NoSuchElementException: minecraft:enchantment_level
	at net.minecraft.util.context.ContextMap.getOrThrow(ContextMap.java:32)
	at net.minecraft.world.level.storage.loot.LootContext.getParameter(LootContext.java:43)
	at net.minecraft.world.level.storage.loot.providers.number.floats.EnchantmentLevelProvider.getFloatUnsafe(EnchantmentLevelProvider.java:30)
	at net.minecraft.server.commands.ComputeCommand.computeAsFloat(ComputeCommand.java:91)
	at net.minecraft.server.commands.ComputeCommand.lambda$register$1(ComputeCommand.java:40)
	at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73)
	at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:29)
	at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:13)
	at net.minecraft.commands.execution.UnboundEntryAction.lambda$bind$0(UnboundEntryAction.java:8)
	at net.minecraft.commands.execution.CommandQueueEntry.execute(CommandQueueEntry.java:8)
	at net.minecraft.commands.execution.ExecutionContext.runCommandQueue(ExecutionContext.java:106)
	at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:438)
	at net.minecraft.commands.Commands.performCommand(Commands.java:370)
	at net.minecraft.server.network.ServerGamePacketListenerImpl.performUnsignedChatCommand(ServerGamePacketListenerImpl.java:1717)
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$0(ServerGamePacketListenerImpl.java:1705)
	at net.minecraft.server.TickTask.run(TickTask.java:18)
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:173)
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23)
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:912)
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:193)
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:147)
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:894)
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:888)
	at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:156)
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:859)
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:758)
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:310)
	at java.base/java.lang.Thread.run(Thread.java:1474)

tryashtar

boq

Confirmed

Platform HC

Normal

Commands, Data Packs

26.3 Pre-Release 1

26.3 Pre-Release 2

Retrieved