GDA Minecraft Adventure Map
Last summer (2022), I joined the GDA Adventure Map project run by Zoey to try and help with the project. Eventually, I shifted from a participant role to a planner role and am now helping plan out it's execution until completion.
We recently decided that we want the map (and the server) to use a custom resource pack for the purposes of adding custom block models! In my process of figuring out how this worked, I decided to automate a lot of the process as the server website we're using, Shockbyte, takes 50 years to load each page and it's annoying to update/upload a new pack everytime someone makes a change.
Using Github Actions/Workflows, it's actually pretty easy to setup. Just keep in mind that this process only works for Minecraft servers, not clients.
Below is my process and how I think Github Actions and workflows work, this was my first time using them so if I got anything wrong, please feel free to let me know.
Resource Packs and adding them to a server
Adding a resource pack to a server is pretty easy. In your server config properties, you'll see a field called "resource-pack", and it will likely be empty.
To use it, you will need a download link to your resource pack (Dropbox or Github work pretty well), and the link must be added in the "resource-pack" field. There are also plugins you can use to manage this, but using the default server properties functionality works fine. The download link must provide a .zip file and the .zip file must follow the file structure specified by Minecraft, but the main points are the pack.mcmeta file (which contains all the descriptive info of your pack), and the assets folder (which contains the meat and potatoes of your resource pack).
You might think that this link might work, as it's prompts a download to a .zip file of your repository on Github.
However, this does not work, as the .zip file is dynamically created upon entering the link, and not stored on Github's servers anywhere until clicked.
Instead, we will create a .zip file automatically within the repository itself whenever we push (you might spot release.zip on the left)
Github Actions + Workflow
In my quest to automate the resource pack, I wanted to see if I could provide a link to a .zip file in the Github repo as a valid link. It worked!
So all we need to do is create a new .zip file in the repo whenever someone pushes a change to the main branch! To do this, I used Github Actions to automatically pull everything from the repo, zip it up, then push the .zip file to the repo, overriding the old release.zip.
You can see your workflows in the Actions section on Github.
Breaking it down:
This is a workflow file that describes the workflow we're going to take. If placed in .github/workflows in the repo, it'll be automatically read by Github.
Line 1 is the name of this workflow. (Archival Zip)
Lines 3-9 are a basic descriptor of when this workflow happens. It runs on any push to the main branch that changes files at any path in assets/ or the pack.mcmeta file. (keywords bolded in blue for more clarity)
Starting on line 11, the rest of the file describes the job taking place; it runs using ubuntu-latest.
The steps of the job start at line 15, where first, the Github Actions bot will checkout the code using the secret TOKEN as credentials (I'll talk more about secrets later).
(21) Then, it pulls the latest version of the repo, and removes the old release.zip file.
(29) After that, it zips the repo to a new .zip file called release.zip, and excludes any .git files (using this utility here).
(35) Finally, it auto-commits the changes with the commit message "new pack!" (using this utility here).
Something I didn't mention in the breakdown was secrets - You might have noticed the secrets.TOKEN in the above code snippet. Secrets are defined in your repository in a special location in the settings. For the secret I called TOKEN, I added a personal access token to my Github account, meaning can access the repository using my credentials. This way, I can create code that uses this TOKEN secret that doesn't require me to show my login information.
Custom Hats and getting the pack into the server
Ok, this part I'm not going to go into too much detail over but I will briefly cover. How do we make custom hats for the resource pack itself?
For our purposes, we're using creating and texturing the custom models in Blockbench.
There are plenty of tutorials on how to create a model with Blockbench, so feel free to look those up. Honestly I just winged it and managed to create this bad boy.
WARNING: with any file names involving minecraft resource packs, do NOT use capital letters!
Once you create the model, you'll be able to texture it in Blockbench. There's an auto-UV feature that worked decently for me, although you can mess with your own manual UV map if you want as well.
When you're done texturing, you'll end up with two files:
A model file (in the form of a .json file)
A texture file (in the form of a .png file)
Make sure that you mark your texture as "Use for Particles".
This is the contents of our resource pack right now. The big ones I'm going to be looking at are:
calextest.json (model file of my hat)
pyorohat.png (texture file of my hat)
carved_pumpkin.json (item file of the carved pumpkin block)
pumpkinblur.png (this texture replaces the pumpkin visual blur that happens when the pumpkin is equipped as a helmet)
This carved_pumpkin.json file will need to be modified every time you add a new hat.
The overrides change the model file used for the pumpkin depending on the custom_model_data value; increase by one for each hat you have, and add the path to the new hat model file as well.
In your model file, make sure that your path for the textures of your model match the path in your resource pack of the .png file you added from Blockbench.
And that's it! To get the pack onto the server, I just added the link to the release.zip file on the Github to the "resource-pack" property in server properties.
https://github.com/clxrffdman/GDA-Minecraft-Resource-Pack/blob/main/release.zip?raw=true
I can give any hat with custom model data to the player using:
/give @p carved_pumpkin{CustomModelData:1}
(replace 1 with any index you want)
A slight annoyance is that the players need to delete the local version of the server pack in their .minecraft folder (server-resource-packs) whenever they want to receive an update, as Minecraft auto-caches server resource packs and won't detect an update, as the link remains the same (if someone finds a way to force Minecraft to check for a new version of the .zip everytime upon logging in let me know).
If you want to check out the repo, check it out here! Hope this is helpful!