package net.minecraft.client.renderer;

import net.minecraft.resources.ResourceLocation;
import java.util.Objects;
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 dbn) {
        this.mainHandItem = ItemStack.EMPTY;
        this.offHandItem = ItemStack.EMPTY;
        this.minecraft = dbn;
        this.entityRenderDispatcher = dbn.getEntityRenderDispatcher();
        this.itemRenderer = dbn.getItemRenderer();
    }
    
    public void renderItem(final LivingEntity akz, final ItemStack ben, final ItemTransforms.TransformType b, final boolean boolean4, final PoseStack cyl, final MultiBufferSource dqt, final int integer) {
        if (ben.isEmpty()) {
            return;
        }
        this.itemRenderer.renderStatic(akz, ben, b, boolean4, cyl, dqt, akz.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 cyl, final MultiBufferSource dqt, final int integer, final HumanoidArm aky) {
        this.minecraft.getTextureManager().bind(this.minecraft.player.getSkinTextureLocation());
        final PlayerRenderer dzt6 = (PlayerRenderer)this.entityRenderDispatcher.<LocalPlayer>getRenderer(this.minecraft.player);
        cyl.pushPose();
        final float float7 = (aky == HumanoidArm.RIGHT) ? 1.0f : -1.0f;
        cyl.mulPose(Vector3f.YP.rotationDegrees(92.0f));
        cyl.mulPose(Vector3f.XP.rotationDegrees(45.0f));
        cyl.mulPose(Vector3f.ZP.rotationDegrees(float7 * -41.0f));
        cyl.translate(float7 * 0.3f, -1.100000023841858, 0.44999998807907104);
        if (aky == HumanoidArm.RIGHT) {
            dzt6.renderRightHand(cyl, dqt, integer, this.minecraft.player);
        }
        else {
            dzt6.renderLeftHand(cyl, dqt, integer, this.minecraft.player);
        }
        cyl.popPose();
    }
    
    private void renderOneHandedMap(final PoseStack cyl, final MultiBufferSource dqt, final int integer, final float float4, final HumanoidArm aky, final float float6, final ItemStack ben) {
        final float float7 = (aky == HumanoidArm.RIGHT) ? 1.0f : -1.0f;
        cyl.translate(float7 * 0.125f, -0.125, 0.0);
        if (!this.minecraft.player.isInvisible()) {
            cyl.pushPose();
            cyl.mulPose(Vector3f.ZP.rotationDegrees(float7 * 10.0f));
            this.renderPlayerArm(cyl, dqt, integer, float4, float6, aky);
            cyl.popPose();
        }
        cyl.pushPose();
        cyl.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);
        cyl.translate(float7 * float10, float11 - 0.3f * float9, float12);
        cyl.mulPose(Vector3f.XP.rotationDegrees(float9 * -45.0f));
        cyl.mulPose(Vector3f.YP.rotationDegrees(float7 * float9 * -30.0f));
        this.renderMap(cyl, dqt, integer, ben);
        cyl.popPose();
    }
    
    private void renderTwoHandedMap(final PoseStack cyl, final MultiBufferSource dqt, 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);
        cyl.translate(0.0, -float8 / 2.0f, float9);
        final float float10 = this.calculateMapTilt(float4);
        cyl.translate(0.0, 0.04f + float5 * -1.2f + float10 * -0.5f, -0.7200000286102295);
        cyl.mulPose(Vector3f.XP.rotationDegrees(float10 * -85.0f));
        if (!this.minecraft.player.isInvisible()) {
            cyl.pushPose();
            cyl.mulPose(Vector3f.YP.rotationDegrees(90.0f));
            this.renderMapHand(cyl, dqt, integer, HumanoidArm.RIGHT);
            this.renderMapHand(cyl, dqt, integer, HumanoidArm.LEFT);
            cyl.popPose();
        }
        final float float11 = Mth.sin(float7 * 3.1415927f);
        cyl.mulPose(Vector3f.XP.rotationDegrees(float11 * 20.0f));
        cyl.scale(2.0f, 2.0f, 2.0f);
        this.renderMap(cyl, dqt, integer, this.mainHandItem);
    }
    
    private void renderMap(final PoseStack cyl, final MultiBufferSource dqt, final int integer, final ItemStack ben) {
        cyl.mulPose(Vector3f.YP.rotationDegrees(180.0f));
        cyl.mulPose(Vector3f.ZP.rotationDegrees(180.0f));
        cyl.scale(0.38f, 0.38f, 0.38f);
        cyl.translate(-0.5, -0.5, 0.0);
        cyl.scale(0.0078125f, 0.0078125f, 0.0078125f);
        final MapItemSavedData crg6 = MapItem.getOrCreateSavedData(ben, this.minecraft.level);
        final VertexConsumer cyo7 = dqt.getBuffer((crg6 == null) ? ItemInHandRenderer.MAP_BACKGROUND : ItemInHandRenderer.MAP_BACKGROUND_CHECKERBOARD);
        final Matrix4f b8 = cyl.last().pose();
        cyo7.vertex(b8, -7.0f, 135.0f, 0.0f).color(255, 255, 255, 255).uv(0.0f, 1.0f).uv2(integer).endVertex();
        cyo7.vertex(b8, 135.0f, 135.0f, 0.0f).color(255, 255, 255, 255).uv(1.0f, 1.0f).uv2(integer).endVertex();
        cyo7.vertex(b8, 135.0f, -7.0f, 0.0f).color(255, 255, 255, 255).uv(1.0f, 0.0f).uv2(integer).endVertex();
        cyo7.vertex(b8, -7.0f, -7.0f, 0.0f).color(255, 255, 255, 255).uv(0.0f, 0.0f).uv2(integer).endVertex();
        if (crg6 != null) {
            this.minecraft.gameRenderer.getMapRenderer().render(cyl, dqt, crg6, false, integer);
        }
    }
    
    private void renderPlayerArm(final PoseStack cyl, final MultiBufferSource dqt, final int integer, final float float4, final float float5, final HumanoidArm aky) {
        final boolean boolean8 = aky != 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);
        cyl.translate(float6 * (float8 + 0.64000005f), float9 - 0.6f + float4 * -0.6f, float10 - 0.71999997f);
        cyl.mulPose(Vector3f.YP.rotationDegrees(float6 * 45.0f));
        final float float11 = Mth.sin(float5 * float5 * 3.1415927f);
        final float float12 = Mth.sin(float7 * 3.1415927f);
        cyl.mulPose(Vector3f.YP.rotationDegrees(float6 * float12 * 70.0f));
        cyl.mulPose(Vector3f.ZP.rotationDegrees(float6 * float11 * -20.0f));
        final AbstractClientPlayer dpy16 = this.minecraft.player;
        this.minecraft.getTextureManager().bind(dpy16.getSkinTextureLocation());
        cyl.translate(float6 * -1.0f, 3.5999999046325684, 3.5);
        cyl.mulPose(Vector3f.ZP.rotationDegrees(float6 * 120.0f));
        cyl.mulPose(Vector3f.XP.rotationDegrees(200.0f));
        cyl.mulPose(Vector3f.YP.rotationDegrees(float6 * -135.0f));
        cyl.translate(float6 * 5.6f, 0.0, 0.0);
        final PlayerRenderer dzt17 = (PlayerRenderer)this.entityRenderDispatcher.<AbstractClientPlayer>getRenderer(dpy16);
        if (boolean8) {
            dzt17.renderRightHand(cyl, dqt, integer, dpy16);
        }
        else {
            dzt17.renderLeftHand(cyl, dqt, integer, dpy16);
        }
    }
    
    private void applyEatTransform(final PoseStack cyl, final float float2, final HumanoidArm aky, final ItemStack ben) {
        final float float3 = this.minecraft.player.getUseItemRemainingTicks() - float2 + 1.0f;
        final float float4 = float3 / ben.getUseDuration();
        if (float4 < 0.8f) {
            final float float5 = Mth.abs(Mth.cos(float3 / 4.0f * 3.1415927f) * 0.1f);
            cyl.translate(0.0, float5, 0.0);
        }
        final float float5 = 1.0f - (float)Math.pow(float4, 27.0);
        final int integer9 = (aky == HumanoidArm.RIGHT) ? 1 : -1;
        cyl.translate(float5 * 0.6f * integer9, float5 * -0.5f, float5 * 0.0f);
        cyl.mulPose(Vector3f.YP.rotationDegrees(integer9 * float5 * 90.0f));
        cyl.mulPose(Vector3f.XP.rotationDegrees(float5 * 10.0f));
        cyl.mulPose(Vector3f.ZP.rotationDegrees(integer9 * float5 * 30.0f));
    }
    
    private void applyItemArmAttackTransform(final PoseStack cyl, final HumanoidArm aky, final float float3) {
        final int integer5 = (aky == HumanoidArm.RIGHT) ? 1 : -1;
        final float float4 = Mth.sin(float3 * float3 * 3.1415927f);
        cyl.mulPose(Vector3f.YP.rotationDegrees(integer5 * (45.0f + float4 * -20.0f)));
        final float float5 = Mth.sin(Mth.sqrt(float3) * 3.1415927f);
        cyl.mulPose(Vector3f.ZP.rotationDegrees(integer5 * float5 * -20.0f));
        cyl.mulPose(Vector3f.XP.rotationDegrees(float5 * -80.0f));
        cyl.mulPose(Vector3f.YP.rotationDegrees(integer5 * -45.0f));
    }
    
    private void applyItemArmTransform(final PoseStack cyl, final HumanoidArm aky, final float float3) {
        final int integer5 = (aky == HumanoidArm.RIGHT) ? 1 : -1;
        cyl.translate(integer5 * 0.56f, -0.52f + float3 * -0.6f, -0.7200000286102295);
    }
    
    public void renderHandsWithItems(final float float1, final PoseStack cyl, final MultiBufferSource.BufferSource a, final LocalPlayer dqb, final int integer) {
        final float float2 = dqb.getAttackAnim(float1);
        final InteractionHand ajk8 = MoreObjects.<InteractionHand>firstNonNull(dqb.swingingArm, InteractionHand.MAIN_HAND);
        final float float3 = Mth.lerp(float1, dqb.xRotO, dqb.xRot);
        boolean boolean10 = true;
        boolean boolean11 = true;
        if (dqb.isUsingItem()) {
            final ItemStack ben12 = dqb.getUseItem();
            if (ben12.getItem() == Items.BOW || ben12.getItem() == Items.CROSSBOW) {
                boolean10 = (dqb.getUsedItemHand() == InteractionHand.MAIN_HAND);
                boolean11 = !boolean10;
            }
            final InteractionHand ajk9 = dqb.getUsedItemHand();
            if (ajk9 == InteractionHand.MAIN_HAND) {
                final ItemStack ben13 = dqb.getOffhandItem();
                if (ben13.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(ben13)) {
                    boolean11 = false;
                }
            }
        }
        else {
            final ItemStack ben12 = dqb.getMainHandItem();
            final ItemStack ben14 = dqb.getOffhandItem();
            if (ben12.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(ben12)) {
                boolean11 = !boolean10;
            }
            if (ben14.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(ben14)) {
                boolean10 = !ben12.isEmpty();
                boolean11 = !boolean10;
            }
        }
        final float float4 = Mth.lerp(float1, dqb.xBobO, dqb.xBob);
        final float float5 = Mth.lerp(float1, dqb.yBobO, dqb.yBob);
        cyl.mulPose(Vector3f.XP.rotationDegrees((dqb.getViewXRot(float1) - float4) * 0.1f));
        cyl.mulPose(Vector3f.YP.rotationDegrees((dqb.getViewYRot(float1) - float5) * 0.1f));
        if (boolean10) {
            final float float6 = (ajk8 == InteractionHand.MAIN_HAND) ? float2 : 0.0f;
            final float float7 = 1.0f - Mth.lerp(float1, this.oMainHandHeight, this.mainHandHeight);
            this.renderArmWithItem(dqb, float1, float3, InteractionHand.MAIN_HAND, float6, this.mainHandItem, float7, cyl, a, integer);
        }
        if (boolean11) {
            final float float6 = (ajk8 == InteractionHand.OFF_HAND) ? float2 : 0.0f;
            final float float7 = 1.0f - Mth.lerp(float1, this.oOffHandHeight, this.offHandHeight);
            this.renderArmWithItem(dqb, float1, float3, InteractionHand.OFF_HAND, float6, this.offHandItem, float7, cyl, a, integer);
        }
        a.endBatch();
    }
    
    private void renderArmWithItem(final AbstractClientPlayer dpy, final float float2, final float float3, final InteractionHand ajk, final float float5, final ItemStack ben, final float float7, final PoseStack cyl, final MultiBufferSource dqt, final int integer) {
        final boolean boolean12 = ajk == InteractionHand.MAIN_HAND;
        final HumanoidArm aky13 = boolean12 ? dpy.getMainArm() : dpy.getMainArm().getOpposite();
        cyl.pushPose();
        if (ben.isEmpty()) {
            if (boolean12 && !dpy.isInvisible()) {
                this.renderPlayerArm(cyl, dqt, integer, float7, float5, aky13);
            }
        }
        else if (ben.getItem() == Items.FILLED_MAP) {
            if (boolean12 && this.offHandItem.isEmpty()) {
                this.renderTwoHandedMap(cyl, dqt, integer, float3, float7, float5);
            }
            else {
                this.renderOneHandedMap(cyl, dqt, integer, float7, aky13, float5, ben);
            }
        }
        else if (ben.getItem() == Items.CROSSBOW) {
            final boolean boolean13 = CrossbowItem.isCharged(ben);
            final boolean boolean14 = aky13 == HumanoidArm.RIGHT;
            final int integer2 = boolean14 ? 1 : -1;
            if (dpy.isUsingItem() && dpy.getUseItemRemainingTicks() > 0 && dpy.getUsedItemHand() == ajk) {
                this.applyItemArmTransform(cyl, aky13, float7);
                cyl.translate(integer2 * -0.4785682f, -0.0943870022892952, 0.05731530860066414);
                cyl.mulPose(Vector3f.XP.rotationDegrees(-11.935f));
                cyl.mulPose(Vector3f.YP.rotationDegrees(integer2 * 65.3f));
                cyl.mulPose(Vector3f.ZP.rotationDegrees(integer2 * -9.785f));
                final float float8 = ben.getUseDuration() - (this.minecraft.player.getUseItemRemainingTicks() - float2 + 1.0f);
                float float9 = float8 / CrossbowItem.getChargeDuration(ben);
                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;
                    cyl.translate(float12 * 0.0f, float12 * 0.004f, float12 * 0.0f);
                }
                cyl.translate(float9 * 0.0f, float9 * 0.0f, float9 * 0.04f);
                cyl.scale(1.0f, 1.0f, 1.0f + float9 * 0.2f);
                cyl.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);
                cyl.translate(integer2 * float8, float9, float10);
                this.applyItemArmTransform(cyl, aky13, float7);
                this.applyItemArmAttackTransform(cyl, aky13, float5);
                if (boolean13 && float5 < 0.001f) {
                    cyl.translate(integer2 * -0.641864f, 0.0, 0.0);
                    cyl.mulPose(Vector3f.YP.rotationDegrees(integer2 * 10.0f));
                }
            }
            this.renderItem(dpy, ben, boolean14 ? ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !boolean14, cyl, dqt, integer);
        }
        else {
            final boolean boolean13 = aky13 == HumanoidArm.RIGHT;
            if (dpy.isUsingItem() && dpy.getUseItemRemainingTicks() > 0 && dpy.getUsedItemHand() == ajk) {
                final int integer3 = boolean13 ? 1 : -1;
                switch (ben.getUseAnimation()) {
                    case NONE: {
                        this.applyItemArmTransform(cyl, aky13, float7);
                        break;
                    }
                    case EAT:
                    case DRINK: {
                        this.applyEatTransform(cyl, float2, aky13, ben);
                        this.applyItemArmTransform(cyl, aky13, float7);
                        break;
                    }
                    case BLOCK: {
                        this.applyItemArmTransform(cyl, aky13, float7);
                        break;
                    }
                    case BOW: {
                        this.applyItemArmTransform(cyl, aky13, float7);
                        cyl.translate(integer3 * -0.2785682f, 0.18344387412071228, 0.15731531381607056);
                        cyl.mulPose(Vector3f.XP.rotationDegrees(-13.935f));
                        cyl.mulPose(Vector3f.YP.rotationDegrees(integer3 * 35.3f));
                        cyl.mulPose(Vector3f.ZP.rotationDegrees(integer3 * -9.785f));
                        final float float13 = ben.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;
                            cyl.translate(float11 * 0.0f, float11 * 0.004f, float11 * 0.0f);
                        }
                        cyl.translate(float8 * 0.0f, float8 * 0.0f, float8 * 0.04f);
                        cyl.scale(1.0f, 1.0f, 1.0f + float8 * 0.2f);
                        cyl.mulPose(Vector3f.YN.rotationDegrees(integer3 * 45.0f));
                        break;
                    }
                    case SPEAR: {
                        this.applyItemArmTransform(cyl, aky13, float7);
                        cyl.translate(integer3 * -0.5f, 0.699999988079071, 0.10000000149011612);
                        cyl.mulPose(Vector3f.XP.rotationDegrees(-55.0f));
                        cyl.mulPose(Vector3f.YP.rotationDegrees(integer3 * 35.3f));
                        cyl.mulPose(Vector3f.ZP.rotationDegrees(integer3 * -9.785f));
                        final float float13 = ben.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;
                            cyl.translate(float11 * 0.0f, float11 * 0.004f, float11 * 0.0f);
                        }
                        cyl.translate(0.0, 0.0, float8 * 0.2f);
                        cyl.scale(1.0f, 1.0f, 1.0f + float8 * 0.2f);
                        cyl.mulPose(Vector3f.YN.rotationDegrees(integer3 * 45.0f));
                        break;
                    }
                }
            }
            else if (dpy.isAutoSpinAttack()) {
                this.applyItemArmTransform(cyl, aky13, float7);
                final int integer3 = boolean13 ? 1 : -1;
                cyl.translate(integer3 * -0.4f, 0.800000011920929, 0.30000001192092896);
                cyl.mulPose(Vector3f.YP.rotationDegrees(integer3 * 65.0f));
                cyl.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;
                cyl.translate(integer4 * float14, float13, float8);
                this.applyItemArmTransform(cyl, aky13, float7);
                this.applyItemArmAttackTransform(cyl, aky13, float5);
            }
            this.renderItem(dpy, ben, boolean13 ? ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !boolean13, cyl, dqt, integer);
        }
        cyl.popPose();
    }
    
    public void tick() {
        this.oMainHandHeight = this.mainHandHeight;
        this.oOffHandHeight = this.offHandHeight;
        final LocalPlayer dqb2 = this.minecraft.player;
        final ItemStack ben3 = dqb2.getMainHandItem();
        final ItemStack ben4 = dqb2.getOffhandItem();
        if (dqb2.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 = dqb2.getAttackStrengthScale(1.0f);
            this.mainHandHeight += Mth.clamp((Objects.equals(this.mainHandItem, ben3) ? (float5 * float5 * float5) : 0.0f) - this.mainHandHeight, -0.4f, 0.4f);
            this.offHandHeight += Mth.clamp((float)(Objects.equals(this.offHandItem, ben4) ? 1 : 0) - this.offHandHeight, -0.4f, 0.4f);
        }
        if (this.mainHandHeight < 0.1f) {
            this.mainHandItem = ben3;
        }
        if (this.offHandHeight < 0.1f) {
            this.offHandItem = ben4;
        }
    }
    
    public void itemUsed(final InteractionHand ajk) {
        if (ajk == 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"));
    }
}
