Guest User

GuiWeightedPlayer

a guest
Dec 26th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.36 KB | None | 0 0
  1. package com.happykiller.weightlimit.client.gui.player;
  2.  
  3. import org.lwjgl.opengl.GL11;
  4.  
  5. import com.happykiller.weightlimit.main.ModReference;
  6. import com.happykiller.weightlimit.player.inventory.InventoryWeightLimit;
  7. import com.happykiller.weightlimit.player.inventory.container.ContainerWeightedPlayer;
  8.  
  9. import net.minecraft.client.Minecraft;
  10. import net.minecraft.client.gui.inventory.GuiContainer;
  11. import net.minecraft.client.renderer.GlStateManager;
  12. import net.minecraft.client.renderer.OpenGlHelper;
  13. import net.minecraft.client.renderer.RenderHelper;
  14. import net.minecraft.client.renderer.entity.RenderManager;
  15. import net.minecraft.entity.EntityLivingBase;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.entity.player.InventoryPlayer;
  18. import net.minecraft.util.ResourceLocation;
  19.  
  20. public class GuiWeightedPlayer extends GuiContainer {
  21.    
  22.     private float xSize_lo;
  23.     private float ySize_lo;
  24.    
  25.     private static final ResourceLocation iconLocal = new
  26.             ResourceLocation(ModReference.MOD_ID, "textures/gui/container/player/WeightedInventory.png");
  27.  
  28.     private final InventoryWeightLimit inv;
  29.    
  30.     public GuiWeightedPlayer(EntityPlayer player, InventoryPlayer invPlayer, InventoryWeightLimit invW) {
  31.         super(new ContainerWeightedPlayer(player, invPlayer, invW));
  32.        
  33.         this.inv = invW;
  34.     }
  35.    
  36.     public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  37.         super.drawScreen(mouseX, mouseY, partialTicks);
  38.        
  39.         this.xSize_lo = (float)mouseX;
  40.         this.ySize_lo = (float)mouseY;
  41.     }
  42.    
  43.     //protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {}
  44.  
  45.     protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  46.         GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  47.        
  48.         this.mc.getTextureManager().bindTexture(iconLocal);
  49.        
  50.         int k = (this.width - this.xSize) / 2;
  51.         int l = (this.height - this.ySize) / 2;
  52.        
  53.         this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
  54.        
  55.         //int i1;
  56.        
  57.         this.drawPlayerModel(k + 51, l + 75, 30, (float)(k + 51) - this.xSize_lo, (float)(l + 75 - 50) - this.ySize_lo, this.mc.thePlayer);
  58.     }
  59.    
  60.     public static void drawPlayerModel(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_) {
  61.         GlStateManager.enableColorMaterial();
  62.         GlStateManager.pushMatrix();
  63.         GlStateManager.translate((float)p_147046_0_, (float)p_147046_1_, 50.0F);
  64.         GlStateManager.scale((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_);
  65.         GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
  66.         float f2 = p_147046_5_.renderYawOffset;
  67.         float f3 = p_147046_5_.rotationYaw;
  68.         float f4 = p_147046_5_.rotationPitch;
  69.         float f5 = p_147046_5_.prevRotationYawHead;
  70.         float f6 = p_147046_5_.rotationYawHead;
  71.         GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
  72.         RenderHelper.enableStandardItemLighting();
  73.         GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
  74.         GlStateManager.rotate(-((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
  75.         p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F;
  76.         p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F;
  77.         p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F;
  78.         p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw;
  79.         p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw;
  80.         GlStateManager.translate(0.0F, 0.0F, 0.0F);
  81.         RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
  82.         rendermanager.setPlayerViewY(180.0F);
  83.         rendermanager.setRenderShadow(false);
  84.         rendermanager.renderEntityWithPosYaw(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
  85.         rendermanager.setRenderShadow(true);
  86.         p_147046_5_.renderYawOffset = f2;
  87.         p_147046_5_.rotationYaw = f3;
  88.         p_147046_5_.rotationPitch = f4;
  89.         p_147046_5_.prevRotationYawHead = f5;
  90.         p_147046_5_.rotationYawHead = f6;
  91.         GlStateManager.popMatrix();
  92.         RenderHelper.disableStandardItemLighting();
  93.         GlStateManager.disableRescaleNormal();
  94.         GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
  95.         GlStateManager.disableTexture2D();
  96.         GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
  97.     }
  98. }
Add Comment
Please, Sign In to add comment