package net.minecraft.client.renderer.entity;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.layers.CarriedBlockLayer;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.client.renderer.entity.layers.EnderEyesLayer;
import java.util.Random;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.client.model.EndermanModel;
import net.minecraft.world.entity.monster.EnderMan;

public class EndermanRenderer extends MobRenderer<EnderMan, EndermanModel<EnderMan>> {
    private static final ResourceLocation ENDERMAN_LOCATION;
    private final Random random;
    
    public EndermanRenderer(final EntityRenderDispatcher dvf) {
        super(dvf, new EndermanModel(0.0f), 0.5f);
        this.random = new Random();
        this.addLayer((RenderLayer<EnderMan, EndermanModel<EnderMan>>)new EnderEyesLayer((RenderLayerParent<LivingEntity, EndermanModel<LivingEntity>>)this));
        this.addLayer(new CarriedBlockLayer(this));
    }
    
    @Override
    public void render(final EnderMan awm, final float float2, final float float3, final PoseStack cyl, final MultiBufferSource dqt, final int integer) {
        final BlockState byj8 = awm.getCarriedBlock();
        final EndermanModel<EnderMan> dky9 = ((LivingEntityRenderer<T, EndermanModel<EnderMan>>)this).getModel();
        dky9.carrying = (byj8 != null);
        dky9.creepy = awm.isCreepy();
        super.render(awm, float2, float3, cyl, dqt, integer);
    }
    
    public Vec3 getRenderOffset(final EnderMan awm, final float float2) {
        if (awm.isCreepy()) {
            final double double4 = 0.02;
            return new Vec3(this.random.nextGaussian() * 0.02, 0.0, this.random.nextGaussian() * 0.02);
        }
        return super.getRenderOffset((T)awm, float2);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final EnderMan awm) {
        return EndermanRenderer.ENDERMAN_LOCATION;
    }
    
    static {
        ENDERMAN_LOCATION = new ResourceLocation("textures/entity/enderman/enderman.png");
    }
}
