CommandResultCallback .java

net.minecraft.commands.CommandResultCallback (interface, 37 lines): members: onFailure, onSuccess, onResult, chain, EMPTY. strings: "<empty>".

net.minecraft.commandsinterface37 linescommon805 B

API Surface (2)

void onResult(final boolean success, final int result)
String toString()

Fields & Constants (1)

EMPTY

String literals (1)

"<empty>"

Full Source

CommandResultCallback.java37 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.commands;
2
3
@FunctionalInterface
4
public interface CommandResultCallback {
5
	CommandResultCallback EMPTY = new CommandResultCallback() {
6
		@Override
7
		public void onResult(final boolean success, final int result) {
8
		}
9
10
		@Override
11
		public String toString() {
12
			return "<empty>";
13
		}
14
	};
15
16
	void onResult(boolean success, int result);
17
18
	default void onSuccess(final int result) {
19
		this.onResult(true, result);
20
	}
21
22
	default void onFailure() {
23
		this.onResult(false, 0);
24
	}
25
26
	static CommandResultCallback chain(final CommandResultCallback first, final CommandResultCallback second) {
27
		if (first == EMPTY) {
28
			return second;
29
		} else {
30
			return second == EMPTY ? first : (success, result) -> {
31
				first.onResult(success, result);
32
				second.onResult(success, result);
33
			};
34
		}
35
	}
36
}
37

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