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

68 lines
3.1 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.google.common.collect.Maps
*/
package net.minecraft.client.renderer.entity;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.vertex.PoseStack;
import java.util.Map;
import net.minecraft.client.model.AdultAndBabyModelPair;
import net.minecraft.client.model.ChickenModel;
import net.minecraft.client.model.ColdChickenModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.state.ChickenRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
import net.minecraft.resources.Identifier;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.animal.Chicken;
import net.minecraft.world.entity.animal.ChickenVariant;
public class ChickenRenderer
extends MobRenderer<Chicken, ChickenRenderState, ChickenModel> {
private final Map<ChickenVariant.ModelType, AdultAndBabyModelPair<ChickenModel>> models;
public ChickenRenderer(EntityRendererProvider.Context context) {
super(context, new ChickenModel(context.bakeLayer(ModelLayers.CHICKEN)), 0.3f);
this.models = ChickenRenderer.bakeModels(context);
}
private static Map<ChickenVariant.ModelType, AdultAndBabyModelPair<ChickenModel>> bakeModels(EntityRendererProvider.Context context) {
return Maps.newEnumMap(Map.of(ChickenVariant.ModelType.NORMAL, new AdultAndBabyModelPair<ChickenModel>(new ChickenModel(context.bakeLayer(ModelLayers.CHICKEN)), new ChickenModel(context.bakeLayer(ModelLayers.CHICKEN_BABY))), ChickenVariant.ModelType.COLD, new AdultAndBabyModelPair<ColdChickenModel>(new ColdChickenModel(context.bakeLayer(ModelLayers.COLD_CHICKEN)), new ColdChickenModel(context.bakeLayer(ModelLayers.COLD_CHICKEN_BABY)))));
}
@Override
public void submit(ChickenRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) {
if (state.variant == null) {
return;
}
this.model = this.models.get(state.variant.modelAndTexture().model()).getModel(state.isBaby);
super.submit(state, poseStack, submitNodeCollector, camera);
}
@Override
public Identifier getTextureLocation(ChickenRenderState state) {
return state.variant == null ? MissingTextureAtlasSprite.getLocation() : state.variant.modelAndTexture().asset().texturePath();
}
@Override
public ChickenRenderState createRenderState() {
return new ChickenRenderState();
}
@Override
public void extractRenderState(Chicken entity, ChickenRenderState state, float partialTicks) {
super.extractRenderState(entity, state, partialTicks);
state.flap = Mth.lerp(partialTicks, entity.oFlap, entity.flap);
state.flapSpeed = Mth.lerp(partialTicks, entity.oFlapSpeed, entity.flapSpeed);
state.variant = entity.getVariant().value();
}
}