package ru.Pa4ok.mod.test;
import java.util.UUID;
import org.lwjgl.opengl.GL11;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.StringUtils;
import ru.Pa4ok.mod.entity.extended.ExtendedEntityPlayer;
import ru.Pa4ok.mod.util.hook.gloomyfolken.hooklib.asm.Hook;
import ru.Pa4ok.mod.util.hook.gloomyfolken.hooklib.asm.ReturnCondition;
public class RenderBipedHook
{
@Hook(injectOnExit = true)
public static void doRender(RenderBiped renderBiped, EntityLiving p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
System.out.println("mark2");
}
@Hook(createMethod = true, returnCondition = ReturnCondition.ALWAYS)
public static void renderEquippedItems(RenderBiped renderBiped, EntityLiving entityLiving, float var1)
{
System.out.println("mark1");
GL11.glColor3f(1.0F, 1.0F, 1.0F);
//super.renderEquippedItems(entityLiving, var1);
ItemStack itemstack = entityLiving.getHeldItem();
ItemStack itemstack1 = entityLiving.func_130225_q(3);
Item item;
float f1;
if (itemstack1 != null)
{
GL11.glPushMatrix();
renderBiped.modelBipedMain.bipedHead.postRender(0.0625F);
item = itemstack1.getItem();
net.minecraftforge.client.IItemRenderer customRenderer = net.minecraftforge.client.MinecraftForgeClient.getItemRenderer(itemstack1, net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED, itemstack1, net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D));
if (item instanceof ItemBlock)
{
if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item).getRenderType()))
{
f1 = 0.625F;
GL11.glTranslatef(0.0F, -0.25F, 0.0F);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(f1, -f1, -f1);
}
renderBiped.renderManager.itemRenderer.renderItem(entityLiving, itemstack1, 0);
}
else if (item == Items.skull)
{
f1 = 1.0625F;
GL11.glScalef(f1, -f1, -f1);
GameProfile gameprofile = null;
if (itemstack1.hasTagCompound())
{
NBTTagCompound nbttagcompound = itemstack1.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkullOwner")))
{
gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
}
}
TileEntitySkullRenderer.field_147536_b.func_152674_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, itemstack1.getItemDamage(), gameprofile);
}
GL11.glPopMatrix();
}
if (itemstack != null && itemstack.getItem() != null)
{
item = itemstack.getItem();
GL11.glPushMatrix();
if (renderBiped.mainModel.isChild)
{
f1 = 0.5F;
GL11.glTranslatef(0.0F, 0.625F, 0.0F);
GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F);
GL11.glScalef(f1, f1, f1);
}
renderBiped.modelBipedMain.bipedRightArm.postRender(0.0625F);
GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);
net.minecraftforge.client.IItemRenderer customRenderer = net.minecraftforge.client.MinecraftForgeClient.getItemRenderer(itemstack, net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED, itemstack, net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D));
if (item instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item).getRenderType())))
{
f1 = 0.5F;
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
f1 *= 0.75F;
GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(-f1, -f1, f1);
}
else if (item == Items.bow)
{
f1 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(f1, -f1, f1);
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
}
//else if (ItemGun.oruzhiye(itemstack.getItem(), 1))
else if(itemstack.getItem() instanceof ItemGun)
{
System.out.println("mark");
/*if ((entityLiving.getClass().equals(EntityPlayer.class) || entityLiving.getClass().equals(EntityPlayerMP.class)))
{
EntityPlayer player = (EntityPlayer)entityLiving;
ExtendedEntityPlayer props = ExtendedEntityPlayer.get(player);
if(props.reloading > 0)
{
f1 = 0.5F;
GL11.glTranslatef(0.0F, 0.42F, 0.03F);
GL11.glRotatef(-60.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(f1, -f1, f1);
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
}
}
else
{*/
f1 = 0.5F;
GL11.glTranslatef(0.0F, 0.35F, 0.08F);
GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(f1, -f1, f1);
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
//}
}
else if (item.isFull3D())
{
f1 = 0.625F;
if (item.shouldRotateAroundWhenRendering())
{
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.0F, -0.125F, 0.0F);
}
//
//renderBiped.func_82422_c();
GL11.glTranslatef(0.0F, 0.1875F, 0.0F);
//
GL11.glScalef(f1, -f1, f1);
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
}
else
{
f1 = 0.375F;
GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
GL11.glScalef(f1, f1, f1);
GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
}
float f2;
int i;
float f5;
if (itemstack.getItem().requiresMultipleRenderPasses())
{
for (i = 0; i < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++i)
{
int j = itemstack.getItem().getColorFromItemStack(itemstack, i);
f5 = (float)(j >> 16 & 255) / 255.0F;
f2 = (float)(j >> 8 & 255) / 255.0F;
float f3 = (float)(j & 255) / 255.0F;
GL11.glColor4f(f5, f2, f3, 1.0F);
renderBiped.renderManager.itemRenderer.renderItem(entityLiving, itemstack, i);
}
}
else
{
i = itemstack.getItem().getColorFromItemStack(itemstack, 0);
float f4 = (float)(i >> 16 & 255) / 255.0F;
f5 = (float)(i >> 8 & 255) / 255.0F;
f2 = (float)(i & 255) / 255.0F;
GL11.glColor4f(f4, f5, f2, 1.0F);
renderBiped.renderManager.itemRenderer.renderItem(entityLiving, itemstack, 0);
}
GL11.glPopMatrix();
}
}
}