ExecuteCommand .java

net.minecraft.commands.execution.tasks.ExecuteCommand (class, 41 lines): members: executionContext, commandInput, modifiers, execute. strings: "execute ".

net.minecraft.commands.execution.tasksclass41 linescommonextends ExecutionCommandSource<T>>1.6 KB

Implements

API Surface (1)

void execute(final T sender, final ExecutionContext<T> context, final Frame frame)

Fields & Constants (3)

commandInput
modifiers
executionContext

String literals (1)

"execute "

Full Source

ExecuteCommand.java41 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.commands.execution.tasks;
2
3
import com.mojang.brigadier.context.CommandContext;
4
import com.mojang.brigadier.context.ContextChain;
5
import com.mojang.brigadier.exceptions.CommandSyntaxException;
6
import net.minecraft.commands.ExecutionCommandSource;
7
import net.minecraft.commands.execution.ChainModifiers;
8
import net.minecraft.commands.execution.ExecutionContext;
9
import net.minecraft.commands.execution.Frame;
10
import net.minecraft.commands.execution.TraceCallbacks;
11
import net.minecraft.commands.execution.UnboundEntryAction;
12
13
public class ExecuteCommand<T extends ExecutionCommandSource<T>> implements UnboundEntryAction<T> {
14
	private final String commandInput;
15
	private final ChainModifiers modifiers;
16
	private final CommandContext<T> executionContext;
17
18
	public ExecuteCommand(final String commandInput, final ChainModifiers modifiers, final CommandContext<T> executionContext) {
19
		this.commandInput = commandInput;
20
		this.modifiers = modifiers;
21
		this.executionContext = executionContext;
22
	}
23
24
	public void execute(final T sender, final ExecutionContext<T> context, final Frame frame) {
25
		context.profiler().push(() -> "execute " + this.commandInput);
26
27
		try {
28
			context.incrementCost();
29
			int result = ContextChain.runExecutable(this.executionContext, sender, ExecutionCommandSource.resultConsumer(), this.modifiers.isForked());
30
			TraceCallbacks tracer = context.tracer();
31
			if (tracer != null) {
32
				tracer.onReturn(frame.depth(), this.commandInput, result);
33
			}
34
		} catch (CommandSyntaxException e) {
35
			sender.handleError(e, this.modifiers.isForked(), context.tracer());
36
		} finally {
37
			context.profiler().pop();
38
		}
39
	}
40
}
41

Decompiled Minecraft 26.3 source of ExecuteCommand (net/minecraft/commands/execution/tasks/ExecuteCommand.java) with Mojang official mappings, stored verbatim on the site.