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

44 lines
2 KiB
Java

package net.minecraft.client.renderer.entity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.FoxModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.entity.layers.FoxHeldItemLayer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.animal.Fox;
@Environment(EnvType.CLIENT)
public class FoxRenderer extends MobRenderer<Fox, FoxModel<Fox>> {
private static final ResourceLocation RED_FOX_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fox/fox.png");
private static final ResourceLocation RED_FOX_SLEEP_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fox/fox_sleep.png");
private static final ResourceLocation SNOW_FOX_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fox/snow_fox.png");
private static final ResourceLocation SNOW_FOX_SLEEP_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fox/snow_fox_sleep.png");
public FoxRenderer(EntityRendererProvider.Context context) {
super(context, new FoxModel<>(context.bakeLayer(ModelLayers.FOX)), 0.4F);
this.addLayer(new FoxHeldItemLayer(this, context.getItemInHandRenderer()));
}
protected void setupRotations(Fox entity, PoseStack poseStack, float bob, float yBodyRot, float partialTick, float scale) {
super.setupRotations(entity, poseStack, bob, yBodyRot, partialTick, scale);
if (entity.isPouncing() || entity.isFaceplanted()) {
float f = -Mth.lerp(partialTick, entity.xRotO, entity.getXRot());
poseStack.mulPose(Axis.XP.rotationDegrees(f));
}
}
/**
* Returns the location of an entity's texture.
*/
public ResourceLocation getTextureLocation(Fox entity) {
if (entity.getVariant() == Fox.Type.RED) {
return entity.isSleeping() ? RED_FOX_SLEEP_TEXTURE : RED_FOX_TEXTURE;
} else {
return entity.isSleeping() ? SNOW_FOX_SLEEP_TEXTURE : SNOW_FOX_TEXTURE;
}
}
}