minecraft-src/net/minecraft/client/renderer/entity/ParrotRenderer.java
2025-07-04 01:41:11 +03:00

48 lines
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.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.animal.Parrot;
@Environment(EnvType.CLIENT)
public class ParrotRenderer extends MobRenderer<Parrot, 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);
}
/**
* Returns the location of an entity's texture.
*/
public ResourceLocation getTextureLocation(Parrot entity) {
return getVariantTexture(entity.getVariant());
}
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;
};
}
/**
* Defines what float the third param in setRotationAngles of ModelBase is
*/
public float getBob(Parrot livingBase, float partialTicks) {
float f = Mth.lerp(partialTicks, livingBase.oFlap, livingBase.flap);
float g = Mth.lerp(partialTicks, livingBase.oFlapSpeed, livingBase.flapSpeed);
return (Mth.sin(f) + 1.0F) * g;
}
}