Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.04 KB | None | 0 0
  1. @SideOnly(Side.CLIENT)
  2. public class GuiHUD extends Gui
  3. {
  4.     private Minecraft mc;
  5.     private static final ResourceLocation hudTexture = new ResourceLocation("mchardcore", "textures/gui/hud.png");
  6.     private static final ResourceLocation armourBarTexture = new ResourceLocation("mchardcore", "textures/gui/armour_bar.png");
  7.     private static final ResourceLocation airBarTexture = new ResourceLocation("mchardcore", "textures/gui/air_bar.png");
  8.    
  9.     public GuiHUD(Minecraft mc)
  10.     {
  11.         super();
  12.         this.mc = mc;
  13.     }
  14.    
  15.     @SubscribeEvent
  16.     public void onRenderHealthBar(RenderGameOverlayEvent event)
  17.     {
  18.        
  19.         if(event.type.equals(ElementType.HEALTH) && event.isCancelable())
  20.         {
  21.             event.setCanceled(true);
  22.            
  23.             this.mc.getTextureManager().bindTexture(hudTexture);
  24.            
  25.             //GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
  26.             //GL11.glEnable(GL11.GL_ALPHA_TEST);
  27.             GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  28.             GL11.glDisable(GL11.GL_LIGHTING);
  29.            
  30.             this.drawTexturedModalRect(5, 5, 0, 0, 118, 38);
  31.            
  32.             EntityPlayer player = this.mc.thePlayer;
  33.            
  34.             ExtendedPlayerProperties properties = ExtendedPlayerProperties.fetchProperties(player);
  35.            
  36.             if(properties == null)
  37.             {
  38.                 return;
  39.             }
  40.            
  41.             int totalLevelXp = properties.calculateNewExpToLevel(properties.getLevel());
  42.             int currentXp = properties.getCurrentXp();
  43.            
  44.             int xpRemaining = totalLevelXp-currentXp;
  45.            
  46.             //SET BAR WIDTHS
  47.             float health = player.getHealth();
  48.             float maxHealth = player.getMaxHealth();
  49.             int stamina = player.getFoodStats().getFoodLevel();
  50.             int armour = player.getTotalArmorValue();
  51.            
  52.             int hungerBarWidth = (int)(((float)stamina/20)*79);
  53.             int armourBarWidth = (int)(((float)armour/20)*79);
  54.             int healthBarWidth = (int)(((float)health/maxHealth)*79);
  55.             int xpBarWidth = (int)(((float)currentXp/totalLevelXp)*79);
  56.  
  57.         //DRAW BARS
  58.             //HEALTH
  59.             this.drawTexturedModalRect(41, 13, 0, 52, healthBarWidth, 7);
  60.            
  61.             Entity mount = player.ridingEntity;
  62.            
  63.             //HUNGER
  64.             if(mount == null)
  65.             {
  66.                 this.drawTexturedModalRect(41, 21, 0, 45, hungerBarWidth, 7);
  67.             }
  68.            
  69.             //EXP
  70.             this.drawTexturedModalRect(41, 29, 0, 38, xpBarWidth, 7);
  71.            
  72.             //SET SCREEN POS FOR ARMOUR AND AIR
  73.             int xPos = event.resolution.getScaledWidth() / 2 - 91;
  74.             int yPos = event.resolution.getScaledHeight() - 40;
  75.            
  76.             //ARMOUR BAR
  77.             if(armour > 0)
  78.             {
  79.                 this.mc.getTextureManager().bindTexture(armourBarTexture);
  80.                
  81.                 this.drawTexturedModalRect(xPos, yPos-10, 0, 0, 81, 9);
  82.                 this.drawTexturedModalRect(xPos+1, yPos-9, 0, 9, armourBarWidth, 7);
  83.             }
  84.            
  85.             //AIR BAR
  86.             if(player.isInsideOfMaterial(Material.water))
  87.             {
  88.                 int air = player.getAir();
  89.                 int airBarWidth = (int)Math.floor((((float)air/300)*79));
  90.                
  91.                 this.mc.getTextureManager().bindTexture(airBarTexture);
  92.                
  93.                 this.drawTexturedModalRect(xPos+101, yPos-10, 0, 0, 81, 9);
  94.                 this.drawTexturedModalRect(xPos+102, yPos-9, 0, 9, airBarWidth, 7);
  95.             }
  96.            
  97.  
  98.             this.drawCenteredString(this.mc.fontRenderer, "\u00A7a"+properties.getLevel(), 23, 20, 0xffffffff);
  99.            
  100.         }
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement