CustomAll .java

net.minecraft.server.dialog.action.CustomAll (record): members: additions, createAction, MAP_CODEC, codec. strings: "additions". imports: ClickEvent.

net.minecraft.server.dialog.actionrecord29 linesserver1.1 KB

Implements

API Surface (2)

MapCodec<CustomAll> codec()
Optional<ClickEvent> createAction(final Map<String, Action.ValueGetter> parameters)

Fields & Constants (1)

MAP_CODEC

String literals (1)

"additions"

Code Graph: Dependencies (4)

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

Full Source

CustomAll.java29 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.dialog.action;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import java.util.Map;
6
import java.util.Optional;
7
import net.minecraft.nbt.CompoundTag;
8
import net.minecraft.network.chat.ClickEvent;
9
import net.minecraft.resources.Identifier;
10
11
public record CustomAll(Identifier id, Optional<CompoundTag> additions) implements Action {
12
	public static final MapCodec<CustomAll> MAP_CODEC = RecordCodecBuilder.mapCodec(
13
		i -> i.group(Identifier.CODEC.fieldOf("id").forGetter(CustomAll::id), CompoundTag.CODEC.optionalFieldOf("additions").forGetter(CustomAll::additions))
14
			.apply(i, CustomAll::new)
15
	);
16
17
	@Override
18
	public MapCodec<CustomAll> codec() {
19
		return MAP_CODEC;
20
	}
21
22
	@Override
23
	public Optional<ClickEvent> createAction(final Map<String, Action.ValueGetter> parameters) {
24
		CompoundTag tag = this.additions.<CompoundTag>map(CompoundTag::copy).orElseGet(CompoundTag::new);
25
		parameters.forEach((key, value) -> tag.put(key, value.asTag()));
26
		return Optional.of(new ClickEvent.Custom(this.id, Optional.of(tag)));
27
	}
28
}
29

Decompiled Minecraft 26.3 source of CustomAll (net/minecraft/server/dialog/action/CustomAll.java) with Mojang official mappings, stored verbatim on the site.