64 lines
2.9 KiB
Java
64 lines
2.9 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.CowModel;
|
|
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.CowRenderState;
|
|
import net.minecraft.client.renderer.state.CameraRenderState;
|
|
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.world.entity.animal.Cow;
|
|
import net.minecraft.world.entity.animal.CowVariant;
|
|
|
|
public class CowRenderer
|
|
extends MobRenderer<Cow, CowRenderState, CowModel> {
|
|
private final Map<CowVariant.ModelType, AdultAndBabyModelPair<CowModel>> models;
|
|
|
|
public CowRenderer(EntityRendererProvider.Context context) {
|
|
super(context, new CowModel(context.bakeLayer(ModelLayers.COW)), 0.7f);
|
|
this.models = CowRenderer.bakeModels(context);
|
|
}
|
|
|
|
private static Map<CowVariant.ModelType, AdultAndBabyModelPair<CowModel>> bakeModels(EntityRendererProvider.Context context) {
|
|
return Maps.newEnumMap(Map.of(CowVariant.ModelType.NORMAL, new AdultAndBabyModelPair<CowModel>(new CowModel(context.bakeLayer(ModelLayers.COW)), new CowModel(context.bakeLayer(ModelLayers.COW_BABY))), CowVariant.ModelType.WARM, new AdultAndBabyModelPair<CowModel>(new CowModel(context.bakeLayer(ModelLayers.WARM_COW)), new CowModel(context.bakeLayer(ModelLayers.WARM_COW_BABY))), CowVariant.ModelType.COLD, new AdultAndBabyModelPair<CowModel>(new CowModel(context.bakeLayer(ModelLayers.COLD_COW)), new CowModel(context.bakeLayer(ModelLayers.COLD_COW_BABY)))));
|
|
}
|
|
|
|
@Override
|
|
public Identifier getTextureLocation(CowRenderState state) {
|
|
return state.variant == null ? MissingTextureAtlasSprite.getLocation() : state.variant.modelAndTexture().asset().texturePath();
|
|
}
|
|
|
|
@Override
|
|
public CowRenderState createRenderState() {
|
|
return new CowRenderState();
|
|
}
|
|
|
|
@Override
|
|
public void extractRenderState(Cow entity, CowRenderState state, float partialTicks) {
|
|
super.extractRenderState(entity, state, partialTicks);
|
|
state.variant = entity.getVariant().value();
|
|
}
|
|
|
|
@Override
|
|
public void submit(CowRenderState 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);
|
|
}
|
|
}
|
|
|