Topic category: User side tutorials
While researching references for my administrative mod, I noticed that many servers use GUIs with player heads as icons!
For example:
(Spigot - PlayerProfile)
Since I'm developing a mod similar to systems already used on plugin-based servers, I searched around and found a resource pack called "2D Player Heads - MCModels". From there, the idea was simple: integrate this pack into my mod and make it work inside a GUI.
That’s when I realized how challenging this task really is...
To begin with:
Your GUI must have two slots for this method to work. If there’s only one, the game crashes.
In my case, I used input_slot
s, though I believe it may also work with output_slot
s.
Using my system as an example, in the image you can see one gray slot and one red slot.
The red slot is our “extra” slot, which serves no functional purpose other than to act as a trigger.
In the Slot whe will use the "When slot contens change" trigger.
As you can see, this slot is filtered to only accept minecraft:air
, with item drop, pickup, and placement all disabled.
We will use this slot's trigger to define our NBT changer — it will set the item in the gray slot and apply the correct NBT data.
NBT changer Procedure code:
Variable:
My command code:
I get the PlayerName from the command inself.
(Procedure called by the command.)
(Command)
In the GUI Whe will use the "When this GUI is opened" trigger:
The GUI trigger code:
Here’s how it basically works:
A command is sent, and when that command runs, it captures the player's name from its arguments and stores it in a variable.
That same command also opens the GUI.
Once the GUI is opened, it places an air block into the extra slot — this triggers an event that sets a player head with no skin into the main slot.
Right after that, the head is automatically updated with the skin of the player whose name was stored in the variable.
You can hide the extra slot by placing on top off the main slot:
I'm still working on the mod's code and visuals, but this is the current base screen.
Thats it! If you want to get the player name to set in the Label you can use this:
Procedure:
Label:
I hope this helps!!!
Bob325