š Your First Custom Bar
Let's learn by doing! In this tutorial, we'll create a simple health bar for Pigs (PIG
) that will display their name and health in a text format.
Step 1: Create the Design (Layout)
Go to the plugins/SunshineHealthBars/layouts/
folder and create a new file named pig_layout.yml
. Open the file and paste the following code:
# This is our blueprint. It defines two lines of text.
layout-lines:
# Line 1: Displays the pig's name in pink.
- line: '&d%sunshine_mob_name%'
y-offset: 0.25 # We position it slightly upwards.
# Line 2: Displays the current and max health with a heart.
- line: '&c⤠&f%sunshine_health_current%&7/&f%sunshine_health_max%'
scale: 0.8 # We make it a little smaller.
Step 2: Assign the Design to the Pig
Now, open the most important file: mob_assignments.yml
, located in the main plugin folder (plugins/SunshineHealthBars/
).
Add the following section to the file (or modify the existing one if you already have one for PIG
):
# We tell the plugin that all PIGs should use our new design.
PIG:
name: 'Oinker' # This name will replace %sunshine_mob_name%
layout: 'pig_layout' # The name of our layout file!
vertical-offset: 1.2 # Adjusts the bar's height above the pig.
components: {} # We leave this empty since our design doesn't use components.
Step 3: Reload and Enjoy!
Save both files and run one of these commands in-game or in the console:
/sbreload
(if you have permission)Or restart the server.
Now, find a pig! You'll see it has its new custom health bar. Congratulations, you've created your first bar! You can now experiment by changing the colors, text, and values.
Last updated