Search in sources :

Example 1 with IMixinItemRenderer

use of cc.hyperium.mixins.client.renderer.IMixinItemRenderer in project Hyperium by HyperiumClient.

the class HyperiumItemRenderer method renderItemInFirstPerson.

public void renderItemInFirstPerson(float partialTicks, float prevEquippedProgress, float equippedProgress, ItemStack itemToRender) {
    float f = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks);
    EntityPlayerSP entityPlayerSP = mc.thePlayer;
    float f1 = entityPlayerSP.getSwingProgress(partialTicks);
    float f2 = entityPlayerSP.prevRotationPitch + (entityPlayerSP.rotationPitch - entityPlayerSP.prevRotationPitch) * partialTicks;
    float f3 = entityPlayerSP.prevRotationYaw + (entityPlayerSP.rotationYaw - entityPlayerSP.prevRotationYaw) * partialTicks;
    ((IMixinItemRenderer) parent).callRotateArroundXAndY(f2, f3);
    ((IMixinItemRenderer) parent).callSetLightMapFromPlayer(entityPlayerSP);
    ((IMixinItemRenderer) parent).callRotateWithPlayerRotations(entityPlayerSP, partialTicks);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();
    if (itemToRender != null) {
        if (itemToRender.getItem() == Items.filled_map) {
            ((IMixinItemRenderer) parent).callRenderItemMap(entityPlayerSP, f2, f, f1);
        } else if ((itemToRender.getItem() instanceof ItemSword) && !mc.thePlayer.isBlocking() && Settings.CUSTOM_SWORD_ANIMATION) {
            transformFirstPersonItem(f, f1);
        } else if (entityPlayerSP.getItemInUseCount() > 0) {
            EnumAction enumaction = itemToRender.getItemUseAction();
            switch(enumaction) {
                case NONE:
                    transformFirstPersonItem(f, 0.0F);
                    break;
                case EAT:
                case DRINK:
                    ((IMixinItemRenderer) parent).callPerformDrinking(entityPlayerSP, partialTicks);
                    if (Settings.OLD_EATING) {
                        transformFirstPersonItem(f, f1);
                    } else {
                        transformFirstPersonItem(f, 0.0F);
                    }
                    break;
                case BLOCK:
                    if (Settings.OLD_BLOCKHIT) {
                        transformFirstPersonItem(f, f1);
                        ((IMixinItemRenderer) parent).callDoBlockTransformations();
                        GlStateManager.scale(0.83f, 0.88f, 0.85f);
                        GlStateManager.translate(-0.3f, 0.1f, 0.0f);
                    } else {
                        transformFirstPersonItem(f, 0f);
                        ((IMixinItemRenderer) parent).callDoBlockTransformations();
                    }
                    break;
                case BOW:
                    if (Settings.OLD_BOW) {
                        transformFirstPersonItem(f, f1);
                        ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
                        GlStateManager.translate(0.0F, 0.1F, -0.15F);
                    } else {
                        transformFirstPersonItem(f, 0.0F);
                        ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
                    }
            }
        } else {
            ((IMixinItemRenderer) parent).callDoItemUsedTransformations(f1);
            transformFirstPersonItem(f, f1);
        }
        parent.renderItem(entityPlayerSP, itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
    } else if (!entityPlayerSP.isInvisible()) {
        ((IMixinItemRenderer) parent).callRenderPlayerArm(entityPlayerSP, f, f1);
    }
    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
}
Also used : ItemSword(net.minecraft.item.ItemSword) IMixinItemRenderer(cc.hyperium.mixins.client.renderer.IMixinItemRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EnumAction(net.minecraft.item.EnumAction)

Aggregations

IMixinItemRenderer (cc.hyperium.mixins.client.renderer.IMixinItemRenderer)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 EnumAction (net.minecraft.item.EnumAction)1 ItemSword (net.minecraft.item.ItemSword)1