/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.google.common.primitives.Ints * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.serialization.Codec * com.mojang.serialization.codecs.RecordCodecBuilder * org.jspecify.annotations.Nullable */ package net.minecraft.network.chat; import com.google.common.primitives.Ints; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import java.security.SignatureException; import java.util.UUID; import net.minecraft.core.UUIDUtil; import net.minecraft.util.ExtraCodecs; import net.minecraft.util.SignatureUpdater; import net.minecraft.util.Util; import org.jspecify.annotations.Nullable; public record SignedMessageLink(int index, UUID sender, UUID sessionId) { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group((App)ExtraCodecs.NON_NEGATIVE_INT.fieldOf("index").forGetter(SignedMessageLink::index), (App)UUIDUtil.CODEC.fieldOf("sender").forGetter(SignedMessageLink::sender), (App)UUIDUtil.CODEC.fieldOf("session_id").forGetter(SignedMessageLink::sessionId)).apply((Applicative)i, SignedMessageLink::new)); public static SignedMessageLink unsigned(UUID sender) { return SignedMessageLink.root(sender, Util.NIL_UUID); } public static SignedMessageLink root(UUID sender, UUID sessionId) { return new SignedMessageLink(0, sender, sessionId); } public void updateSignature(SignatureUpdater.Output output) throws SignatureException { output.update(UUIDUtil.uuidToByteArray(this.sender)); output.update(UUIDUtil.uuidToByteArray(this.sessionId)); output.update(Ints.toByteArray((int)this.index)); } public boolean isDescendantOf(SignedMessageLink link) { return this.index > link.index() && this.sender.equals(link.sender()) && this.sessionId.equals(link.sessionId()); } public @Nullable SignedMessageLink advance() { if (this.index == Integer.MAX_VALUE) { return null; } return new SignedMessageLink(this.index + 1, this.sender, this.sessionId); } }