RangeArgument .java

net.minecraft.commands.arguments.RangeArgument (interface): members: Floats, floatRange, intRange, Ints. imports: MinMaxBounds, ArgumentType, StringReader.

net.minecraft.commands.argumentsinterface55 linescommonextends MinMaxBounds<1.8 KB

API Surface (6)

MinMaxBounds.Doubles getRange(final CommandContext<CommandSourceStack> context, final String name)
MinMaxBounds.Doubles parse(final StringReader reader)
Collection<String> getExamples()
MinMaxBounds.Ints getRange(final CommandContext<CommandSourceStack> context, final String name)
MinMaxBounds.Ints parse(final StringReader reader)
Collection<String> getExamples()

Code Graph: Dependencies (2)

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

Full Source

RangeArgument.java55 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.commands.arguments;
2
3
import com.mojang.brigadier.StringReader;
4
import com.mojang.brigadier.arguments.ArgumentType;
5
import com.mojang.brigadier.context.CommandContext;
6
import com.mojang.brigadier.exceptions.CommandSyntaxException;
7
import java.util.Arrays;
8
import java.util.Collection;
9
import net.minecraft.advancements.predicates.MinMaxBounds;
10
import net.minecraft.commands.CommandSourceStack;
11
12
public interface RangeArgument<T extends MinMaxBounds<?>> extends ArgumentType<T> {
13
	static RangeArgument.Ints intRange() {
14
		return new RangeArgument.Ints();
15
	}
16
17
	static RangeArgument.Floats floatRange() {
18
		return new RangeArgument.Floats();
19
	}
20
21
	class Floats implements RangeArgument<MinMaxBounds.Doubles> {
22
		private static final Collection<String> EXAMPLES = Arrays.asList("0..5.2", "0", "-5.4", "-100.76..", "..100");
23
24
		public static MinMaxBounds.Doubles getRange(final CommandContext<CommandSourceStack> context, final String name) {
25
			return context.getArgument(name, MinMaxBounds.Doubles.class);
26
		}
27
28
		public MinMaxBounds.Doubles parse(final StringReader reader) throws CommandSyntaxException {
29
			return MinMaxBounds.Doubles.fromReader(reader);
30
		}
31
32
		@Override
33
		public Collection<String> getExamples() {
34
			return EXAMPLES;
35
		}
36
	}
37
38
	class Ints implements RangeArgument<MinMaxBounds.Ints> {
39
		private static final Collection<String> EXAMPLES = Arrays.asList("0..5", "0", "-5", "-100..", "..100");
40
41
		public static MinMaxBounds.Ints getRange(final CommandContext<CommandSourceStack> context, final String name) {
42
			return context.getArgument(name, MinMaxBounds.Ints.class);
43
		}
44
45
		public MinMaxBounds.Ints parse(final StringReader reader) throws CommandSyntaxException {
46
			return MinMaxBounds.Ints.fromReader(reader);
47
		}
48
49
		@Override
50
		public Collection<String> getExamples() {
51
			return EXAMPLES;
52
		}
53
	}
54
}
55

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