ResolutionContext .java

net.minecraft.network.chat.ResolutionContext (record, 78 lines): members: source, defaultScoreboardEntity, objectInfoValidator, depthLimit, LimitBehavior.

net.minecraft.network.chatrecord78 linescommon2.5 KB

API Surface (9)

record ResolutionContext(@Nullable CommandSourceStack source, @Nullable Entity defaultScoreboardEntity, Predicate<ObjectInfo> objectInfoValidator, int depthLimit, ResolutionContext.LimitBehavior depthLimitBehavior, int resolvedComponentLimit, MutableInt resolvedComponentCount)
ResolutionContext create(final CommandSourceStack source)
ResolutionContext.Builder builder()
ResolutionContext.Builder withSource(final CommandSourceStack source)
ResolutionContext.Builder withEntityOverride(final @Nullable Entity defaultScoreboardEntity)
ResolutionContext.Builder withObjectInfoValidator(final Predicate<ObjectInfo> objectInfoValidator)
ResolutionContext.Builder setDepthLimit(final int depthLimit)
ResolutionContext.Builder setDepthLimitBehavior(final ResolutionContext.LimitBehavior behavior)
ResolutionContext build()

Fields & Constants (1)

DEFAULT_RESOLVED_COMPONENT_LIMIT

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ResolutionContext.java78 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.chat;
2
3
import java.util.function.Predicate;
4
import net.minecraft.commands.CommandSourceStack;
5
import net.minecraft.network.chat.contents.objects.ObjectInfo;
6
import net.minecraft.world.entity.Entity;
7
import org.apache.commons.lang3.mutable.MutableInt;
8
import org.jspecify.annotations.Nullable;
9
10
public record ResolutionContext(
11
	@Nullable CommandSourceStack source,
12
	@Nullable Entity defaultScoreboardEntity,
13
	Predicate<ObjectInfo> objectInfoValidator,
14
	int depthLimit,
15
	ResolutionContext.LimitBehavior depthLimitBehavior,
16
	int resolvedComponentLimit,
17
	MutableInt resolvedComponentCount
18
) {
19
	private static final int DEFAULT_RESOLVED_COMPONENT_LIMIT = 65536;
20
21
	public @Nullable ObjectInfo validate(final ObjectInfo description) {
22
		return this.objectInfoValidator.test(description) ? description : null;
23
	}
24
25
	public static ResolutionContext create(final CommandSourceStack source) {
26
		return builder().withSource(source).build();
27
	}
28
29
	public static ResolutionContext.Builder builder() {
30
		return new ResolutionContext.Builder();
31
	}
32
33
	public static class Builder {
34
		private @Nullable CommandSourceStack source;
35
		private @Nullable Entity defaultScoreboardEntity;
36
		private Predicate<ObjectInfo> objectInfoValidator = var0 -> true;
37
		private int depthLimit = 100;
38
		private ResolutionContext.LimitBehavior depthLimitBehavior = ResolutionContext.LimitBehavior.STOP_PROCESSING_AND_COPY_REMAINING;
39
40
		public ResolutionContext.Builder withSource(final CommandSourceStack source) {
41
			this.source = source;
42
			this.defaultScoreboardEntity = source.getEntity();
43
			return this;
44
		}
45
46
		public ResolutionContext.Builder withEntityOverride(final @Nullable Entity defaultScoreboardEntity) {
47
			this.defaultScoreboardEntity = defaultScoreboardEntity;
48
			return this;
49
		}
50
51
		public ResolutionContext.Builder withObjectInfoValidator(final Predicate<ObjectInfo> objectInfoValidator) {
52
			this.objectInfoValidator = objectInfoValidator;
53
			return this;
54
		}
55
56
		public ResolutionContext.Builder setDepthLimit(final int depthLimit) {
57
			this.depthLimit = depthLimit;
58
			return this;
59
		}
60
61
		public ResolutionContext.Builder setDepthLimitBehavior(final ResolutionContext.LimitBehavior behavior) {
62
			this.depthLimitBehavior = behavior;
63
			return this;
64
		}
65
66
		public ResolutionContext build() {
67
			return new ResolutionContext(
68
				this.source, this.defaultScoreboardEntity, this.objectInfoValidator, this.depthLimit, this.depthLimitBehavior, 65536, new MutableInt()
69
			);
70
		}
71
	}
72
73
	public enum LimitBehavior {
74
		DISCARD_REMAINING,
75
		STOP_PROCESSING_AND_COPY_REMAINING;
76
	}
77
}
78

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