The making of a gui based dynamic Forge energy bar with a tool tip.

Started by Eritze on

Topic category: User side tutorials

Joined Jul 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The making of a gui based dynamic Forge energy bar with a tool tip.
Wed, 07/23/2025 - 14:43 (edited)

Making a dynamic Forge energy bar can be a difficult task for a beginner, This power bar can be applied to any machine without changing its internal structure or values . Here is an example


To make this bar I am gonna use a sprite , sprites in Mcreator  work by splitting a image into equal parts horizontally or vertically, My power bar

in game  is  16 x 16 and it has 10 sprites so that is a 16 x 160 image when divided equally into 10 sprites it comes out to 16 x 16 per sprite keep that in mind when creating you're sprite sheet my sprite sheet happens to be vertically in length and has sprites form 0 filled at the bottom to fully filled at the top so that would be the index 10 for 0 filled and 0 for fully filled.


Next is is creating a procedure, sprites change by changing the index witch is just a number and it is based on how many sprites you have, we calculate it based on this procedure 

https://imgur.com/a/n9w8nv2

 The first variables cur_energy and max_energy are to get the values of the current block , from that it checks if there is 0 energy so it can draw the sprite 10 witch is the empty energy sprite and zero is a full sprite, the variable result is used to calculate the percentage of our energy so if our cur energy is 100 and our max energy is 1000 it calculates that our energy percentage is 0.1 filled the next variable sprite index is used to determine the sprite index , 10 - is used to flip our numbers upside down because our empty energy sprite is index 10 and our 0 sprite is a full bar , then we get the number from the result and we round it down because of decimal points, and we get our value witch is 9 for 0.1 percentage filled last part is the clamp we clamp the values so they don't go over 10 and under 0, lastly we return the number sprite index that we calculated earlier, we return it to the sprites index and we put this procedure in our sprite where the index of a sprite is shown.


Next is The making of a tool tip is verry easy,

https://imgur.com/uqn9fAX

 you just create a new procedure go into the text blocks, return text witch returns the text to the tooltip, you check how much energy it has , and you check its max energy , and you put this procedure into the tooltips value. and place it over your energy bar .


This was verry hard to figure out for me due to the limited amount on documentation this software , hope it helps someone.

Edited by Eritze on Wed, 07/23/2025 - 14:43