minecraft-src/net/minecraft/client/renderer/entity/ParrotRenderer.java
2025-07-04 02:49:36 +03:00

50 lines
2.2 KiB
Java

package net.minecraft.client.renderer.entity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.ParrotModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.entity.state.ParrotRenderState;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.animal.Parrot;
@Environment(EnvType.CLIENT)
public class ParrotRenderer extends MobRenderer<Parrot, ParrotRenderState, ParrotModel> {
private static final ResourceLocation RED_BLUE = ResourceLocation.withDefaultNamespace("textures/entity/parrot/parrot_red_blue.png");
private static final ResourceLocation BLUE = ResourceLocation.withDefaultNamespace("textures/entity/parrot/parrot_blue.png");
private static final ResourceLocation GREEN = ResourceLocation.withDefaultNamespace("textures/entity/parrot/parrot_green.png");
private static final ResourceLocation YELLOW_BLUE = ResourceLocation.withDefaultNamespace("textures/entity/parrot/parrot_yellow_blue.png");
private static final ResourceLocation GREY = ResourceLocation.withDefaultNamespace("textures/entity/parrot/parrot_grey.png");
public ParrotRenderer(EntityRendererProvider.Context context) {
super(context, new ParrotModel(context.bakeLayer(ModelLayers.PARROT)), 0.3F);
}
public ResourceLocation getTextureLocation(ParrotRenderState renderState) {
return getVariantTexture(renderState.variant);
}
public ParrotRenderState createRenderState() {
return new ParrotRenderState();
}
public void extractRenderState(Parrot entity, ParrotRenderState reusedState, float partialTick) {
super.extractRenderState(entity, reusedState, partialTick);
reusedState.variant = entity.getVariant();
float f = Mth.lerp(partialTick, entity.oFlap, entity.flap);
float g = Mth.lerp(partialTick, entity.oFlapSpeed, entity.flapSpeed);
reusedState.flapAngle = (Mth.sin(f) + 1.0F) * g;
reusedState.pose = ParrotModel.getPose(entity);
}
public static ResourceLocation getVariantTexture(Parrot.Variant variant) {
return switch (variant) {
case RED_BLUE -> RED_BLUE;
case BLUE -> BLUE;
case GREEN -> GREEN;
case YELLOW_BLUE -> YELLOW_BLUE;
case GRAY -> GREY;
};
}
}