LongArgumentInfo .java

net.minecraft.commands.synchronization.brigadier.LongArgumentInfo (class, 64 lines): members: deserializeFromNetwork, serializeToJson, Template, unpack.

net.minecraft.commands.synchronization.brigadierclass64 linescommon2.1 KB

Implements

API Surface (6)

void serializeToNetwork(final LongArgumentInfo.Template template, final FriendlyByteBuf out)
LongArgumentInfo.Template deserializeFromNetwork(final FriendlyByteBuf in)
void serializeToJson(final LongArgumentInfo.Template template, final JsonObject out)
LongArgumentInfo.Template unpack(final LongArgumentType argument)
LongArgumentType instantiate(final CommandBuildContext context)
ArgumentTypeInfo<LongArgumentType, ?> type()

Code Graph: Dependencies (5)

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

Full Source

LongArgumentInfo.java64 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.commands.synchronization.brigadier;
2
3
import com.google.gson.JsonObject;
4
import com.mojang.brigadier.arguments.LongArgumentType;
5
import net.minecraft.commands.CommandBuildContext;
6
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
7
import net.minecraft.commands.synchronization.ArgumentUtils;
8
import net.minecraft.network.FriendlyByteBuf;
9
10
public class LongArgumentInfo implements ArgumentTypeInfo<LongArgumentType, LongArgumentInfo.Template> {
11
	public void serializeToNetwork(final LongArgumentInfo.Template template, final FriendlyByteBuf out) {
12
		boolean hasMin = template.min != Long.MIN_VALUE;
13
		boolean hasMax = template.max != Long.MAX_VALUE;
14
		out.writeByte(ArgumentUtils.createNumberFlags(hasMin, hasMax));
15
		if (hasMin) {
16
			out.writeLong(template.min);
17
		}
18
19
		if (hasMax) {
20
			out.writeLong(template.max);
21
		}
22
	}
23
24
	public LongArgumentInfo.Template deserializeFromNetwork(final FriendlyByteBuf in) {
25
		byte flags = in.readByte();
26
		long min = ArgumentUtils.numberHasMin(flags) ? in.readLong() : Long.MIN_VALUE;
27
		long max = ArgumentUtils.numberHasMax(flags) ? in.readLong() : Long.MAX_VALUE;
28
		return new LongArgumentInfo.Template(min, max);
29
	}
30
31
	public void serializeToJson(final LongArgumentInfo.Template template, final JsonObject out) {
32
		if (template.min != Long.MIN_VALUE) {
33
			out.addProperty("min", template.min);
34
		}
35
36
		if (template.max != Long.MAX_VALUE) {
37
			out.addProperty("max", template.max);
38
		}
39
	}
40
41
	public LongArgumentInfo.Template unpack(final LongArgumentType argument) {
42
		return new LongArgumentInfo.Template(argument.getMinimum(), argument.getMaximum());
43
	}
44
45
	public final class Template implements ArgumentTypeInfo.Template<LongArgumentType> {
46
		private final long min;
47
		private final long max;
48
49
		private Template(final long min, final long max) {
50
			this.min = min;
51
			this.max = max;
52
		}
53
54
		public LongArgumentType instantiate(final CommandBuildContext context) {
55
			return LongArgumentType.longArg(this.min, this.max);
56
		}
57
58
		@Override
59
		public ArgumentTypeInfo<LongArgumentType, ?> type() {
60
			return LongArgumentInfo.this;
61
		}
62
	}
63
}
64

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