SlotSources .java

net.minecraft.world.item.slot.SlotSources (interface): members: TYPED_CODEC, LIST_CODEC, DIRECT_CODEC, bootstrap, CODEC. strings: "limit_slots", "group".

net.minecraft.world.item.slotinterface34 linescommon1.6 KB

API Surface (0)

No public/protected methods detected (fields or constants only).

Fields & Constants (4)

TYPED_CODEC
DIRECT_CODEC
CODEC
LIST_CODEC

String literals (6)

"group"
"filtered"
"limit_slots"
"slot_range"
"contents"
"empty"

Code Graph: Dependencies (7)

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

Full Source

SlotSources.java34 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item.slot;
2
3
import com.mojang.datafixers.util.Either;
4
import com.mojang.serialization.Codec;
5
import com.mojang.serialization.MapCodec;
6
import net.minecraft.core.Holder;
7
import net.minecraft.core.HolderSet;
8
import net.minecraft.core.Registry;
9
import net.minecraft.core.registries.BuiltInRegistries;
10
import net.minecraft.core.registries.Registries;
11
import net.minecraft.core.registries.codec.RegistryCodecs;
12
13
public interface SlotSources {
14
	Codec<SlotSource> TYPED_CODEC = BuiltInRegistries.SLOT_SOURCE_TYPE.byNameCodec().dispatch(SlotSource::codec, c -> c);
15
	Codec<SlotSource> DIRECT_CODEC = Codec.lazyInitialized(
16
		() -> Codec.either(TYPED_CODEC, GroupSlotSource.INLINE_CODEC)
17
			.xmap(
18
				typedOrInline -> typedOrInline.map(e -> (SlotSource)e, e -> (SlotSource)e),
19
				slotSource -> slotSource instanceof GroupSlotSource composite ? Either.right(composite) : Either.left(slotSource)
20
			)
21
	);
22
	Codec<Holder<SlotSource>> CODEC = RegistryCodecs.holder(Registries.SLOT_SOURCE, DIRECT_CODEC);
23
	Codec<HolderSet<SlotSource>> LIST_CODEC = RegistryCodecs.holderSet(Registries.SLOT_SOURCE, TYPED_CODEC);
24
25
	static MapCodec<? extends SlotSource> bootstrap(final Registry<MapCodec<? extends SlotSource>> registry) {
26
		Registry.register(registry, "group", GroupSlotSource.MAP_CODEC);
27
		Registry.register(registry, "filtered", FilteredSlotSource.MAP_CODEC);
28
		Registry.register(registry, "limit_slots", LimitSlotSource.MAP_CODEC);
29
		Registry.register(registry, "slot_range", RangeSlotSource.MAP_CODEC);
30
		Registry.register(registry, "contents", ContentsSlotSource.MAP_CODEC);
31
		return Registry.register(registry, "empty", EmptySlotSource.MAP_CODEC);
32
	}
33
}
34

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