package net.minecraft.client.renderer.entity.layers;

import net.minecraft.world.entity.Entity;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.entity.ParrotRenderer;
import net.minecraft.world.entity.EntityType;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.model.ParrotModel;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.world.entity.player.Player;

public class ParrotOnShoulderLayer<T extends Player> extends RenderLayer<T, PlayerModel<T>> {
    private final ParrotModel model;
    
    public ParrotOnShoulderLayer(final RenderLayerParent<T, PlayerModel<T>> eid) {
        super(eid);
        this.model = new ParrotModel();
    }
    
    @Override
    public void render(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final T bec, final float float5, final float float6, final float float7, final float float8, final float float9, final float float10) {
        this.render(dhl, ebz, integer, bec, float5, float6, float9, float10, true);
        this.render(dhl, ebz, integer, bec, float5, float6, float9, float10, false);
    }
    
    private void render(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final T bec, final float float5, final float float6, final float float7, final float float8, final boolean boolean9) {
        final CompoundTag le11 = boolean9 ? bec.getShoulderEntityLeft() : bec.getShoulderEntityRight();
        final CompoundTag compoundTag;
        final VertexConsumer dhp13;
        EntityType.byString(le11.getString("id")).filter(aoq -> aoq == EntityType.PARROT).ifPresent(aoq -> {
            dhl.pushPose();
            dhl.translate(boolean9 ? 0.4000000059604645 : -0.4000000059604645, bec.isCrouching() ? -1.2999999523162842 : -1.5, 0.0);
            dhp13 = ebz.getBuffer(this.model.renderType(ParrotRenderer.PARROT_LOCATIONS[compoundTag.getInt("Variant")]));
            this.model.renderOnShoulder(dhl, dhp13, integer, OverlayTexture.NO_OVERLAY, float5, float6, float7, float8, bec.tickCount);
            dhl.popPose();
        });
    }
}
