ArgumentTypeInfos .java

net.minecraft.commands.synchronization.ArgumentTypeInfos (class): members: isClassRecognized, brigadierType, BY_CLASS, byClass, unpack, bootstrap.

net.minecraft.commands.synchronizationclass177 linescommon12.7 KB

API Surface (4)

ArgumentTypeInfo<?, ?> bootstrap(final Registry<ArgumentTypeInfo<?, ?>> registry)
boolean isClassRecognized(final Class<?> cls)
<A extends ArgumentType<?>> ArgumentTypeInfo<A, ?> byClass(final A argumentType)
<A extends ArgumentType<?>> ArgumentTypeInfo.Template<A> unpack(final A argumentType)

Fields & Constants (2)

BY_CLASS
brigadierType

String literals (61)

"brigadier:bool"
"brigadier:float"
"brigadier:double"
"brigadier:integer"
"brigadier:long"
"brigadier:string"
"entity"
"game_profile"
"block_pos"
"column_pos"
"vec3"
"vec2"
"block_state"
"block_predicate"
"item_stack"
"item_predicate"
"team_color"
"hex_color"
"component"
"style"
"nbt_compound_tag"
"nbt_tag"
"nbt_path"
"objective"

Code Graph: Dependencies (57)

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

Full Source

ArgumentTypeInfos.java177 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.commands.synchronization;
2
3
import com.google.common.collect.Maps;
4
import com.mojang.brigadier.arguments.ArgumentType;
5
import com.mojang.brigadier.arguments.BoolArgumentType;
6
import com.mojang.brigadier.arguments.DoubleArgumentType;
7
import com.mojang.brigadier.arguments.FloatArgumentType;
8
import com.mojang.brigadier.arguments.IntegerArgumentType;
9
import com.mojang.brigadier.arguments.LongArgumentType;
10
import com.mojang.brigadier.arguments.StringArgumentType;
11
import java.util.Locale;
12
import java.util.Map;
13
import net.minecraft.commands.arguments.AngleArgument;
14
import net.minecraft.commands.arguments.ComponentArgument;
15
import net.minecraft.commands.arguments.CompoundTagArgument;
16
import net.minecraft.commands.arguments.DimensionArgument;
17
import net.minecraft.commands.arguments.EntityAnchorArgument;
18
import net.minecraft.commands.arguments.EntityArgument;
19
import net.minecraft.commands.arguments.GameModeArgument;
20
import net.minecraft.commands.arguments.GameProfileArgument;
21
import net.minecraft.commands.arguments.HeightmapTypeArgument;
22
import net.minecraft.commands.arguments.HexColorArgument;
23
import net.minecraft.commands.arguments.IdentifierArgument;
24
import net.minecraft.commands.arguments.MessageArgument;
25
import net.minecraft.commands.arguments.NbtPathArgument;
26
import net.minecraft.commands.arguments.NbtTagArgument;
27
import net.minecraft.commands.arguments.ObjectiveArgument;
28
import net.minecraft.commands.arguments.ObjectiveCriteriaArgument;
29
import net.minecraft.commands.arguments.OperationArgument;
30
import net.minecraft.commands.arguments.ParticleArgument;
31
import net.minecraft.commands.arguments.RangeArgument;
32
import net.minecraft.commands.arguments.ResourceArgument;
33
import net.minecraft.commands.arguments.ResourceKeyArgument;
34
import net.minecraft.commands.arguments.ResourceOrIdArgument;
35
import net.minecraft.commands.arguments.ResourceOrTagArgument;
36
import net.minecraft.commands.arguments.ResourceOrTagKeyArgument;
37
import net.minecraft.commands.arguments.ResourceSelectorArgument;
38
import net.minecraft.commands.arguments.ScoreHolderArgument;
39
import net.minecraft.commands.arguments.ScoreboardSlotArgument;
40
import net.minecraft.commands.arguments.SlotArgument;
41
import net.minecraft.commands.arguments.SlotSourceArgument;
42
import net.minecraft.commands.arguments.SlotsArgument;
43
import net.minecraft.commands.arguments.StyleArgument;
44
import net.minecraft.commands.arguments.SwingAnimationArgument;
45
import net.minecraft.commands.arguments.TeamArgument;
46
import net.minecraft.commands.arguments.TeamColorArgument;
47
import net.minecraft.commands.arguments.TemplateMirrorArgument;
48
import net.minecraft.commands.arguments.TemplateRotationArgument;
49
import net.minecraft.commands.arguments.TimeArgument;
50
import net.minecraft.commands.arguments.UuidArgument;
51
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
52
import net.minecraft.commands.arguments.blocks.BlockStateArgument;
53
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
54
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
55
import net.minecraft.commands.arguments.coordinates.RotationArgument;
56
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
57
import net.minecraft.commands.arguments.coordinates.Vec2Argument;
58
import net.minecraft.commands.arguments.coordinates.Vec3Argument;
59
import net.minecraft.commands.arguments.item.FunctionArgument;
60
import net.minecraft.commands.arguments.item.ItemArgument;
61
import net.minecraft.commands.arguments.item.ItemPredicateArgument;
62
import net.minecraft.commands.synchronization.brigadier.DoubleArgumentInfo;
63
import net.minecraft.commands.synchronization.brigadier.FloatArgumentInfo;
64
import net.minecraft.commands.synchronization.brigadier.IntegerArgumentInfo;
65
import net.minecraft.commands.synchronization.brigadier.LongArgumentInfo;
66
import net.minecraft.commands.synchronization.brigadier.StringArgumentSerializer;
67
import net.minecraft.core.Registry;
68
69
public class ArgumentTypeInfos {
70
	private static final Map<Class<?>, ArgumentTypeInfo<?, ?>> BY_CLASS = Maps.newHashMap();
71
72
	private static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>> ArgumentTypeInfo<A, T> register(
73
		final Registry<ArgumentTypeInfo<?, ?>> registry, final String id, final Class<? extends A> brigadierType, final ArgumentTypeInfo<A, T> info
74
	) {
75
		BY_CLASS.put(brigadierType, info);
76
		return Registry.register(registry, id, info);
77
	}
78
79
	public static ArgumentTypeInfo<?, ?> bootstrap(final Registry<ArgumentTypeInfo<?, ?>> registry) {
80
		register(registry, "brigadier:bool", BoolArgumentType.class, SingletonArgumentInfo.contextFree(BoolArgumentType::bool));
81
		register(registry, "brigadier:float", FloatArgumentType.class, new FloatArgumentInfo());
82
		register(registry, "brigadier:double", DoubleArgumentType.class, new DoubleArgumentInfo());
83
		register(registry, "brigadier:integer", IntegerArgumentType.class, new IntegerArgumentInfo());
84
		register(registry, "brigadier:long", LongArgumentType.class, new LongArgumentInfo());
85
		register(registry, "brigadier:string", StringArgumentType.class, new StringArgumentSerializer());
86
		register(registry, "entity", EntityArgument.class, new EntityArgument.Info());
87
		register(registry, "game_profile", GameProfileArgument.class, SingletonArgumentInfo.contextFree(GameProfileArgument::gameProfile));
88
		register(registry, "block_pos", BlockPosArgument.class, SingletonArgumentInfo.contextFree(BlockPosArgument::blockPos));
89
		register(registry, "column_pos", ColumnPosArgument.class, SingletonArgumentInfo.contextFree(ColumnPosArgument::columnPos));
90
		register(registry, "vec3", Vec3Argument.class, SingletonArgumentInfo.contextFree(Vec3Argument::vec3));
91
		register(registry, "vec2", Vec2Argument.class, SingletonArgumentInfo.contextFree(Vec2Argument::vec2));
92
		register(registry, "block_state", BlockStateArgument.class, SingletonArgumentInfo.contextAware(BlockStateArgument::block));
93
		register(registry, "block_predicate", BlockPredicateArgument.class, SingletonArgumentInfo.contextAware(BlockPredicateArgument::blockPredicate));
94
		register(registry, "item_stack", ItemArgument.class, SingletonArgumentInfo.contextAware(ItemArgument::item));
95
		register(registry, "item_predicate", ItemPredicateArgument.class, SingletonArgumentInfo.contextAware(ItemPredicateArgument::itemPredicate));
96
		register(registry, "team_color", TeamColorArgument.class, SingletonArgumentInfo.contextFree(TeamColorArgument::teamColor));
97
		register(registry, "hex_color", HexColorArgument.class, SingletonArgumentInfo.contextFree(HexColorArgument::hexColor));
98
		register(registry, "component", ComponentArgument.class, SingletonArgumentInfo.contextAware(ComponentArgument::textComponent));
99
		register(registry, "style", StyleArgument.class, SingletonArgumentInfo.contextAware(StyleArgument::style));
100
		register(registry, "message", MessageArgument.class, SingletonArgumentInfo.contextFree(MessageArgument::message));
101
		register(registry, "nbt_compound_tag", CompoundTagArgument.class, SingletonArgumentInfo.contextFree(CompoundTagArgument::compoundTag));
102
		register(registry, "nbt_tag", NbtTagArgument.class, SingletonArgumentInfo.contextFree(NbtTagArgument::nbtTag));
103
		register(registry, "nbt_path", NbtPathArgument.class, SingletonArgumentInfo.contextFree(NbtPathArgument::nbtPath));
104
		register(registry, "objective", ObjectiveArgument.class, SingletonArgumentInfo.contextFree(ObjectiveArgument::objective));
105
		register(registry, "objective_criteria", ObjectiveCriteriaArgument.class, SingletonArgumentInfo.contextFree(ObjectiveCriteriaArgument::criteria));
106
		register(registry, "operation", OperationArgument.class, SingletonArgumentInfo.contextFree(OperationArgument::operation));
107
		register(registry, "particle", ParticleArgument.class, SingletonArgumentInfo.contextAware(ParticleArgument::particle));
108
		register(registry, "angle", AngleArgument.class, SingletonArgumentInfo.contextFree(AngleArgument::angle));
109
		register(registry, "rotation", RotationArgument.class, SingletonArgumentInfo.contextFree(RotationArgument::rotation));
110
		register(registry, "scoreboard_slot", ScoreboardSlotArgument.class, SingletonArgumentInfo.contextFree(ScoreboardSlotArgument::displaySlot));
111
		register(registry, "score_holder", ScoreHolderArgument.class, new ScoreHolderArgument.Info());
112
		register(registry, "swizzle", SwizzleArgument.class, SingletonArgumentInfo.contextFree(SwizzleArgument::swizzle));
113
		register(registry, "team", TeamArgument.class, SingletonArgumentInfo.contextFree(TeamArgument::team));
114
		register(registry, "item_slot", SlotArgument.class, SingletonArgumentInfo.contextFree(SlotArgument::slot));
115
		register(registry, "item_slots", SlotsArgument.class, SingletonArgumentInfo.contextFree(SlotsArgument::slots));
116
		register(registry, "resource_location", IdentifierArgument.class, SingletonArgumentInfo.contextFree(IdentifierArgument::id));
117
		register(registry, "function", FunctionArgument.class, SingletonArgumentInfo.contextFree(FunctionArgument::functions));
118
		register(registry, "entity_anchor", EntityAnchorArgument.class, SingletonArgumentInfo.contextFree(EntityAnchorArgument::anchor));
119
		register(registry, "int_range", RangeArgument.Ints.class, SingletonArgumentInfo.contextFree(RangeArgument::intRange));
120
		register(registry, "float_range", RangeArgument.Floats.class, SingletonArgumentInfo.contextFree(RangeArgument::floatRange));
121
		register(registry, "dimension", DimensionArgument.class, SingletonArgumentInfo.contextFree(DimensionArgument::dimension));
122
		register(registry, "gamemode", GameModeArgument.class, SingletonArgumentInfo.contextFree(GameModeArgument::gameMode));
123
		register(registry, "time", TimeArgument.class, new TimeArgument.Info());
124
		register(registry, "resource_or_tag", fixClassType(ResourceOrTagArgument.class), new ResourceOrTagArgument.Info());
125
		register(registry, "resource_or_tag_key", fixClassType(ResourceOrTagKeyArgument.class), new ResourceOrTagKeyArgument.Info());
126
		register(registry, "resource", fixClassType(ResourceArgument.class), new ResourceArgument.Info());
127
		register(registry, "resource_key", fixClassType(ResourceKeyArgument.class), new ResourceKeyArgument.Info());
128
		register(registry, "resource_selector", fixClassType(ResourceSelectorArgument.class), new ResourceSelectorArgument.Info());
129
		register(registry, "template_mirror", TemplateMirrorArgument.class, SingletonArgumentInfo.contextFree(TemplateMirrorArgument::templateMirror));
130
		register(registry, "template_rotation", TemplateRotationArgument.class, SingletonArgumentInfo.contextFree(TemplateRotationArgument::templateRotation));
131
		register(registry, "heightmap", HeightmapTypeArgument.class, SingletonArgumentInfo.contextFree(HeightmapTypeArgument::heightmap));
132
		register(registry, "loot_table", ResourceOrIdArgument.LootTableArgument.class, SingletonArgumentInfo.contextAware(ResourceOrIdArgument::lootTable));
133
		register(
134
			registry, "loot_predicate", ResourceOrIdArgument.LootPredicateArgument.class, SingletonArgumentInfo.contextAware(ResourceOrIdArgument::lootPredicate)
135
		);
136
		register(registry, "loot_modifier", ResourceOrIdArgument.LootModifierArgument.class, SingletonArgumentInfo.contextAware(ResourceOrIdArgument::lootModifier));
137
		register(
138
			registry,
139
			"context_float_provider",
140
			ResourceOrIdArgument.ContextFloatProviderArgument.class,
141
			SingletonArgumentInfo.contextAware(ResourceOrIdArgument::floatProvider)
142
		);
143
		register(
144
			registry,
145
			"context_int_provider",
146
			ResourceOrIdArgument.ContextIntProviderArgument.class,
147
			SingletonArgumentInfo.contextAware(ResourceOrIdArgument::intProvider)
148
		);
149
		register(registry, "slot_source", SlotSourceArgument.class, SingletonArgumentInfo.contextAware(SlotSourceArgument::slotSource));
150
		register(registry, "dialog", ResourceOrIdArgument.DialogArgument.class, SingletonArgumentInfo.contextAware(ResourceOrIdArgument::dialog));
151
		register(registry, "feature", ResourceOrIdArgument.FeatureArgument.class, SingletonArgumentInfo.contextAware(ResourceOrIdArgument::feature));
152
		register(registry, "swing_animation", SwingAnimationArgument.class, SingletonArgumentInfo.contextFree(SwingAnimationArgument::swingAnimationType));
153
		return register(registry, "uuid", UuidArgument.class, SingletonArgumentInfo.contextFree(UuidArgument::uuid));
154
	}
155
156
	private static <T extends ArgumentType<?>> Class<T> fixClassType(final Class<? super T> cls) {
157
		return (Class<T>)cls;
158
	}
159
160
	public static boolean isClassRecognized(final Class<?> cls) {
161
		return BY_CLASS.containsKey(cls);
162
	}
163
164
	public static <A extends ArgumentType<?>> ArgumentTypeInfo<A, ?> byClass(final A argumentType) {
165
		ArgumentTypeInfo<?, ?> result = BY_CLASS.get(argumentType.getClass());
166
		if (result == null) {
167
			throw new IllegalArgumentException(String.format(Locale.ROOT, "Unrecognized argument type %s (%s)", argumentType, argumentType.getClass()));
168
		} else {
169
			return (ArgumentTypeInfo<A, ?>)result;
170
		}
171
	}
172
173
	public static <A extends ArgumentType<?>> ArgumentTypeInfo.Template<A> unpack(final A argumentType) {
174
		return byClass(argumentType).unpack(argumentType);
175
	}
176
}
177

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