package net.minecraft.client.renderer;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CrossbowItem;
import net.minecraft.world.item.Items;
import com.google.common.base.MoreObjects;
import net.minecraft.world.InteractionHand;
import com.mojang.math.Matrix4f;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.MapItem;
import net.minecraft.client.player.AbstractClientPlayer;
import com.mojang.math.Vector3f;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.util.Mth;
import net.minecraft.client.renderer.texture.OverlayTexture;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.world.item.ItemStack;
import net.minecraft.client.Minecraft;

public class ItemInHandRenderer {
    private static final RenderType MAP_BACKGROUND;
    private static final RenderType MAP_BACKGROUND_CHECKERBOARD;
    private final Minecraft minecraft;
    private ItemStack mainHandItem;
    private ItemStack offHandItem;
    private float mainHandHeight;
    private float oMainHandHeight;
    private float offHandHeight;
    private float oOffHandHeight;
    private final EntityRenderDispatcher entityRenderDispatcher;
    private final ItemRenderer itemRenderer;
    
    public ItemInHandRenderer(final Minecraft dlx) {
        this.mainHandItem = ItemStack.EMPTY;
        this.offHandItem = ItemStack.EMPTY;
        this.minecraft = dlx;
        this.entityRenderDispatcher = dlx.getEntityRenderDispatcher();
        this.itemRenderer = dlx.getItemRenderer();
    }
    
    public void renderItem(final LivingEntity aoy, final ItemStack bki, final ItemTransforms.TransformType b, final boolean boolean4, final PoseStack dhl, final MultiBufferSource ebz, final int integer) {
        if (bki.isEmpty()) {
            return;
        }
        this.itemRenderer.renderStatic(aoy, bki, b, boolean4, dhl, ebz, aoy.level, integer, OverlayTexture.NO_OVERLAY);
    }
    
    private float calculateMapTilt(final float float1) {
        float float2 = 1.0f - float1 / 45.0f + 0.1f;
        float2 = Mth.clamp(float2, 0.0f, 1.0f);
        float2 = -Mth.cos(float2 * 3.1415927f) * 0.5f + 0.5f;
        return float2;
    }
    
    private void renderMapHand(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final HumanoidArm aou) {
        this.minecraft.getTextureManager().bind(this.minecraft.player.getSkinTextureLocation());
        final PlayerRenderer eld6 = (PlayerRenderer)this.entityRenderDispatcher.<LocalPlayer>getRenderer(this.minecraft.player);
        dhl.pushPose();
        final float float7 = (aou == HumanoidArm.RIGHT) ? 1.0f : -1.0f;
        dhl.mulPose(Vector3f.YP.rotationDegrees(92.0f));
        dhl.mulPose(Vector3f.XP.rotationDegrees(45.0f));
        dhl.mulPose(Vector3f.ZP.rotationDegrees(float7 * -41.0f));
        dhl.translate(float7 * 0.3f, -1.100000023841858, 0.44999998807907104);
        if (aou == HumanoidArm.RIGHT) {
            eld6.renderRightHand(dhl, ebz, integer, this.minecraft.player);
        }
        else {
            eld6.renderLeftHand(dhl, ebz, integer, this.minecraft.player);
        }
        dhl.popPose();
    }
    
    private void renderOneHandedMap(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final float float4, final HumanoidArm aou, final float float6, final ItemStack bki) {
        final float float7 = (aou == HumanoidArm.RIGHT) ? 1.0f : -1.0f;
        dhl.translate(float7 * 0.125f, -0.125, 0.0);
        if (!this.minecraft.player.isInvisible()) {
            dhl.pushPose();
            dhl.mulPose(Vector3f.ZP.rotationDegrees(float7 * 10.0f));
            this.renderPlayerArm(dhl, ebz, integer, float4, float6, aou);
            dhl.popPose();
        }
        dhl.pushPose();
        dhl.translate(float7 * 0.51f, -0.08f + float4 * -1.2f, -0.75);
        final float float8 = Mth.sqrt(float6);
        final float float9 = Mth.sin(float8 * 3.1415927f);
        final float float10 = -0.5f * float9;
        final float float11 = 0.4f * Mth.sin(float8 * 6.2831855f);
        final float float12 = -0.3f * Mth.sin(float6 * 3.1415927f);
        dhl.translate(float7 * float10, float11 - 0.3f * float9, float12);
        dhl.mulPose(Vector3f.XP.rotationDegrees(float9 * -45.0f));
        dhl.mulPose(Vector3f.YP.rotationDegrees(float7 * float9 * -30.0f));
        this.renderMap(dhl, ebz, integer, bki);
        dhl.popPose();
    }
    
    private void renderTwoHandedMap(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final float float4, final float float5, final float float6) {
        final float float7 = Mth.sqrt(float6);
        final float float8 = -0.2f * Mth.sin(float6 * 3.1415927f);
        final float float9 = -0.4f * Mth.sin(float7 * 3.1415927f);
        dhl.translate(0.0, -float8 / 2.0f, float9);
        final float float10 = this.calculateMapTilt(float4);
        dhl.translate(0.0, 0.04f + float5 * -1.2f + float10 * -0.5f, -0.7200000286102295);
        dhl.mulPose(Vector3f.XP.rotationDegrees(float10 * -85.0f));
        if (!this.minecraft.player.isInvisible()) {
            dhl.pushPose();
            dhl.mulPose(Vector3f.YP.rotationDegrees(90.0f));
            this.renderMapHand(dhl, ebz, integer, HumanoidArm.RIGHT);
            this.renderMapHand(dhl, ebz, integer, HumanoidArm.LEFT);
            dhl.popPose();
        }
        final float float11 = Mth.sin(float7 * 3.1415927f);
        dhl.mulPose(Vector3f.XP.rotationDegrees(float11 * 20.0f));
        dhl.scale(2.0f, 2.0f, 2.0f);
        this.renderMap(dhl, ebz, integer, this.mainHandItem);
    }
    
    private void renderMap(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final ItemStack bki) {
        dhl.mulPose(Vector3f.YP.rotationDegrees(180.0f));
        dhl.mulPose(Vector3f.ZP.rotationDegrees(180.0f));
        dhl.scale(0.38f, 0.38f, 0.38f);
        dhl.translate(-0.5, -0.5, 0.0);
        dhl.scale(0.0078125f, 0.0078125f, 0.0078125f);
        final MapItemSavedData czv6 = MapItem.getOrCreateSavedData(bki, this.minecraft.level);
        final VertexConsumer dhp7 = ebz.getBuffer((czv6 == null) ? ItemInHandRenderer.MAP_BACKGROUND : ItemInHandRenderer.MAP_BACKGROUND_CHECKERBOARD);
        final Matrix4f b8 = dhl.last().pose();
        dhp7.vertex(b8, -7.0f, 135.0f, 0.0f).color(255, 255, 255, 255).uv(0.0f, 1.0f).uv2(integer).endVertex();
        dhp7.vertex(b8, 135.0f, 135.0f, 0.0f).color(255, 255, 255, 255).uv(1.0f, 1.0f).uv2(integer).endVertex();
        dhp7.vertex(b8, 135.0f, -7.0f, 0.0f).color(255, 255, 255, 255).uv(1.0f, 0.0f).uv2(integer).endVertex();
        dhp7.vertex(b8, -7.0f, -7.0f, 0.0f).color(255, 255, 255, 255).uv(0.0f, 0.0f).uv2(integer).endVertex();
        if (czv6 != null) {
            this.minecraft.gameRenderer.getMapRenderer().render(dhl, ebz, czv6, false, integer);
        }
    }
    
    private void renderPlayerArm(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final float float4, final float float5, final HumanoidArm aou) {
        final boolean boolean8 = aou != HumanoidArm.LEFT;
        final float float6 = boolean8 ? 1.0f : -1.0f;
        final float float7 = Mth.sqrt(float5);
        final float float8 = -0.3f * Mth.sin(float7 * 3.1415927f);
        final float float9 = 0.4f * Mth.sin(float7 * 6.2831855f);
        final float float10 = -0.4f * Mth.sin(float5 * 3.1415927f);
        dhl.translate(float6 * (float8 + 0.64000005f), float9 - 0.6f + float4 * -0.6f, float10 - 0.71999997f);
        dhl.mulPose(Vector3f.YP.rotationDegrees(float6 * 45.0f));
        final float float11 = Mth.sin(float5 * float5 * 3.1415927f);
        final float float12 = Mth.sin(float7 * 3.1415927f);
        dhl.mulPose(Vector3f.YP.rotationDegrees(float6 * float12 * 70.0f));
        dhl.mulPose(Vector3f.ZP.rotationDegrees(float6 * float11 * -20.0f));
        final AbstractClientPlayer ebc16 = this.minecraft.player;
        this.minecraft.getTextureManager().bind(ebc16.getSkinTextureLocation());
        dhl.translate(float6 * -1.0f, 3.5999999046325684, 3.5);
        dhl.mulPose(Vector3f.ZP.rotationDegrees(float6 * 120.0f));
        dhl.mulPose(Vector3f.XP.rotationDegrees(200.0f));
        dhl.mulPose(Vector3f.YP.rotationDegrees(float6 * -135.0f));
        dhl.translate(float6 * 5.6f, 0.0, 0.0);
        final PlayerRenderer eld17 = (PlayerRenderer)this.entityRenderDispatcher.<AbstractClientPlayer>getRenderer(ebc16);
        if (boolean8) {
            eld17.renderRightHand(dhl, ebz, integer, ebc16);
        }
        else {
            eld17.renderLeftHand(dhl, ebz, integer, ebc16);
        }
    }
    
    private void applyEatTransform(final PoseStack dhl, final float float2, final HumanoidArm aou, final ItemStack bki) {
        final float float3 = this.minecraft.player.getUseItemRemainingTicks() - float2 + 1.0f;
        final float float4 = float3 / bki.getUseDuration();
        if (float4 < 0.8f) {
            final float float5 = Mth.abs(Mth.cos(float3 / 4.0f * 3.1415927f) * 0.1f);
            dhl.translate(0.0, float5, 0.0);
        }
        final float float5 = 1.0f - (float)Math.pow(float4, 27.0);
        final int integer9 = (aou == HumanoidArm.RIGHT) ? 1 : -1;
        dhl.translate(float5 * 0.6f * integer9, float5 * -0.5f, float5 * 0.0f);
        dhl.mulPose(Vector3f.YP.rotationDegrees(integer9 * float5 * 90.0f));
        dhl.mulPose(Vector3f.XP.rotationDegrees(float5 * 10.0f));
        dhl.mulPose(Vector3f.ZP.rotationDegrees(integer9 * float5 * 30.0f));
    }
    
    private void applyItemArmAttackTransform(final PoseStack dhl, final HumanoidArm aou, final float float3) {
        final int integer5 = (aou == HumanoidArm.RIGHT) ? 1 : -1;
        final float float4 = Mth.sin(float3 * float3 * 3.1415927f);
        dhl.mulPose(Vector3f.YP.rotationDegrees(integer5 * (45.0f + float4 * -20.0f)));
        final float float5 = Mth.sin(Mth.sqrt(float3) * 3.1415927f);
        dhl.mulPose(Vector3f.ZP.rotationDegrees(integer5 * float5 * -20.0f));
        dhl.mulPose(Vector3f.XP.rotationDegrees(float5 * -80.0f));
        dhl.mulPose(Vector3f.YP.rotationDegrees(integer5 * -45.0f));
    }
    
    private void applyItemArmTransform(final PoseStack dhl, final HumanoidArm aou, final float float3) {
        final int integer5 = (aou == HumanoidArm.RIGHT) ? 1 : -1;
        dhl.translate(integer5 * 0.56f, -0.52f + float3 * -0.6f, -0.7200000286102295);
    }
    
    public void renderHandsWithItems(final float float1, final PoseStack dhl, final MultiBufferSource.BufferSource a, final LocalPlayer ebf, final int integer) {
        final float float2 = ebf.getAttackAnim(float1);
        final InteractionHand anf8 = MoreObjects.<InteractionHand>firstNonNull(ebf.swingingArm, InteractionHand.MAIN_HAND);
        final float float3 = Mth.lerp(float1, ebf.xRotO, ebf.xRot);
        boolean boolean10 = true;
        boolean boolean11 = true;
        if (ebf.isUsingItem()) {
            final ItemStack bki12 = ebf.getUseItem();
            if (bki12.getItem() == Items.BOW || bki12.getItem() == Items.CROSSBOW) {
                boolean10 = (ebf.getUsedItemHand() == InteractionHand.MAIN_HAND);
                boolean11 = !boolean10;
            }
            final InteractionHand anf9 = ebf.getUsedItemHand();
            if (anf9 == InteractionHand.MAIN_HAND) {
                final ItemStack bki13 = ebf.getOffhandItem();
                if (bki13.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(bki13)) {
                    boolean11 = false;
                }
            }
        }
        else {
            final ItemStack bki12 = ebf.getMainHandItem();
            final ItemStack bki14 = ebf.getOffhandItem();
            if (bki12.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(bki12)) {
                boolean11 = !boolean10;
            }
            if (bki14.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(bki14)) {
                boolean10 = !bki12.isEmpty();
                boolean11 = !boolean10;
            }
        }
        final float float4 = Mth.lerp(float1, ebf.xBobO, ebf.xBob);
        final float float5 = Mth.lerp(float1, ebf.yBobO, ebf.yBob);
        dhl.mulPose(Vector3f.XP.rotationDegrees((ebf.getViewXRot(float1) - float4) * 0.1f));
        dhl.mulPose(Vector3f.YP.rotationDegrees((ebf.getViewYRot(float1) - float5) * 0.1f));
        if (boolean10) {
            final float float6 = (anf8 == InteractionHand.MAIN_HAND) ? float2 : 0.0f;
            final float float7 = 1.0f - Mth.lerp(float1, this.oMainHandHeight, this.mainHandHeight);
            this.renderArmWithItem(ebf, float1, float3, InteractionHand.MAIN_HAND, float6, this.mainHandItem, float7, dhl, a, integer);
        }
        if (boolean11) {
            final float float6 = (anf8 == InteractionHand.OFF_HAND) ? float2 : 0.0f;
            final float float7 = 1.0f - Mth.lerp(float1, this.oOffHandHeight, this.offHandHeight);
            this.renderArmWithItem(ebf, float1, float3, InteractionHand.OFF_HAND, float6, this.offHandItem, float7, dhl, a, integer);
        }
        a.endBatch();
    }
    
    private void renderArmWithItem(final AbstractClientPlayer ebc, final float float2, final float float3, final InteractionHand anf, final float float5, final ItemStack bki, final float float7, final PoseStack dhl, final MultiBufferSource ebz, final int integer) {
        final boolean boolean12 = anf == InteractionHand.MAIN_HAND;
        final HumanoidArm aou13 = boolean12 ? ebc.getMainArm() : ebc.getMainArm().getOpposite();
        dhl.pushPose();
        if (bki.isEmpty()) {
            if (boolean12 && !ebc.isInvisible()) {
                this.renderPlayerArm(dhl, ebz, integer, float7, float5, aou13);
            }
        }
        else if (bki.getItem() == Items.FILLED_MAP) {
            if (boolean12 && this.offHandItem.isEmpty()) {
                this.renderTwoHandedMap(dhl, ebz, integer, float3, float7, float5);
            }
            else {
                this.renderOneHandedMap(dhl, ebz, integer, float7, aou13, float5, bki);
            }
        }
        else if (bki.getItem() == Items.CROSSBOW) {
            final boolean boolean13 = CrossbowItem.isCharged(bki);
            final boolean boolean14 = aou13 == HumanoidArm.RIGHT;
            final int integer2 = boolean14 ? 1 : -1;
            if (ebc.isUsingItem() && ebc.getUseItemRemainingTicks() > 0 && ebc.getUsedItemHand() == anf) {
                this.applyItemArmTransform(dhl, aou13, float7);
                dhl.translate(integer2 * -0.4785682f, -0.0943870022892952, 0.05731530860066414);
                dhl.mulPose(Vector3f.XP.rotationDegrees(-11.935f));
                dhl.mulPose(Vector3f.YP.rotationDegrees(integer2 * 65.3f));
                dhl.mulPose(Vector3f.ZP.rotationDegrees(integer2 * -9.785f));
                final float float8 = bki.getUseDuration() - (this.minecraft.player.getUseItemRemainingTicks() - float2 + 1.0f);
                float float9 = float8 / CrossbowItem.getChargeDuration(bki);
                if (float9 > 1.0f) {
                    float9 = 1.0f;
                }
                if (float9 > 0.1f) {
                    final float float10 = Mth.sin((float8 - 0.1f) * 1.3f);
                    final float float11 = float9 - 0.1f;
                    final float float12 = float10 * float11;
                    dhl.translate(float12 * 0.0f, float12 * 0.004f, float12 * 0.0f);
                }
                dhl.translate(float9 * 0.0f, float9 * 0.0f, float9 * 0.04f);
                dhl.scale(1.0f, 1.0f, 1.0f + float9 * 0.2f);
                dhl.mulPose(Vector3f.YN.rotationDegrees(integer2 * 45.0f));
            }
            else {
                final float float8 = -0.4f * Mth.sin(Mth.sqrt(float5) * 3.1415927f);
                final float float9 = 0.2f * Mth.sin(Mth.sqrt(float5) * 6.2831855f);
                final float float10 = -0.2f * Mth.sin(float5 * 3.1415927f);
                dhl.translate(integer2 * float8, float9, float10);
                this.applyItemArmTransform(dhl, aou13, float7);
                this.applyItemArmAttackTransform(dhl, aou13, float5);
                if (boolean13 && float5 < 0.001f) {
                    dhl.translate(integer2 * -0.641864f, 0.0, 0.0);
                    dhl.mulPose(Vector3f.YP.rotationDegrees(integer2 * 10.0f));
                }
            }
            this.renderItem(ebc, bki, boolean14 ? ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !boolean14, dhl, ebz, integer);
        }
        else {
            final boolean boolean13 = aou13 == HumanoidArm.RIGHT;
            if (ebc.isUsingItem() && ebc.getUseItemRemainingTicks() > 0 && ebc.getUsedItemHand() == anf) {
                final int integer3 = boolean13 ? 1 : -1;
                switch (bki.getUseAnimation()) {
                    case NONE: {
                        this.applyItemArmTransform(dhl, aou13, float7);
                        break;
                    }
                    case EAT:
                    case DRINK: {
                        this.applyEatTransform(dhl, float2, aou13, bki);
                        this.applyItemArmTransform(dhl, aou13, float7);
                        break;
                    }
                    case BLOCK: {
                        this.applyItemArmTransform(dhl, aou13, float7);
                        break;
                    }
                    case BOW: {
                        this.applyItemArmTransform(dhl, aou13, float7);
                        dhl.translate(integer3 * -0.2785682f, 0.18344387412071228, 0.15731531381607056);
                        dhl.mulPose(Vector3f.XP.rotationDegrees(-13.935f));
                        dhl.mulPose(Vector3f.YP.rotationDegrees(integer3 * 35.3f));
                        dhl.mulPose(Vector3f.ZP.rotationDegrees(integer3 * -9.785f));
                        final float float13 = bki.getUseDuration() - (this.minecraft.player.getUseItemRemainingTicks() - float2 + 1.0f);
                        float float8 = float13 / 20.0f;
                        float8 = (float8 * float8 + float8 * 2.0f) / 3.0f;
                        if (float8 > 1.0f) {
                            float8 = 1.0f;
                        }
                        if (float8 > 0.1f) {
                            final float float9 = Mth.sin((float13 - 0.1f) * 1.3f);
                            final float float10 = float8 - 0.1f;
                            final float float11 = float9 * float10;
                            dhl.translate(float11 * 0.0f, float11 * 0.004f, float11 * 0.0f);
                        }
                        dhl.translate(float8 * 0.0f, float8 * 0.0f, float8 * 0.04f);
                        dhl.scale(1.0f, 1.0f, 1.0f + float8 * 0.2f);
                        dhl.mulPose(Vector3f.YN.rotationDegrees(integer3 * 45.0f));
                        break;
                    }
                    case SPEAR: {
                        this.applyItemArmTransform(dhl, aou13, float7);
                        dhl.translate(integer3 * -0.5f, 0.699999988079071, 0.10000000149011612);
                        dhl.mulPose(Vector3f.XP.rotationDegrees(-55.0f));
                        dhl.mulPose(Vector3f.YP.rotationDegrees(integer3 * 35.3f));
                        dhl.mulPose(Vector3f.ZP.rotationDegrees(integer3 * -9.785f));
                        final float float13 = bki.getUseDuration() - (this.minecraft.player.getUseItemRemainingTicks() - float2 + 1.0f);
                        float float8 = float13 / 10.0f;
                        if (float8 > 1.0f) {
                            float8 = 1.0f;
                        }
                        if (float8 > 0.1f) {
                            final float float9 = Mth.sin((float13 - 0.1f) * 1.3f);
                            final float float10 = float8 - 0.1f;
                            final float float11 = float9 * float10;
                            dhl.translate(float11 * 0.0f, float11 * 0.004f, float11 * 0.0f);
                        }
                        dhl.translate(0.0, 0.0, float8 * 0.2f);
                        dhl.scale(1.0f, 1.0f, 1.0f + float8 * 0.2f);
                        dhl.mulPose(Vector3f.YN.rotationDegrees(integer3 * 45.0f));
                        break;
                    }
                }
            }
            else if (ebc.isAutoSpinAttack()) {
                this.applyItemArmTransform(dhl, aou13, float7);
                final int integer3 = boolean13 ? 1 : -1;
                dhl.translate(integer3 * -0.4f, 0.800000011920929, 0.30000001192092896);
                dhl.mulPose(Vector3f.YP.rotationDegrees(integer3 * 65.0f));
                dhl.mulPose(Vector3f.ZP.rotationDegrees(integer3 * -85.0f));
            }
            else {
                final float float14 = -0.4f * Mth.sin(Mth.sqrt(float5) * 3.1415927f);
                final float float13 = 0.2f * Mth.sin(Mth.sqrt(float5) * 6.2831855f);
                final float float8 = -0.2f * Mth.sin(float5 * 3.1415927f);
                final int integer4 = boolean13 ? 1 : -1;
                dhl.translate(integer4 * float14, float13, float8);
                this.applyItemArmTransform(dhl, aou13, float7);
                this.applyItemArmAttackTransform(dhl, aou13, float5);
            }
            this.renderItem(ebc, bki, boolean13 ? ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !boolean13, dhl, ebz, integer);
        }
        dhl.popPose();
    }
    
    public void tick() {
        this.oMainHandHeight = this.mainHandHeight;
        this.oOffHandHeight = this.offHandHeight;
        final LocalPlayer ebf2 = this.minecraft.player;
        final ItemStack bki3 = ebf2.getMainHandItem();
        final ItemStack bki4 = ebf2.getOffhandItem();
        if (ItemStack.matches(this.mainHandItem, bki3)) {
            this.mainHandItem = bki3;
        }
        if (ItemStack.matches(this.offHandItem, bki4)) {
            this.offHandItem = bki4;
        }
        if (ebf2.isHandsBusy()) {
            this.mainHandHeight = Mth.clamp(this.mainHandHeight - 0.4f, 0.0f, 1.0f);
            this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4f, 0.0f, 1.0f);
        }
        else {
            final float float5 = ebf2.getAttackStrengthScale(1.0f);
            this.mainHandHeight += Mth.clamp(((this.mainHandItem == bki3) ? (float5 * float5 * float5) : 0.0f) - this.mainHandHeight, -0.4f, 0.4f);
            this.offHandHeight += Mth.clamp((float)((this.offHandItem == bki4) ? 1 : 0) - this.offHandHeight, -0.4f, 0.4f);
        }
        if (this.mainHandHeight < 0.1f) {
            this.mainHandItem = bki3;
        }
        if (this.offHandHeight < 0.1f) {
            this.offHandItem = bki4;
        }
    }
    
    public void itemUsed(final InteractionHand anf) {
        if (anf == InteractionHand.MAIN_HAND) {
            this.mainHandHeight = 0.0f;
        }
        else {
            this.offHandHeight = 0.0f;
        }
    }
    
    static {
        MAP_BACKGROUND = RenderType.text(new ResourceLocation("textures/map/map_background.png"));
        MAP_BACKGROUND_CHECKERBOARD = RenderType.text(new ResourceLocation("textures/map/map_background_checkerboard.png"));
    }
}
