Jump to content

[SOLVED] [1.8] First Person Arm Rendering - Translate And Rotate Arm


EverythingGames

Recommended Posts

Hi

I have been working on my mod for some time now, and I have seem to have come to a problem. I can't seem to figure out how to obtain the hand in first person and translate / rotate it accordingly. If I could also add that I only need to do the modifications to the arm when I am holding a certain item. I am using the RenderPlayerAPI core for Minecraft 1.8. Thanks to all in advance!

public class CustomRenderPlayer extends ModelPlayerBase
{

public CustomRenderPlayer(ModelPlayerAPI modelPlayerAPI) 
{
	super(modelPlayerAPI);
}

@Override
public void setRotationAngles(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, float paramFloat5, float paramFloat6, net.minecraft.entity.Entity paramEntity)
{
	this.modelPlayer.bipedLeftArm.rotateAngleX = 0.0F; //Not trying to rotate any here - I believe this is only included in third person... (Not what I need)
	this.modelPlayer.bipedRightArm.rotateAngleX = 0.0F; //Not trying to rotate any here - I believe this is only included in third person... (Not what I need)
}

}

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

Thanks for the reply, TGG, it helped lead me a lot further. I looked in the RenderPlayer class, and I found the various functions. Is the rendering of the hand in first person canceled when the player is holding an item? Should I override the function that modifies the first person arm - if so which exact function controls the rendering with an item. If you could clear some things up for me and point me in the right direction I would greatly appreciate it!

 

I am seeking to do something along the lines of this:

 

IWOVJzeuZos.jpg

 

[Courtesy of Last Days Mod]

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

Hi

 

It's hard going because of all the obfuscated names, but if you trace it through (perhaps with your debugger) you should be able to figure it out.

 

For example in

    public void renderItemInFirstPerson(float p_78440_1_)
    {
        float f1 = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * p_78440_1_);
        EntityPlayerSP entityplayersp = this.mc.thePlayer;
        float f2 = entityplayersp.getSwingProgress(p_78440_1_);
        float f3 = entityplayersp.prevRotationPitch + (entityplayersp.rotationPitch - entityplayersp.prevRotationPitch) * p_78440_1_;
        float f4 = entityplayersp.prevRotationYaw + (entityplayersp.rotationYaw - entityplayersp.prevRotationYaw) * p_78440_1_;
        this.func_178101_a(f3, f4);
        this.func_178109_a(entityplayersp);
        this.func_178110_a((EntityPlayerSP)entityplayersp, p_78440_1_);
        GlStateManager.enableRescaleNormal();
        GlStateManager.pushMatrix();

        if (this.itemToRender != null)   // is player holding an item?
        {                                               // yes
            if (this.itemToRender.getItem() == Items.filled_map)
            {
                this.func_178097_a(entityplayersp, f3, f1, f2);
            }
            else if (entityplayersp.getItemInUseCount() > 0)
           // ... etc ...
        } else if (!entityplayersp.isInvisible())  // player isn't holding an item; check if invisible
        {
            this.func_178095_a(entityplayersp, f1, f2);   // draw arm without item
        }

 

To be honest I'm not sure what the best way to hijack the first person rendering would be. 

The first thing I would check is whether there are any Forge hooks or events in the code as you are looking through it. 

If not, you could perhaps stop the first person arm rendering (eg by making the player invisible immediately before the arm render, and the restoring the visible flag immediately after), then rendering your own arms. 

You might be able to create your own MyRenderPlayer which overrides RenderPlayer, and replace the vanilla RenderPlayer with yours.

As a last resort you could use ASM+Reflection to insert your code into the vanilla code.  (This is tricky to get right).

 

You could also consider looking at other mods (Last Days for example) to see how they do it.  Even if it's not open source, you can use a decompiler (eg IntelliJ IDEA has one built in) to look through.

 

-TGG

Link to comment
Share on other sites

I'm just going to throw this out there: RenderHandEvent.

 

There are also several RenderPlayerEvents (e.g. Pre, Post, etc.), and other entity-based rendering events, if needed.

I remember that the Render player events are not used on 1.8

But RenderHandEvent would work.

 

EDIT: Confirmed that the render player events are not referenced anywhere.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

I remember that the Render player events are not used on 1.8

But RenderHandEvent would work.

Is that so? I haven't actually checked to see if they get called or not, but only the 'Specials' versions of it are marked as Deprecated...

 

I wish they would just completely remove things that no longer work, rather than leaving them in there (like IItemRenderer) causing people to think they might still function, deprecated or not.

 

Note that 'deprecated' does not mean "No longer functions", it means "Use the newer version instead, as this one sucks and / or might be removed in the future".

Link to comment
Share on other sites

Thanks for all the replies, everyone. I have used the RenderHandEvent, and I think RenderPlayer events work, you just have to use the subclasses (pre, post). I tested this by canceling the event and it did indeed not render the player as it was invisible. As far as my problem, TGG pointed out the various functions in the ItemRenderer and RenderPlayer classes, I had a look at them and am still stuck. Im trying my best to see whats going on (haha, too much obfuscated methods). As TGG suggested that I look into various other mods' source code to see how they achieved a custom first person render, most of them use the RenderPlayerAPI. Also I have tried using the functions in the ItemRenderer class, just not much luck. There is a couple of fields obtained with the player instance (I believe only the client, I may be wrong though) called renderArmPitch and renderArmYaw with looks to be the fact of being able to translate the model in first person. Maybe canceling the render hand event and rendering my own hand? I just don't know on too much how, rendering is a bit tricky for myself as far as entities go. I hope to achieve this first person view soon!

@SubscribeEvent
public void renderHandEvent(RenderHandEvent par1RenderHandEvent)
{
    //do something here
}

//With player instance
void test(EntityPlayer player)
{
    player.renderArmPitch = 0.0F; //there's also prevRenderArmPitch
    player.renderArmYaw = 0.0F; // there's also prevRenderArmYaw
}

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

Just throwing this out there (please feel encouraged to correct me):

I have tried to extend the ItemRenderer class, override the ItemRenderer.renderItemInFirstPerson(float par1Float) and call it in the RenderHandEvent. In the overridden renderItemInFirstPerson, I call another method (exactly the same as the vanilla method func_178095_a in ItemRenderer) called customRenderOne to try and render a new arm just to test. As you all know, my problem is to render the arm to make it look like the player is holding my model (specifically a gun / weapon model) in first person. Here is a trial of some tried code:

@SideOnly(Side.CLIENT)
public class CustomFirstPerson extends ItemRenderer
{

    private Minecraft mc;
    private RenderManager renderManager;
    private RenderItem itemRenderer;

    public CustomFirstPerson(Minecraft par1Minecraft)
    {
super(par1Minecraft);
this.mc = par1Minecraft;
this.renderManager = par1Minecraft.getRenderManager();
this.itemRenderer = par1Minecraft.getRenderItem();
    }

    @SubscribeEvent
    public void renderHandEvent(RenderHandEvent par1RenderHandEvent)
    {
this.renderItemInFirstPerson(1.0F);
    }

    @Override
    public void renderItemInFirstPerson(float par1Float)
    {
        try
{
    ItemRenderer itemrenderer = new ItemRenderer(this.mc);
            EntityPlayerSP entityplayersp = this.mc.thePlayer;
    Field field1 = ItemRenderer.class.getDeclaredField("equippedProgress");
    Field field2 = ItemRenderer.class.getDeclaredField("prevEquippedProgress");
    field1.setAccessible(true);
    field2.setAccessible(true);
    float equippedProgress = field1.getFloat(itemrenderer);
    float prevEquippedProgress = field2.getFloat(itemrenderer);
    float f1 = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * par1Float);
    float f2 = entityplayersp.getSwingProgress(par1Float);
    if(!entityplayersp.isInvisible())
    {
	customRenderOne(entityplayersp, f1, f2);
    }
        }
catch(Exception par2Exception)
{

}
    }

    private void customRenderOne(AbstractClientPlayer par1AbstractClientPlayer, float par2Float, float par3Float)
    {
float f2 = -0.3F * MathHelper.sin(MathHelper.sqrt_float(par3Float) * (float) Math.PI);
float f3 = 0.4F * MathHelper.sin(MathHelper.sqrt_float(par3Float) * (float) Math.PI * 2.0F);
float f4 = -0.4F * MathHelper.sin(par3Float * (float) Math.PI);
GlStateManager.translate(f2, f3, f4);
GlStateManager.translate(0.64000005F, -0.6F, -0.71999997F);
GlStateManager.translate(0.0F, par2Float * -0.6F, 0.0F);
GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
float f5 = MathHelper.sin(par3Float * par3Float * (float) Math.PI);
float f6 = MathHelper.sin(MathHelper.sqrt_float(par3Float) * (float) Math.PI);
GlStateManager.rotate(f6 * 70.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(f5 * -20.0F, 0.0F, 0.0F, 1.0F);
this.mc.getTextureManager().bindTexture(par1AbstractClientPlayer.getLocationSkin());
GlStateManager.translate(-1.0F, 3.6F, 3.5F);
GlStateManager.rotate(120.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(200.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(1.0F, 1.0F, 1.0F);
GlStateManager.translate(5.6F, 0.0F, 0.0F);
Render render = this.renderManager.getEntityRenderObject(this.mc.thePlayer);
RenderPlayer renderplayer = (RenderPlayer) render;
renderplayer.func_177138_b(this.mc.thePlayer);
    }

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

You really shouldn't need to take such drastic measures.

 

You can do all of that rendering directly from RenderHandEvent, which is only fired in first person anyway (I believe), or you could move it to happen with your Item's IPerspectiveAwareModel and do your rendering of the player's hand from the first person perspective there.

Link to comment
Share on other sites

You really shouldn't need to take such drastic measures.

 

You can do all of that rendering directly from RenderHandEvent, which is only fired in first person anyway (I believe), or you could move it to happen with your Item's IPerspectiveAwareModel and do your rendering of the player's hand from the first person perspective there.

Thanks for the reply, coolAlias. I don't why performing the rendering straight from the RenderHandEvent would be more benificial rather than just having one method (I'd like to know because I may be false on the subject matter). What is this IPerspectiveAwareModel? I haven't heard of this before and I don't know why. If you could briefly describe this to me (if it is benificial to my problem) or provide a link I would greatly appreciate it.

 

Some things to look at in ItemRenderer.class:

 

public void renderItem(EntityLivingBase entityIn, ItemStack heldStack, ItemCameraTransforms.TransformType p_178099_3_)
    {
        if (heldStack != null)
        {
            Item item = heldStack.getItem();
            Block block = Block.getBlockFromItem(item);
            GlStateManager.pushMatrix();

            if (this.itemRenderer.shouldRenderItemIn3D(heldStack))
            {
                GlStateManager.scale(2.0F, 2.0F, 2.0F);

                if (this.func_178107_a(block))
                {
                    GlStateManager.depthMask(false);
                }
            }

            this.itemRenderer.renderItemModelForEntity(heldStack, entityIn, p_178099_3_);

            if (this.func_178107_a(block))
            {
                GlStateManager.depthMask(true);
            }

            GlStateManager.popMatrix();
        }
    }

    private boolean func_178107_a(Block p_178107_1_)
    {
        return p_178107_1_ != null && p_178107_1_.getBlockLayer() == EnumWorldBlockLayer.TRANSLUCENT;
    }

    private void func_178101_a(float p_178101_1_, float p_178101_2_)
    {
        GlStateManager.pushMatrix();
        GlStateManager.rotate(p_178101_1_, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(p_178101_2_, 0.0F, 1.0F, 0.0F);
        RenderHelper.enableStandardItemLighting();
        GlStateManager.popMatrix();
    }

    private void func_178109_a(AbstractClientPlayer p_178109_1_)
    {
        int i = this.mc.theWorld.getCombinedLight(new BlockPos(p_178109_1_.posX, p_178109_1_.posY + (double)p_178109_1_.getEyeHeight(), p_178109_1_.posZ), 0);
        float f = (float)(i & 65535);
        float f1 = (float)(i >> 16);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, f, f1);
    }

    private void func_178110_a(EntityPlayerSP p_178110_1_, float p_178110_2_)
    {
        float f1 = p_178110_1_.prevRenderArmPitch + (p_178110_1_.renderArmPitch - p_178110_1_.prevRenderArmPitch) * p_178110_2_;
        float f2 = p_178110_1_.prevRenderArmYaw + (p_178110_1_.renderArmYaw - p_178110_1_.prevRenderArmYaw) * p_178110_2_;
        GlStateManager.rotate((p_178110_1_.rotationPitch - f1) * 0.1F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate((p_178110_1_.rotationYaw - f2) * 0.1F, 0.0F, 1.0F, 0.0F);
    }

    private float func_178100_c(float p_178100_1_)
    {
        float f1 = 1.0F - p_178100_1_ / 45.0F + 0.1F;
        f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
        f1 = -MathHelper.cos(f1 * (float)Math.PI) * 0.5F + 0.5F;
        return f1;
    }

    private void func_180534_a(RenderPlayer p_180534_1_)
    {
        GlStateManager.pushMatrix();
        GlStateManager.rotate(54.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(64.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-62.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.translate(0.25F, -0.85F, 0.75F);
        p_180534_1_.func_177138_b(this.mc.thePlayer);
        GlStateManager.popMatrix();
    }

    private void func_178106_b(RenderPlayer p_178106_1_)
    {
        GlStateManager.pushMatrix();
        GlStateManager.rotate(92.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(41.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.translate(-0.3F, -1.1F, 0.45F);
        p_178106_1_.func_177139_c(this.mc.thePlayer);
        GlStateManager.popMatrix();
    }

    private void func_178102_b(AbstractClientPlayer p_178102_1_)
    {
        this.mc.getTextureManager().bindTexture(p_178102_1_.getLocationSkin());
        Render render = this.renderManager.getEntityRenderObject(this.mc.thePlayer);
        RenderPlayer renderplayer = (RenderPlayer)render;

        if (!p_178102_1_.isInvisible())
        {
            this.func_180534_a(renderplayer);
            this.func_178106_b(renderplayer);
        }
    }

    private void func_178097_a(AbstractClientPlayer p_178097_1_, float p_178097_2_, float p_178097_3_, float p_178097_4_)
    {
        float f3 = -0.4F * MathHelper.sin(MathHelper.sqrt_float(p_178097_4_) * (float)Math.PI);
        float f4 = 0.2F * MathHelper.sin(MathHelper.sqrt_float(p_178097_4_) * (float)Math.PI * 2.0F);
        float f5 = -0.2F * MathHelper.sin(p_178097_4_ * (float)Math.PI);
        GlStateManager.translate(f3, f4, f5);
        float f6 = this.func_178100_c(p_178097_2_);
        GlStateManager.translate(0.0F, 0.04F, -0.72F);
        GlStateManager.translate(0.0F, p_178097_3_ * -1.2F, 0.0F);
        GlStateManager.translate(0.0F, f6 * -0.5F, 0.0F);
        GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(f6 * -85.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(0.0F, 1.0F, 0.0F, 0.0F);
        this.func_178102_b(p_178097_1_);
        float f7 = MathHelper.sin(p_178097_4_ * p_178097_4_ * (float)Math.PI);
        float f8 = MathHelper.sin(MathHelper.sqrt_float(p_178097_4_) * (float)Math.PI);
        GlStateManager.rotate(f7 * -20.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(f8 * -20.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(f8 * -80.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(0.38F, 0.38F, 0.38F);
        GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(0.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(-1.0F, -1.0F, 0.0F);
        GlStateManager.scale(0.015625F, 0.015625F, 0.015625F);
        this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND);
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        GL11.glNormal3f(0.0F, 0.0F, -1.0F);
        worldrenderer.startDrawingQuads();
        worldrenderer.addVertexWithUV(-7.0D, 135.0D, 0.0D, 0.0D, 1.0D);
        worldrenderer.addVertexWithUV(135.0D, 135.0D, 0.0D, 1.0D, 1.0D);
        worldrenderer.addVertexWithUV(135.0D, -7.0D, 0.0D, 1.0D, 0.0D);
        worldrenderer.addVertexWithUV(-7.0D, -7.0D, 0.0D, 0.0D, 0.0D);
        tessellator.draw();
        MapData mapdata = Items.filled_map.getMapData(this.itemToRender, this.mc.theWorld);

        if (mapdata != null)
        {
            this.mc.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, false);
        }
    }

    private void func_178095_a(AbstractClientPlayer p_178095_1_, float p_178095_2_, float p_178095_3_)
    {
        float f2 = -0.3F * MathHelper.sin(MathHelper.sqrt_float(p_178095_3_) * (float)Math.PI);
        float f3 = 0.4F * MathHelper.sin(MathHelper.sqrt_float(p_178095_3_) * (float)Math.PI * 2.0F);
        float f4 = -0.4F * MathHelper.sin(p_178095_3_ * (float)Math.PI);
        GlStateManager.translate(f2, f3, f4);
        GlStateManager.translate(0.64000005F, -0.6F, -0.71999997F);
        GlStateManager.translate(0.0F, p_178095_2_ * -0.6F, 0.0F);
        GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
        float f5 = MathHelper.sin(p_178095_3_ * p_178095_3_ * (float)Math.PI);
        float f6 = MathHelper.sin(MathHelper.sqrt_float(p_178095_3_) * (float)Math.PI);
        GlStateManager.rotate(f6 * 70.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(f5 * -20.0F, 0.0F, 0.0F, 1.0F);
        this.mc.getTextureManager().bindTexture(p_178095_1_.getLocationSkin());
        GlStateManager.translate(-1.0F, 3.6F, 3.5F);
        GlStateManager.rotate(120.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(200.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.scale(1.0F, 1.0F, 1.0F);
        GlStateManager.translate(5.6F, 0.0F, 0.0F);
        Render render = this.renderManager.getEntityRenderObject(this.mc.thePlayer);
        RenderPlayer renderplayer = (RenderPlayer)render;
        renderplayer.func_177138_b(this.mc.thePlayer);
    }

    private void func_178105_d(float p_178105_1_)
    {
        float f1 = -0.4F * MathHelper.sin(MathHelper.sqrt_float(p_178105_1_) * (float)Math.PI);
        float f2 = 0.2F * MathHelper.sin(MathHelper.sqrt_float(p_178105_1_) * (float)Math.PI * 2.0F);
        float f3 = -0.2F * MathHelper.sin(p_178105_1_ * (float)Math.PI);
        GlStateManager.translate(f1, f2, f3);
    }

    private void func_178104_a(AbstractClientPlayer p_178104_1_, float p_178104_2_)
    {
        float f1 = (float)p_178104_1_.getItemInUseCount() - p_178104_2_ + 1.0F;
        float f2 = f1 / (float)this.itemToRender.getMaxItemUseDuration();
        float f3 = MathHelper.abs(MathHelper.cos(f1 / 4.0F * (float)Math.PI) * 0.1F);

        if (f2 >= 0.8F)
        {
            f3 = 0.0F;
        }

        GlStateManager.translate(0.0F, f3, 0.0F);
        float f4 = 1.0F - (float)Math.pow((double)f2, 27.0D);
        GlStateManager.translate(f4 * 0.6F, f4 * -0.5F, f4 * 0.0F);
        GlStateManager.rotate(f4 * 90.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(f4 * 10.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(f4 * 30.0F, 0.0F, 0.0F, 1.0F);
    }

    private void func_178096_b(float p_178096_1_, float p_178096_2_)
    {
        GlStateManager.translate(0.56F, -0.52F, -0.71999997F);
        GlStateManager.translate(0.0F, p_178096_1_ * -0.6F, 0.0F);
        GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
        float f2 = MathHelper.sin(p_178096_2_ * p_178096_2_ * (float)Math.PI);
        float f3 = MathHelper.sin(MathHelper.sqrt_float(p_178096_2_) * (float)Math.PI);
        GlStateManager.rotate(f2 * -20.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(f3 * -20.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(f3 * -80.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(0.4F, 0.4F, 0.4F);
    }

    private void func_178098_a(float p_178098_1_, AbstractClientPlayer p_178098_2_)
    {
        GlStateManager.rotate(-18.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(-12.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-8.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(-0.9F, 0.2F, 0.0F);
        float f1 = (float)this.itemToRender.getMaxItemUseDuration() - ((float)p_178098_2_.getItemInUseCount() - p_178098_1_ + 1.0F);
        float f2 = f1 / 20.0F;
        f2 = (f2 * f2 + f2 * 2.0F) / 3.0F;

        if (f2 > 1.0F)
        {
            f2 = 1.0F;
        }

        if (f2 > 0.1F)
        {
            float f3 = MathHelper.sin((f1 - 0.1F) * 1.3F);
            float f4 = f2 - 0.1F;
            float f5 = f3 * f4;
            GlStateManager.translate(f5 * 0.0F, f5 * 0.01F, f5 * 0.0F);
        }

        GlStateManager.translate(f2 * 0.0F, f2 * 0.0F, f2 * 0.1F);
        GlStateManager.scale(1.0F, 1.0F, 1.0F + f2 * 0.2F);
    }

    private void func_178103_d()
    {
        GlStateManager.translate(-0.5F, 0.2F, 0.0F);
        GlStateManager.rotate(30.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-80.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(60.0F, 0.0F, 1.0F, 0.0F);
    }

    /**
     * Renders the active item in the player's hand when in first person mode. Args: partialTickTime
     */
    public void renderItemInFirstPerson(float p_78440_1_)
    {
        float f1 = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * p_78440_1_);
        EntityPlayerSP entityplayersp = this.mc.thePlayer;
        float f2 = entityplayersp.getSwingProgress(p_78440_1_);
        float f3 = entityplayersp.prevRotationPitch + (entityplayersp.rotationPitch - entityplayersp.prevRotationPitch) * p_78440_1_;
        float f4 = entityplayersp.prevRotationYaw + (entityplayersp.rotationYaw - entityplayersp.prevRotationYaw) * p_78440_1_;
        this.func_178101_a(f3, f4);
        this.func_178109_a(entityplayersp);
        this.func_178110_a((EntityPlayerSP)entityplayersp, p_78440_1_);
        GlStateManager.enableRescaleNormal();
        GlStateManager.pushMatrix();

        if (this.itemToRender != null)
        {
            if (this.itemToRender.getItem() == Items.filled_map)
            {
                this.func_178097_a(entityplayersp, f3, f1, f2);
            }
            else if (entityplayersp.getItemInUseCount() > 0)
            {
                EnumAction enumaction = this.itemToRender.getItemUseAction();

                switch (ItemRenderer.SwitchEnumAction.field_178094_a[enumaction.ordinal()])
                {
                    case 1:
                        this.func_178096_b(f1, 0.0F);
                        break;
                    case 2:
                    case 3:
                        this.func_178104_a(entityplayersp, p_78440_1_);
                        this.func_178096_b(f1, 0.0F);
                        break;
                    case 4:
                        this.func_178096_b(f1, 0.0F);
                        this.func_178103_d();
                        break;
                    case 5:
                        this.func_178096_b(f1, 0.0F);
                        this.func_178098_a(p_78440_1_, entityplayersp);
                }
            }
            else
            {
                this.func_178105_d(f2);
                this.func_178096_b(f1, f2);
            }

            this.renderItem(entityplayersp, this.itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
        }
        else if (!entityplayersp.isInvisible())
        {
            this.func_178095_a(entityplayersp, f1, f2);
        }

        GlStateManager.popMatrix();
        GlStateManager.disableRescaleNormal();
        RenderHelper.disableStandardItemLighting();
    }

 

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.