2025-11-24 22:52:51 +03:00

68 lines
2.5 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.datafixers.kinds.App
* com.mojang.datafixers.kinds.Applicative
* com.mojang.serialization.MapCodec
* com.mojang.serialization.codecs.RecordCodecBuilder
* org.jspecify.annotations.Nullable
*/
package net.minecraft.client.renderer.item;
import com.mojang.datafixers.kinds.App;
import com.mojang.datafixers.kinds.Applicative;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.List;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.item.ItemModel;
import net.minecraft.client.renderer.item.ItemModelResolver;
import net.minecraft.client.renderer.item.ItemModels;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.client.resources.model.ResolvableModel;
import net.minecraft.world.entity.ItemOwner;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import org.jspecify.annotations.Nullable;
public class CompositeModel
implements ItemModel {
private final List<ItemModel> models;
public CompositeModel(List<ItemModel> models) {
this.models = models;
}
@Override
public void update(ItemStackRenderState output, ItemStack item, ItemModelResolver resolver, ItemDisplayContext displayContext, @Nullable ClientLevel level, @Nullable ItemOwner owner, int seed) {
output.appendModelIdentityElement(this);
output.ensureCapacity(this.models.size());
for (ItemModel model : this.models) {
model.update(output, item, resolver, displayContext, level, owner, seed);
}
}
public record Unbaked(List<ItemModel.Unbaked> models) implements ItemModel.Unbaked
{
public static final MapCodec<Unbaked> MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)ItemModels.CODEC.listOf().fieldOf("models").forGetter(Unbaked::models)).apply((Applicative)i, Unbaked::new));
public MapCodec<Unbaked> type() {
return MAP_CODEC;
}
@Override
public void resolveDependencies(ResolvableModel.Resolver resolver) {
for (ItemModel.Unbaked model : this.models) {
model.resolveDependencies(resolver);
}
}
@Override
public ItemModel bake(ItemModel.BakingContext context) {
return new CompositeModel(this.models.stream().map(m -> m.bake(context)).toList());
}
}
}