@@ -190,31 +190,38 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
190190 return false ;
191191 }
192192
193- private void renderAttributeTextAndIcon (GuiGraphics guiGraphics , int iconOffset , String text , Bounds bounds ) {
193+ private void renderAttributes (GuiGraphics guiGraphics , LivingEntity entity ) {
194+ RenderSystem .setShaderTexture (0 , Constants .ATTRIBUTES_TEXTURE );
194195 int iconSize = 9 ;
195- int iconSpacing = 4 ;
196- int width = iconSize + iconSpacing + font . width ( text ) ;
196+ int iconSpacing = 2 ;
197+ int gap = 8 ;
197198
198- // Center within given bounds
199- int y = bounds .y_center () - iconSize / 2 ;
200- int x = bounds .x_center () - width / 2 ;
199+ int yPos = leftPageBounds .top () + 13 ;
201200
202- guiGraphics . blit ( Constants . ATTRIBUTES_TEXTURE , x , y , 0 , iconOffset , iconSize , iconSize , 32 , 32 );
203- guiGraphics . drawString ( this . font , text , x + iconSize + iconSpacing , y + 1 , Constants . TEXT_COLOR , false );
204- }
201+ String health = String . valueOf (( int ) entity . getMaxHealth () / 2 );
202+ String armor = String . valueOf ( entity . getArmorValue () );
203+ boolean showArmor = ! armor . equals ( "0" );
205204
206- private void renderAttributes (GuiGraphics guiGraphics , LivingEntity entity ) {
207- RenderSystem .setShaderTexture (0 , Constants .ATTRIBUTES_TEXTURE );
205+ int healthWidth = this .font .width (health ) + iconSpacing + iconSize ;
206+ int armorWidth = this .font .width (armor ) + iconSpacing + iconSize ;
207+ int totalWidth = healthWidth + (showArmor ? gap + armorWidth : 0 );
208208
209- // Health
210- String health = String .valueOf ((int )entity .getMaxHealth () / 2 );
211- Bounds healthBounds = new Bounds (leftPageBounds .left (), leftPageBounds .bottom () - 48 , leftPageBounds .width () / 2 , 20 );
212- renderAttributeTextAndIcon (guiGraphics , 0 , health , healthBounds );
209+ int xPos = this .leftPageBounds .x_center () - (totalWidth / 2 );
213210
214- // Armor
215- String armor = String .valueOf (entity .getArmorValue ());
216- Bounds armorBounds = new Bounds (leftPageBounds .x_center (), leftPageBounds .bottom () - 48 , leftPageBounds .width () / 2 , 20 );
217- renderAttributeTextAndIcon (guiGraphics , 9 , armor , armorBounds );
211+ // Draw Health
212+ guiGraphics .blit (Constants .ATTRIBUTES_TEXTURE , xPos , yPos , 0 , 0 , iconSize , iconSize , 32 , 32 );
213+ guiGraphics .drawString (this .font , health , xPos + iconSize + iconSpacing , yPos + 1 , Constants .TEXT_COLOR , false );
214+
215+ // Draw Frame
216+ guiGraphics .blit (Constants .HEALTH_FRAME_TEXTURE , xPos - 9 , yPos - 4 , 0 , 0 , 8 , 16 , 16 , 16 );
217+ guiGraphics .blit (Constants .HEALTH_FRAME_TEXTURE , xPos + totalWidth + 1 , yPos - 4 , 8 , 0 , 8 , 16 , 16 , 16 );
218+
219+ if (showArmor ) {
220+ // Draw Armor
221+ xPos = xPos + healthWidth + gap ;
222+ guiGraphics .blit (Constants .ATTRIBUTES_TEXTURE , xPos , yPos , 0 , iconSize , iconSize , iconSize , 32 , 32 );
223+ guiGraphics .drawString (this .font , armor , xPos + iconSize + iconSpacing , yPos + 1 , Constants .TEXT_COLOR , false );
224+ }
218225 }
219226
220227 @ Override
@@ -289,7 +296,7 @@ public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, flo
289296 }
290297
291298 int xPos = leftPageBounds .x_center ();
292- int yPos = leftPageBounds .y_center () - 20 ;
299+ int yPos = leftPageBounds .y_center ();
293300
294301 if (entry instanceof EntityType && renderedEntity instanceof LivingEntity living ) {
295302 if (unlocked ) {
0 commit comments