Minecraft Datapack Cutscenes!

By Jesse Strijker | Feb 18th , 2024

To give a game a more complete look, nice visuals can always be a large part. Thus the inclusion of simple cutscenes in our datapack seemed obvious. 

How to make cutscenes in minecraft however is less obvious. Below I included a somewhat technical explanation of how it is done.

As opposed to Minecraft bedrock edition, the java edition, what we are developing on, does not allow for extra cameras. So a cutscene has to be done in a different way. We have to user the player themselves as a cutscene camera. The player character has to follow a set path and look at set positions for it to function as a cutscene.

Fortunately Minecraft has a usefull mechanic that allows entities to spectate other entities. So a player can spectate a cow or a pig for example. A player can also spectate an ‘item display’. This is a relatively new entity added to Minecraft that allows items to be displayed, as the name conveniently spoils. These item displays have a usefull feature called ‘teleport duration’. As one expects, this function gives a time window for a teleportation command, and interpolates the position of the entity with each frame. So you get a moving entity from one point to another. If we let the user spectate this point in spectator mode we get a nice camera.

This unfortunately is not all. To have a more complete cutscene, the user, preferably, gets put back to their original location. But oh boy, that is not as simple as it seems. The regular teleport command in minecraft only allows for integers. So /tp 9 9 9. One can not use stored coordinates for this. So if you want to work with variables in minecraft datapacks you have to store them in a scoreboard. If i collect the data of a player and save their positions in a scoreboard, I am consequently not able to teleport to this data by saying /tp variable1 variable2 variable3. 

No we have to find a workaround. What we can do is modify entity data with scoreboard variables. Great, we dont teleport the player to coordinates, but we just modify player data! 

Except, no! Minecraft does not allow you to modify player data. why? No clue. So how do we solve it now? Now we cannot edit player data but we can edit other entities their data. So we summon an entity (say an armorstand), we modify its position to the scoreboard data. And lastly we teleport the player to the correct entity. Because teleportation between entities is still possible.

So after all that work we have a cutscene where the user experiences it correctly, and gets put back in the correct spot after the scene is done.

Category: Minecraft