53 lines
2.1 KiB
Java
53 lines
2.1 KiB
Java
package net.minecraft.client.renderer.entity;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
|
import com.mojang.math.Axis;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.model.EvokerFangsModel;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.entity.projectile.EvokerFangs;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class EvokerFangsRenderer extends EntityRenderer<EvokerFangs> {
|
|
private static final ResourceLocation TEXTURE_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/illager/evoker_fangs.png");
|
|
private final EvokerFangsModel<EvokerFangs> model;
|
|
|
|
public EvokerFangsRenderer(EntityRendererProvider.Context context) {
|
|
super(context);
|
|
this.model = new EvokerFangsModel<>(context.bakeLayer(ModelLayers.EVOKER_FANGS));
|
|
}
|
|
|
|
public void render(EvokerFangs entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
|
|
float f = entity.getAnimationProgress(partialTicks);
|
|
if (f != 0.0F) {
|
|
float g = 2.0F;
|
|
if (f > 0.9F) {
|
|
g *= (1.0F - f) / 0.1F;
|
|
}
|
|
|
|
poseStack.pushPose();
|
|
poseStack.mulPose(Axis.YP.rotationDegrees(90.0F - entity.getYRot()));
|
|
poseStack.scale(-g, -g, g);
|
|
float h = 0.03125F;
|
|
poseStack.translate(0.0, -0.626, 0.0);
|
|
poseStack.scale(0.5F, 0.5F, 0.5F);
|
|
this.model.setupAnim(entity, f, 0.0F, 0.0F, entity.getYRot(), entity.getXRot());
|
|
VertexConsumer vertexConsumer = buffer.getBuffer(this.model.renderType(TEXTURE_LOCATION));
|
|
this.model.renderToBuffer(poseStack, vertexConsumer, packedLight, OverlayTexture.NO_OVERLAY);
|
|
poseStack.popPose();
|
|
super.render(entity, entityYaw, partialTicks, poseStack, buffer, packedLight);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the location of an entity's texture.
|
|
*/
|
|
public ResourceLocation getTextureLocation(EvokerFangs entity) {
|
|
return TEXTURE_LOCATION;
|
|
}
|
|
}
|