API Surface (2) MapCodec<ContentsSlotSource> codec()
SlotCollection transform(final SlotCollection slots)
Code Graph: Dependencies (6) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
ContentsSlotSource.java 30 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.world.item.slot;
2
3 import com.mojang.serialization.MapCodec;
4 import com.mojang.serialization.codecs.RecordCodecBuilder;
5 import net.minecraft.core.Holder;
6 import net.minecraft.world.level.storage.loot.ContainerComponentManipulator;
7 import net.minecraft.world.level.storage.loot.ContainerComponentManipulators;
8
9 public class ContentsSlotSource extends TransformedSlotSource {
10 public static final MapCodec<ContentsSlotSource> MAP_CODEC = RecordCodecBuilder.mapCodec(
11 i -> commonFields(i).and(ContainerComponentManipulators.CODEC.fieldOf("component").forGetter(t -> t.component)).apply(i, ContentsSlotSource::new)
12 );
13 private final ContainerComponentManipulator<?> component;
14
15 private ContentsSlotSource(final Holder<SlotSource> slotSource, final ContainerComponentManipulator<?> component) {
16 super(slotSource);
17 this.component = component;
18 }
19
20 @Override
21 public MapCodec<ContentsSlotSource> codec() {
22 return MAP_CODEC;
23 }
24
25 @Override
26 protected SlotCollection transform(final SlotCollection slots) {
27 return slots.flatMap(this.component::getSlots);
28 }
29 }
30
Decompiled Minecraft 26.3 source of ContentsSlotSource (net/minecraft/world/item/slot/ContentsSlotSource.java) with Mojang official mappings, stored verbatim on the site.