Celestial Storytelling

a datapack adding observatories and a celestial storyline to minecraft

headshotSpring2020.jpg

Nina Navazio


Incoming Microsoft User Experience (UX) writer. Studied English, Interactive Multimedia, and Creative Writing as an Honors student at TCNJ. Served as the student radio station’s Station Manager for two years and interning with Microsoft summer 2020.

navazin1 (at) tcnj.edu

Link to my Github!

 

Did you just play Minecraft for thesis?

Yes and no. Mostly no, because really what I was doing was making a Minecraft Datapack. But I did play a lot of Minecraft. With well over 48 hours of gameplay logged for solely development purposes, Minecraft truly became my quarantine getaway. But most of my time mining and crafting resulted in the development of the Astronomer Datapack.





What is a Datapack?

A datapack is a way to program Minecraft that is supported by Minecraft; it's basically a collection of very simple lines of code that when put together can make more complex things happen. 



Datapacks are written in an arbitrary language (because why would they make it easy and do it in C++ or Java?), the same language used in-game for blocks called Command Blocks. Command Blocks are exactly like block-coding, but instead of being in a 2D UI, the “blocks of code” are actual Minecraft blocks. So a Datapack is basically a collection of a bunch of command block lines of code, with a bit more functionality than what Command Blocks can do (like call other functions by name, save buildings / structures, create custom block groups for easy block references, and more).



A few notes for coders out there:

  • All variables are public in a Datapack

  • All variables must be stored as Scoreboard values, meaning only integers (though you can divide them to get doubles / floats at the end of the process)

  • Functions cannot take arguments

  • There are no bracket if-statements (all if-statements are one line, so if there are multiple things that need to happen they either need to be put together in a separate function that executes on the if-statement, or multiples of the same if-statement)

  • There are no while-loops or for-loops (must be done with a counter in a Scoreboard value)

  • each file is a different function, there are no classes or objects except for the entities / blocks in the game



How do Datapacks work?

At their most basic level, Datapacks are generally a network of .mcfunction files. These files are commonly called from the load.mcfunction and tick.mfcuntion files, which are designated functions that run once on Datapack load and every tick (respectively). 

Functions can also be called manually in the game by typing /function <namespace>:<function address>, for example:

/function astronomer:structuregeneration/observatory2/setchunk

The above is the function in my Datapack that actually spawns a structure (in this case, an observatory) in the game. Below is the entire function. All lines are executable in Minecraft as well, just put a / in front of them to designate a command in chat.

#------ # OBSERVATORY SET CHUNK # Actually sets the structure block in place # and adds the doors and the chest with loot_table. #------ setblock ~ ~ ~ air setblock ~ ~ ~ minecraft:structure_block[mode=load]{name:"astronomer:observatory",rotation:"NONE",mirror:"NONE",mode:"LOAD",posX:0,posY:-10,posZ:0} keep execute if block ~ ~ ~ minecraft:structure_block run setblock ~1 ~ ~ minecraft:redstone_block execute as @e[name=observatorychest,limit=1] at @s run setblock ~ ~1 ~ minecraft:oak_slab[type="top"] execute as @e[name=observatorychest,limit=1] at @s run setblock ~ ~ ~ minecraft:chest{LootTable:"astronomer:chests/observatory"} kill @e[name=observatorychest] setblock ~ ~ ~ air setblock ~1 ~ ~ air #Set the door (the door rotates, not the structure!) execute positioned ~4 ~1 ~4 run function astronomer:structuregeneration/observatory2/setdoor fill ~ ~8 ~ ~8 ~100 ~8 air #------ # Print the location of the observatory in chat # for debugging purposes #------ #kill @e[type=area_effect_cloud,tag=setchunk] #summon area_effect_cloud ~ ~ ~ {Tags:["setchunk"]} #execute as @e[tag=setchunk,limit=1] store result score x coord run data get entity @s Pos[0] #execute as @e[tag=setchunk,limit=1] store result score y coord run data get entity @s Pos[1] #execute as @e[tag=setchunk,limit=1] store result score z coord run data get entity @s Pos[2] #tellraw @a "Setting chunk..." #tellraw @a ["",{"text":"Score is "},{"score":{"name":"x","objective":"coord"}}] #tellraw @a ["",{"text":"Score is "},{"score":{"name":"y","objective":"coord"}}] #tellraw @a ["",{"text":"Score is "},{"score":{"name":"z","objective":"coord"}}]




Why did you make a Datapack?

Studying English, Interactive Multimedia, and Creative Writing, I’ve always been interested in interactive storytelling. I love the stories told through games, and Minecraft hold a special place in my heart. Like so many of my friends, I grew up with Minecraft. I loved the open-world style, and I remember trying to survive my first night in a dirt hole in 2011. And as Minecraft has evolved, I've loved reading and watching different theories about the lore of Minecraft, but I was always surprised that there weren't any real solve-able mysteries in Minecraft itself; there were no explanations to the villages you found, or why different structures generated in the world.


So I geared my thesis towards interactive storytelling, and thought Minecraft was a great way to collide all my worlds together. Making a Datapack also allowed me to immerse myself in an entirely new environment, and forced me to learn how to break down problems to their most understandable bits. Because Datapacks are written line-by-line, it’s easy to debug them. And because they’re supported by Mojang, there’s a lot of documentation and development going on as we speak. There are some really insane datapacks out there, like adding vehicles, furniture, and decorations or even new biomes. And future updates look promising and they’ll bring new functionalities to datapacks, making them even more powerful.

What does the Astronomer Datapack do?

In my Datapack, I added observatories that generate randomly as you explore the world (you can see the code above!) and inside of them are loot chests with books. Those books build to a bigger mystery that’s solv-able by yourself, but through playtesting it’s clear that it’s way more fun with friends.


I won’t spoil much, but I will say that it’s best described as a “side quest” adventure (thank you Jordan). It won’t interfere with any quest for the End, and observatories shouldn’t generate on pre-generated structures like villages. Though they could potentially generate on player-made structures, so just to be safe, only use this datapack on a new world.

What did you learn?

As with any coding project, I learned how to problem solve better before. Each coding language brings its own challenges, and overcoming them is incredibly gratifying. Figuring out different problems like how to project a particle effect in a certain location or how to generate structures on the surface of the world instead of mid-air presented unique challenges that had just enough support from the community and documentation to be solvable, but also just difficult and niche enough that the solution wasn’t just on StackOverflow (although a lot of answers and tips were found there).


Overall, I’d say I continued to practice how to break down problems into their parts, then how to theoretically solve the problems, and finally how to implement the solutions. Also, I got to play Minecraft for thesis, so that was pretty cool, too.

Learn more on my Github!

To learn more about my project and to play the Datapack yourself you can check out my Github here

I’ll also be hosting a Minecraft server during the showcase on May 14th for visitors to check out the Datapack live!

Special thanks to…

Tony Navazio, Mom & Dad, Sophia Pereira, Ben Spizuco, Pat O’Callaghan, Ev Huynh, Donna Jung, Krist Hastings, Dr. Nakra, Prof. Fishburn, Prof. Ault. This project wouldn’t have been possible without all of you :)