/* * 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.joml.Vector3f * 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.HashSet; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.block.model.TextureSlots; import net.minecraft.client.renderer.item.ItemModel; import net.minecraft.client.renderer.item.ItemModelResolver; import net.minecraft.client.renderer.item.ItemStackRenderState; import net.minecraft.client.renderer.item.ModelRenderProperties; import net.minecraft.client.renderer.special.SpecialModelRenderer; import net.minecraft.client.renderer.special.SpecialModelRenderers; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ResolvableModel; import net.minecraft.client.resources.model.ResolvedModel; import net.minecraft.resources.Identifier; import net.minecraft.world.entity.ItemOwner; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import org.joml.Vector3f; import org.jspecify.annotations.Nullable; public class SpecialModelWrapper implements ItemModel { private final SpecialModelRenderer specialRenderer; private final ModelRenderProperties properties; public SpecialModelWrapper(SpecialModelRenderer specialRenderer, ModelRenderProperties properties) { this.specialRenderer = specialRenderer; this.properties = properties; } @Override public void update(ItemStackRenderState output, ItemStack item, ItemModelResolver resolver, ItemDisplayContext displayContext, @Nullable ClientLevel level, @Nullable ItemOwner owner, int seed) { output.appendModelIdentityElement(this); ItemStackRenderState.LayerRenderState layer = output.newLayer(); if (item.hasFoil()) { ItemStackRenderState.FoilType foilType = ItemStackRenderState.FoilType.STANDARD; layer.setFoilType(foilType); output.setAnimated(); output.appendModelIdentityElement((Object)foilType); } T argument = this.specialRenderer.extractArgument(item); layer.setExtents(() -> { HashSet results = new HashSet(); this.specialRenderer.getExtents(results); return results.toArray(new Vector3f[0]); }); layer.setupSpecialModel(this.specialRenderer, argument); if (argument != null) { output.appendModelIdentityElement(argument); } this.properties.applyToLayer(layer, displayContext); } public record Unbaked(Identifier base, SpecialModelRenderer.Unbaked specialModel) implements ItemModel.Unbaked { public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)Identifier.CODEC.fieldOf("base").forGetter(Unbaked::base), (App)SpecialModelRenderers.CODEC.fieldOf("model").forGetter(Unbaked::specialModel)).apply((Applicative)i, Unbaked::new)); @Override public void resolveDependencies(ResolvableModel.Resolver resolver) { resolver.markDependency(this.base); } @Override public ItemModel bake(ItemModel.BakingContext context) { SpecialModelRenderer bakedSpecialModel = this.specialModel.bake(context); if (bakedSpecialModel == null) { return context.missingItemModel(); } ModelRenderProperties properties = this.getProperties(context); return new SpecialModelWrapper(bakedSpecialModel, properties); } private ModelRenderProperties getProperties(ItemModel.BakingContext context) { ModelBaker baker = context.blockModelBaker(); ResolvedModel model = baker.getModel(this.base); TextureSlots textureSlots = model.getTopTextureSlots(); return ModelRenderProperties.fromResolvedModel(baker, model, textureSlots); } public MapCodec type() { return MAP_CODEC; } } }