MapDecorations .java

net.minecraft.world.item.component.MapDecorations (record): members: decorations, withDecoration, Entry, EMPTY, CODEC. strings: "rotation". imports: Util.

net.minecraft.world.item.componentrecord31 linescommon1.3 KB

API Surface (3)

record MapDecorations(Map<String, MapDecorations.Entry> decorations)
MapDecorations withDecoration(final String id, final MapDecorations.Entry entry)
record Entry(Holder<MapDecorationType> type, double x, double z, float rotation)

Fields & Constants (2)

EMPTY
CODEC

String literals (1)

"rotation"

Code Graph: Dependencies (4)

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

Full Source

MapDecorations.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item.component;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import java.util.Map;
6
import net.minecraft.core.Holder;
7
import net.minecraft.util.Util;
8
import net.minecraft.world.level.saveddata.maps.MapDecorationType;
9
10
public record MapDecorations(Map<String, MapDecorations.Entry> decorations) {
11
	public static final MapDecorations EMPTY = new MapDecorations(Map.of());
12
	public static final Codec<MapDecorations> CODEC = Codec.unboundedMap(Codec.STRING, MapDecorations.Entry.CODEC)
13
		.xmap(MapDecorations::new, MapDecorations::decorations);
14
15
	public MapDecorations withDecoration(final String id, final MapDecorations.Entry entry) {
16
		return new MapDecorations(Util.copyAndPut(this.decorations, id, entry));
17
	}
18
19
	public record Entry(Holder<MapDecorationType> type, double x, double z, float rotation) {
20
		public static final Codec<MapDecorations.Entry> CODEC = RecordCodecBuilder.create(
21
			i -> i.group(
22
					MapDecorationType.CODEC.fieldOf("type").forGetter(MapDecorations.Entry::type),
23
					Codec.DOUBLE.fieldOf("x").forGetter(MapDecorations.Entry::x),
24
					Codec.DOUBLE.fieldOf("z").forGetter(MapDecorations.Entry::z),
25
					Codec.FLOAT.fieldOf("rotation").forGetter(MapDecorations.Entry::rotation)
26
				)
27
				.apply(i, MapDecorations.Entry::new)
28
		);
29
	}
30
}
31

Decompiled Minecraft 26.3 source of MapDecorations (net/minecraft/world/item/component/MapDecorations.java) with Mojang official mappings, stored verbatim on the site.