Guest User

RenderChapeau

a guest
Jan 28th, 2015
19
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.yannblanc.aliceadsl.agriculcraft.client.render;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.EntityLivingBase;
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.util.ResourceLocation;
  7. import net.minecraftforge.client.IItemRenderer;
  8.  
  9. import org.lwjgl.opengl.GL11;
  10.  
  11. import fr.yannblanc.aliceadsl.agriculcraft.common.Modmain;
  12.  
  13. public class RenderChapeau implements IItemRenderer
  14. {
  15. protected ModelChapeau model;
  16. protected static final ResourceLocation texture = new ResourceLocation(Modmain.MODID + ":" + "textures/armor/chapeau.png");
  17.  
  18. public RenderChapeau()
  19. {
  20.  
  21. model = new ModelChapeau();
  22. }
  23.  
  24. @Override
  25. public boolean handleRenderType(ItemStack item, ItemRenderType type)
  26. {
  27. switch(type)
  28. {
  29. case EQUIPPED:
  30. return true;
  31. case EQUIPPED_FIRST_PERSON:
  32. return true;
  33. case INVENTORY:
  34. return true;
  35. default:
  36. return false;
  37. }
  38. }
  39.  
  40. @Override
  41. public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
  42. {
  43. if(helper == ItemRendererHelper.INVENTORY_BLOCK)
  44. {
  45. return true;
  46. }
  47. return false;
  48. }
  49.  
  50. public void render(Entity par1Entity, float par2, float par3, float par4,
  51. float par5, float par6, float par7) {
  52. if (par1Entity instanceof EntityLivingBase) {
  53. EntityLivingBase entity = (EntityLivingBase)par1Entity;
  54. GL11.glPushMatrix();
  55. float y = 1.5f;
  56. if(entity.isSneaking())
  57. y = 1.53f;
  58. GL11.glRotated(180, 0.0D, 0.0D, 1.0D);
  59. GL11.glRotated(180, 0.0d, 1.0d, 0.0d);
  60. GL11.glTranslatef(0.0f, -y, 0.0f);
  61. GL11.glScalef(0.045f, 0.045f, 0.045f);
  62. float factor = 1f / 0.045f;
  63.  
  64.  
  65. GL11.glTranslated(0.0d, 1.5f * factor, 0.0f);
  66.  
  67.  
  68. GL11.glRotated(-par5, 0.0f, 1.0f, 0.0f);
  69.  
  70. GL11.glTranslated(0.0d, -y * factor, 0.0f);
  71.  
  72. GL11.glTranslated(0.0d, y * factor, 0.0f);
  73. GL11.glRotatef(par6, 1.0f, 0.0f, 0.0f);
  74. GL11.glTranslated(0.0d, -y * factor, 0.0f);
  75.  
  76.  
  77. GL11.glShadeModel(GL11.GL_SMOOTH);
  78. model.render();
  79. GL11.glPopMatrix();
  80. }
  81. }
  82.  
  83.  
  84. private float interpolateRotation(float par1, float par2, float par3)
  85. {
  86. float f3;
  87.  
  88. for(f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F)
  89. {
  90. ;
  91. }
  92.  
  93. while(f3 >= 180.0F)
  94. {
  95. f3 -= 360.0F;
  96. }
  97. return par1 + par3 * f3;
  98.  
  99. }
  100.  
  101. @Override
  102. public void renderItem(ItemRenderType type, ItemStack item, Object... data)
  103. {
  104. // TODO Auto-generated method stub
  105.  
  106. }
  107. }
RAW Paste Data