How to create a datapack to modify shrines loot tables - Silverminer007/Shrines GitHub Wiki

How to create a datapack to modify shrines loot tables

We first need to create the datapack itself. In next step we will add the pack description to the pack to allow minecraft to load the pack. In last step we will modify balloons loot as example

A Datapack is a folder with configuration (JSON) files in it, so we start by creating a new folder. Now we want minecraft to be able to detect our folder as datapack. To do so we create a new file and name it ‘pack.mcmeta‘. This file contains any necessary information about the datapack to be loaded. Here is an example content for the file:

{
	"pack": { 
		"pack_format": 6,
		"description": "My Datapack for Shrines Mod"
	}
}

There are two properties to set. The first is ‘pack_format’, which depends on the Minecraft version, you want to use. Use 1 for 1.13 – 1.14.4, use 5 for 1.15 – 1.16.1, use 3 for 1.16.2 – 1.16.5 and use 7 for 1.17+ The second property is ‘description’. Write there anything you want. There is no technical use for that. It is only there to be shown in datapack overview.

Now Minecraft is able to detect your datapack. To test if everything worked so far, create a new world and press ‘Data Packs’ button. Now you can drag and drop your datapack in that screen and it should appear in ‘Available’ and you only need to move it to the right to activate it!

As we have successfully created a datapack we can now go on and take a look on how to change something with a datapack. In general, you can change things by creating a JSON file in correct format and override to original behavior by placing in to the same path as to original file. (Here you can get an overview what is possible: https://minecraft.fandom.com/wiki/Data_Pack)

You see that you can do many things with datapacks and it’s not easy to understand everything by first look, so we’ll take a closer look on how to override balloon’s loot table.

As said before Balloon’s loot is defined by loot tables. So we need to change a loot table. The path for loot tables is ‘data//loot_tables’, in our case it is ‘data/shrines/loot_tables’ as we want to modify shrines data.

As you can see here: https://github.com/Silverminer007/Shrines/tree/experimental/src/main/resources/data/shrines/loot_tables/chests Shrines uses an subfolder in the ‘loot_tables’ folder called ‘chests’. To override the original loot table, we also need to create the subfolder in our data pack.

In the subfolder directory ‘data/shrines/loot_tables/chests’, you can now add the JSON files to change the loot tables of the shrines mod.

To change balloons loot, create a file called ‘ballon.json’ in that folder and it will replace the original one. For other structures you can lookup the linked github side. Use the same name to change it.

You can find the complete Datapack here: https://github.com/Silverminer007/My-Datapack/tree/main

Hopefully everything works to you too! If not or you have further questions feel free to ask for help on discord(https://discord.gg/8pUpWCEUe2)