/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.serialization.Codec * com.mojang.serialization.MapCodec * com.mojang.serialization.codecs.RecordCodecBuilder */ package net.minecraft.world.item.slot; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import java.util.List; import java.util.function.Function; import net.minecraft.util.ProblemReporter; import net.minecraft.world.item.slot.SlotCollection; import net.minecraft.world.item.slot.SlotSource; import net.minecraft.world.item.slot.SlotSources; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.ValidationContext; public abstract class CompositeSlotSource implements SlotSource { protected final List terms; private final Function compositeSlotSource; protected CompositeSlotSource(List terms) { this.terms = terms; this.compositeSlotSource = SlotSources.group(terms); } protected static MapCodec createCodec(Function, T> factory) { return RecordCodecBuilder.mapCodec(i -> i.group((App)SlotSources.CODEC.listOf().fieldOf("terms").forGetter(t -> t.terms)).apply((Applicative)i, factory)); } protected static Codec createInlineCodec(Function, T> factory) { return SlotSources.CODEC.listOf().xmap(factory, t -> t.terms); } public abstract MapCodec codec(); @Override public SlotCollection provide(LootContext context) { return this.compositeSlotSource.apply(context); } @Override public void validate(ValidationContext context) { SlotSource.super.validate(context); for (int i = 0; i < this.terms.size(); ++i) { this.terms.get(i).validate(context.forChild(new ProblemReporter.IndexedFieldPathElement("terms", i))); } } }