53 lines
2.4 KiB
Java
53 lines
2.4 KiB
Java
package net.minecraft.client.renderer.entity;
|
|
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.model.CamelModel;
|
|
import net.minecraft.client.model.CamelSaddleModel;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.renderer.entity.EntityRendererProvider.Context;
|
|
import net.minecraft.client.renderer.entity.layers.SimpleEquipmentLayer;
|
|
import net.minecraft.client.renderer.entity.state.CamelRenderState;
|
|
import net.minecraft.client.resources.model.EquipmentClientInfo;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.entity.EquipmentSlot;
|
|
import net.minecraft.world.entity.animal.camel.Camel;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class CamelRenderer extends AgeableMobRenderer<Camel, CamelRenderState, CamelModel> {
|
|
private static final ResourceLocation CAMEL_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/camel/camel.png");
|
|
|
|
public CamelRenderer(Context context) {
|
|
super(context, new CamelModel(context.bakeLayer(ModelLayers.CAMEL)), new CamelModel(context.bakeLayer(ModelLayers.CAMEL_BABY)), 0.7F);
|
|
this.addLayer(
|
|
new SimpleEquipmentLayer<>(
|
|
this,
|
|
context.getEquipmentRenderer(),
|
|
EquipmentClientInfo.LayerType.CAMEL_SADDLE,
|
|
camelRenderState -> camelRenderState.saddle,
|
|
new CamelSaddleModel(context.bakeLayer(ModelLayers.CAMEL_SADDLE)),
|
|
new CamelSaddleModel(context.bakeLayer(ModelLayers.CAMEL_BABY_SADDLE))
|
|
)
|
|
);
|
|
}
|
|
|
|
public ResourceLocation getTextureLocation(CamelRenderState camelRenderState) {
|
|
return CAMEL_LOCATION;
|
|
}
|
|
|
|
public CamelRenderState createRenderState() {
|
|
return new CamelRenderState();
|
|
}
|
|
|
|
public void extractRenderState(Camel camel, CamelRenderState camelRenderState, float f) {
|
|
super.extractRenderState(camel, camelRenderState, f);
|
|
camelRenderState.saddle = camel.getItemBySlot(EquipmentSlot.SADDLE).copy();
|
|
camelRenderState.isRidden = camel.isVehicle();
|
|
camelRenderState.jumpCooldown = Math.max(camel.getJumpCooldown() - f, 0.0F);
|
|
camelRenderState.sitAnimationState.copyFrom(camel.sitAnimationState);
|
|
camelRenderState.sitPoseAnimationState.copyFrom(camel.sitPoseAnimationState);
|
|
camelRenderState.sitUpAnimationState.copyFrom(camel.sitUpAnimationState);
|
|
camelRenderState.idleAnimationState.copyFrom(camel.idleAnimationState);
|
|
camelRenderState.dashAnimationState.copyFrom(camel.dashAnimationState);
|
|
}
|
|
}
|