| 1 | package net.minecraft.client.renderer.entity.layers;
|
| 2 |
|
| 3 | import net.minecraft.block.Block;
|
| 4 | import net.minecraft.client.Minecraft;
|
| 5 | import net.minecraft.client.model.ModelBiped;
|
| 6 | import net.minecraft.client.renderer.GlStateManager;
|
| 7 | import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
| 8 | import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
| 9 | import net.minecraft.entity.EntityLivingBase;
|
| 10 | import net.minecraft.entity.player.EntityPlayer;
|
| 11 | import net.minecraft.init.Items;
|
| 12 | import net.minecraft.item.Item;
|
| 13 | import net.minecraft.item.ItemBlock;
|
| 14 | import net.minecraft.item.ItemStack;
|
| 15 |
|
| 16 | public class LayerHeldItem implements LayerRenderer<EntityLivingBase>
|
| 17 | {
|
| 18 | private final RendererLivingEntity<?> livingEntityRenderer;
|
| 19 |
|
| 20 | public LayerHeldItem(RendererLivingEntity<?> livingEntityRendererIn)
|
| 21 | {
|
| 22 | this.livingEntityRenderer = livingEntityRendererIn;
|
| 23 | }
|
| 24 |
|
| 25 | public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
|
| 26 | {
|
| 27 | ItemStack itemstack = entitylivingbaseIn.getHeldItem();
|
| 28 |
|
| 29 | if (itemstack != null)
|
| 30 | {
|
| 31 | GlStateManager.pushMatrix();
|
| 32 |
|
| 33 | if (this.livingEntityRenderer.getMainModel().isChild)
|
| 34 | {
|
| 35 | float f = 0.5F;
|
| 36 | GlStateManager.translate(0.0F, 0.625F, 0.0F);
|
| 37 | GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F);
|
| 38 | GlStateManager.scale(f, f, f);
|
| 39 | }
|
| 40 |
|
| 41 | ((ModelBiped)this.livingEntityRenderer.getMainModel()).postRenderArm(0.0625F);
|
| 42 | GlStateManager.translate(-0.0625F, 0.4375F, 0.0625F);
|
| 43 |
|
| 44 | if (entitylivingbaseIn instanceof EntityPlayer && ((EntityPlayer)entitylivingbaseIn).fishEntity != null)
|
| 45 | {
|
| 46 | itemstack = new ItemStack(Items.fishing_rod, 0);
|
| 47 | }
|
| 48 |
|
| 49 | Item item = itemstack.getItem();
|
| 50 | Minecraft minecraft = Minecraft.getMinecraft();
|
| 51 |
|
| 52 | if (item instanceof ItemBlock && Block.getBlockFromItem(item).getRenderType() == 2)
|
| 53 | {
|
| 54 | GlStateManager.translate(0.0F, 0.1875F, -0.3125F);
|
| 55 | GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
|
| 56 | GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
|
| 57 | float f1 = 0.375F;
|
| 58 | GlStateManager.scale(-f1, -f1, f1);
|
| 59 | }
|
| 60 |
|
| 61 | if (entitylivingbaseIn.isSneaking())
|
| 62 | {
|
| 63 | GlStateManager.translate(0.0F, 0.203125F, 0.0F);
|
| 64 | }
|
| 65 |
|
| 66 | minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON);
|
| 67 | GlStateManager.popMatrix();
|
| 68 | }
|
| 69 | }
|
| 70 |
|
| 71 | public boolean shouldCombineTextures()
|
| 72 | {
|
| 73 | return false;
|
| 74 | }
|
| 75 | }
|
| 76 |
|