CriterionProgress .java

net.minecraft.advancements.CriterionProgress (class, 44 lines): members: getObtained, obtained, revoke, grant, isDone, STREAM_CODEC. imports: ByteBuf.

net.minecraft.advancementsclass44 linescommon1.1 KB

API Surface (4)

boolean isDone()
void grant()
void revoke()
String toString()

Fields & Constants (2)

STREAM_CODEC
obtained

String literals (1)

"CriterionProgress{obtained="

Code Graph: Dependencies (2)

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

Full Source

CriterionProgress.java44 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.advancements;
2
3
import io.netty.buffer.ByteBuf;
4
import java.time.Instant;
5
import java.util.Optional;
6
import net.minecraft.network.codec.ByteBufCodecs;
7
import net.minecraft.network.codec.StreamCodec;
8
import org.jspecify.annotations.Nullable;
9
10
public class CriterionProgress {
11
	public static final StreamCodec<ByteBuf, CriterionProgress> STREAM_CODEC = ByteBufCodecs.INSTANT
12
		.apply(ByteBufCodecs::optional)
13
		.map(obtained -> new CriterionProgress((Instant)obtained.orElse(null)), progress -> Optional.ofNullable(progress.obtained));
14
	private @Nullable Instant obtained;
15
16
	public CriterionProgress() {
17
	}
18
19
	public CriterionProgress(final @Nullable Instant obtained) {
20
		this.obtained = obtained;
21
	}
22
23
	public boolean isDone() {
24
		return this.obtained != null;
25
	}
26
27
	public void grant() {
28
		this.obtained = Instant.now();
29
	}
30
31
	public void revoke() {
32
		this.obtained = null;
33
	}
34
35
	public @Nullable Instant getObtained() {
36
		return this.obtained;
37
	}
38
39
	@Override
40
	public String toString() {
41
		return "CriterionProgress{obtained=" + (this.obtained == null ? "false" : this.obtained) + "}";
42
	}
43
}
44

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