SignedMessageLink .java

net.minecraft.network.chat.SignedMessageLink (record): members: index, sender, sessionId, isDescendantOf, unsigned, updateSignature, advance, root, CODEC.

net.minecraft.network.chatrecord46 linescommon1.7 KB

API Surface (5)

record SignedMessageLink(int index, UUID sender, UUID sessionId)
SignedMessageLink unsigned(final UUID sender)
SignedMessageLink root(final UUID sender, final UUID sessionId)
void updateSignature(final SignatureUpdater.Output output)
boolean isDescendantOf(final SignedMessageLink link)

Fields & Constants (1)

CODEC

String literals (3)

"index"
"sender"
"session_id"

Code Graph: Dependencies (4)

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

Full Source

SignedMessageLink.java46 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.chat;
2
3
import com.google.common.primitives.Ints;
4
import com.mojang.serialization.Codec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
import java.security.SignatureException;
7
import java.util.UUID;
8
import net.minecraft.core.UUIDUtil;
9
import net.minecraft.util.ExtraCodecs;
10
import net.minecraft.util.SignatureUpdater;
11
import net.minecraft.util.Util;
12
import org.jspecify.annotations.Nullable;
13
14
public record SignedMessageLink(int index, UUID sender, UUID sessionId) {
15
	public static final Codec<SignedMessageLink> CODEC = RecordCodecBuilder.create(
16
		i -> i.group(
17
				ExtraCodecs.NON_NEGATIVE_INT.fieldOf("index").forGetter(SignedMessageLink::index),
18
				UUIDUtil.CODEC.fieldOf("sender").forGetter(SignedMessageLink::sender),
19
				UUIDUtil.CODEC.fieldOf("session_id").forGetter(SignedMessageLink::sessionId)
20
			)
21
			.apply(i, SignedMessageLink::new)
22
	);
23
24
	public static SignedMessageLink unsigned(final UUID sender) {
25
		return root(sender, Util.NIL_UUID);
26
	}
27
28
	public static SignedMessageLink root(final UUID sender, final UUID sessionId) {
29
		return new SignedMessageLink(0, sender, sessionId);
30
	}
31
32
	public void updateSignature(final SignatureUpdater.Output output) throws SignatureException {
33
		output.update(UUIDUtil.uuidToByteArray(this.sender));
34
		output.update(UUIDUtil.uuidToByteArray(this.sessionId));
35
		output.update(Ints.toByteArray(this.index));
36
	}
37
38
	public boolean isDescendantOf(final SignedMessageLink link) {
39
		return this.index > link.index() && this.sender.equals(link.sender()) && this.sessionId.equals(link.sessionId());
40
	}
41
42
	public @Nullable SignedMessageLink advance() {
43
		return this.index == Integer.MAX_VALUE ? null : new SignedMessageLink(this.index + 1, this.sender, this.sessionId);
44
	}
45
}
46

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