45 lines
1.5 KiB
Java
45 lines
1.5 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.SalmonModel;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.entity.animal.Salmon;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class SalmonRenderer extends MobRenderer<Salmon, SalmonModel<Salmon>> {
|
|
private static final ResourceLocation SALMON_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/fish/salmon.png");
|
|
|
|
public SalmonRenderer(EntityRendererProvider.Context context) {
|
|
super(context, new SalmonModel<>(context.bakeLayer(ModelLayers.SALMON)), 0.4F);
|
|
}
|
|
|
|
/**
|
|
* Returns the location of an entity's texture.
|
|
*/
|
|
public ResourceLocation getTextureLocation(Salmon entity) {
|
|
return SALMON_LOCATION;
|
|
}
|
|
|
|
protected void setupRotations(Salmon entity, PoseStack poseStack, float bob, float yBodyRot, float partialTick, float scale) {
|
|
super.setupRotations(entity, poseStack, bob, yBodyRot, partialTick, scale);
|
|
float f = 1.0F;
|
|
float g = 1.0F;
|
|
if (!entity.isInWater()) {
|
|
f = 1.3F;
|
|
g = 1.7F;
|
|
}
|
|
|
|
float h = f * 4.3F * Mth.sin(g * 0.6F * bob);
|
|
poseStack.mulPose(Axis.YP.rotationDegrees(h));
|
|
poseStack.translate(0.0F, 0.0F, -0.4F);
|
|
if (!entity.isInWater()) {
|
|
poseStack.translate(0.2F, 0.1F, 0.0F);
|
|
poseStack.mulPose(Axis.ZP.rotationDegrees(90.0F));
|
|
}
|
|
}
|
|
}
|