2025-11-24 22:52:51 +03:00

70 lines
3.0 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.joml.Quaternionfc
*/
package net.minecraft.client.renderer.entity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.model.FoxModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.entity.AgeableMobRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.layers.FoxHeldItemLayer;
import net.minecraft.client.renderer.entity.state.FoxRenderState;
import net.minecraft.client.renderer.entity.state.HoldingEntityRenderState;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.animal.Fox;
import org.joml.Quaternionfc;
public class FoxRenderer
extends AgeableMobRenderer<Fox, FoxRenderState, FoxModel> {
private static final Identifier RED_FOX_TEXTURE = Identifier.withDefaultNamespace("textures/entity/fox/fox.png");
private static final Identifier RED_FOX_SLEEP_TEXTURE = Identifier.withDefaultNamespace("textures/entity/fox/fox_sleep.png");
private static final Identifier SNOW_FOX_TEXTURE = Identifier.withDefaultNamespace("textures/entity/fox/snow_fox.png");
private static final Identifier SNOW_FOX_SLEEP_TEXTURE = Identifier.withDefaultNamespace("textures/entity/fox/snow_fox_sleep.png");
public FoxRenderer(EntityRendererProvider.Context context) {
super(context, new FoxModel(context.bakeLayer(ModelLayers.FOX)), new FoxModel(context.bakeLayer(ModelLayers.FOX_BABY)), 0.4f);
this.addLayer(new FoxHeldItemLayer(this));
}
@Override
protected void setupRotations(FoxRenderState state, PoseStack poseStack, float bodyRot, float entityScale) {
super.setupRotations(state, poseStack, bodyRot, entityScale);
if (state.isPouncing || state.isFaceplanted) {
poseStack.mulPose((Quaternionfc)Axis.XP.rotationDegrees(-state.xRot));
}
}
@Override
public Identifier getTextureLocation(FoxRenderState state) {
if (state.variant == Fox.Variant.RED) {
return state.isSleeping ? RED_FOX_SLEEP_TEXTURE : RED_FOX_TEXTURE;
}
return state.isSleeping ? SNOW_FOX_SLEEP_TEXTURE : SNOW_FOX_TEXTURE;
}
@Override
public FoxRenderState createRenderState() {
return new FoxRenderState();
}
@Override
public void extractRenderState(Fox entity, FoxRenderState state, float partialTicks) {
super.extractRenderState(entity, state, partialTicks);
HoldingEntityRenderState.extractHoldingEntityRenderState(entity, state, this.itemModelResolver);
state.headRollAngle = entity.getHeadRollAngle(partialTicks);
state.isCrouching = entity.isCrouching();
state.crouchAmount = entity.getCrouchAmount(partialTicks);
state.isSleeping = entity.isSleeping();
state.isSitting = entity.isSitting();
state.isFaceplanted = entity.isFaceplanted();
state.isPouncing = entity.isPouncing();
state.variant = entity.getVariant();
}
}