Datapack Creation
Contents
Certain aspects of Pixelmon, such as species, NPCs, drops and structures can be edited through JSON files. These files can be accessed by using a program such as Winrar or 7-Zip to open the Pixelmon mod JAR file, and must be applied using a Datapack. JSON files can be edited with any plain text editor however it is recommended to use a program dedicated to editing code files, such as Virtual Studio Code or Notepad++.
External JSON files should be edited carefully, as bad edits can potentially result in unexpected behavior from Pixelmon. Certain tools (such as JSONLint) can be used to verify that files are formatted correctly. There are also several 3rd-party tools that can be used to generate JSON files for Datapacks. For example, there is Misode's Generators and Minecraft Tools.
After editing JSON files in an existing datapack, they will need to be reloaded in order for the changes to take effect. It is strongly advised to restart your client or server to ensure all files are applied correctly.
Datapackable Files
The following types of files can currently be edited via a datapack:
File type | Folder name | Description |
Abilities | abilities
|
Governs configuration files for each Ability and is where custom-created Abilities are located. |
Advancements | advancements
|
Settings for advancements obtained from doing certain actions. These use the Minecraft advancement JSON format. |
Boss Tiers | bosstiers
|
Governs Boss Pokemon tiers, including their drops, mega specifications and colour. |
Advanced Global Configurations | config
|
Controls several different configuration files, including Starter specs, Shopkeeper items, the Better Spawner config, Traders and NPC Trainer textures. |
Daycare | daycare
|
Governs Daycare settings, including the item costs and hour costs for each type. |
Dimensions | dimension dimension_type
|
Governs settings for Ultra Space and Drowned World, such as the biomes that are generated and structures. |
Drops | drops
|
Governs settings for Drops, including Pokemon drops, Pokeloot, Raids and imprint amounts for TRs and TMs. |
Loot Tables | loot_tables
|
Governs settings for Loot tables used in Pixelmon Structures and Pokestop loot along with block drops. |
Moves | moves
|
Governs configuration files for each Move and is where custom-created Moves are located. |
NPCs | npcs
|
Controls many Pixelmon NPC-related settings, such as Shopkeeper NPCs, NPC Trainer sets and Chatting NPCs. |
Pokéballs | pokeballs
|
Holds configuration files for Pokéballs such as controlling the assets used, the capture method and logic used. This is where custom Pokéballs should be located. |
Quests | quests
|
Governs default and custom Quests. |
Raid Battles | raids
|
Governs which Pokémon can spawn in Raid Dens in which biome and at what Star level(s). |
Crafting Recipes | recipes
|
Governs configuration files for all Recipes in Pixelmon, including recipes used in the Infuser and Vanilla machines. |
Marks/Ribbons | ribbons
|
Governs configuration files for the various Marks and Ribbons in Pixelmon. This is where custom Marks and Ribbons will be located |
Battle Rules | rules
|
Governs rulesets and tiers for competitive battling. |
Spawn Replacement | spawn_replacement
|
Controls settings for Spawn Replacement logic used by Pixelmon that replaces Vanilla Mobs with Pokemon. This is used to re-enable specific vanilla mobs or change the replacement logic. |
Spawning | spawning
|
Governs what Pokémon spawn where, when and how. Includes fishing, bosses and Cave Rock/Grass spawns. This also includes NPC spawning files. |
Species | species
|
Governs Pokémon species files which include every part of information about a Pokemon. Their moves, stats, egg group, mount settings, palettes and forms. This is where custom species should be located and where custom forms can be added into. |
Structures | structures
|
Contains the structure templates as NBT files. These are used in the Worldgen settings to naturally generate structures and/or can be loaded in via Structure Block. |
World Generation | world_gen
|
Defines settings for world generation, such as template pools that govern how structures can generate. These will only affect newly generated terrain. |
Please note: When Pixelmon is updated, internal copies of the above files may change but external will not. If you are using a datapack, keep a close eye on the changelogs and refresh or update files where necessary. Outdated files may cause issues, or contain bugs that have since been fixed.
Creating a Data pack
This section will provide a detailed guide on how to create a basic Datapack for Pixelmon including how to extract files from Pixelmon, add them to your Datapack and edit them. This example will turn Bulbasaur into a Fire-Poison Type. For a more technical guide and further explanation of Datapack functions, see here. A video guide can also be found here.
- Find a suitable location to create the Datapack. It's advised to create a datapack in an easily accessible folder, such as your Documents, Downloads or Desktop. You can also go to your World folder -> Datapacks folder and create it there. This tutorial will create a Datapack in an existing world. You can get to the Datapacks folder from in-game too.
- Create a folder in the Datapacks folder. This is what the Datapack will be called. Ensure it starts with lowercase letters and can only contain lowercase letters, numbers, underscores, hyphens, and periods. For example,
My_Test_Datapack
is suitable. - In your Datapack folder, right click and create a Text Document called
pack.mcmeta
. The entire file name should be replaced with this, including the "txt" part. IMPORTANT: The file extension must be an mcmeta file, not a JSON or Text type. It's advised you enable "hidden file extensions" to verify this. - Open the pack.mcmeta file with a text editor. Notepad is suitable. Paste the following code into the file. Once pasted, save the file and close:
{ "pack": { "pack_format": 6, "description": "My test datapack" } }
- Create a new folder called
data
. Go into this folder. Create a folder calledpixelmon
. Your file path should beMy_Test_Datapack\data\pixelmon\
excluding your world.- Note: You should now have a working empty Datapack. To verify this, go into your world and type
/datapack list
. If you wish to see how to create an example Datapack, continue reading.
- Note: You should now have a working empty Datapack. To verify this, go into your world and type
- Next you will need to find the file you wish to edit. For this example, we will be turning Bulbasaur into a Fire-Poison Type.
- Go the Pixelmon mod file. If you are in-game, you can get here quickly by hitting escape and go to Options -> Resource Packs -> Open Pack folder. Then go back one folder and into the mods folder. Another method is through your launcher. See here. Instead of going to
config
, go tomods
. - Right click the Pixelmon mod file (typically named
Pixelmon-(MC version)-(MOD VERSION)-universal)
. Open it with your preferred archiver tool. Most commonly used ones are Winrar or 7-Zip. - Go into the
data\pixelmon\species
folder. Drag the001_bulbasaur.json
file into yourspecies
folder created earlier in the Datapack. Notice how the folders you created mimic the folders in the mod file. This is how Minecraft finds and reads the data. - Open the
001_bulbasaur.json
file with a text editor of your choice. - Scroll all the way down to this section of code:
"types": [ "GRASS", "POISON" ]
- Remove the part that says GRASS and replace it with FIRE. Ensure you keep the quotation marks
""
and the comma,
. Save your file - Launch Minecraft and load your world the datapack is located in.
- Type
/datapack list
to ensure your Datapack has loaded. - Give yourself a Bulbasaur.
/pokegive [user] bulbasaur
and check its summary. If the icon for Fire is there, congratulations! You have created a Datapack that changed Bulbasaur into a Fire-Poison type.
Troubleshooting
If your Datapack does not function how it should or an error appears when loading into your world, then you must debug it. This section will guide you on how to debug and resolve common issues with Datapacks.
Firstly, ensure you have restarted your client or server after making any changes. Files need to be reloaded before they will take effect.
Check your logs
The main step is to read your logs. As the game runs, it reports back information on what's going on at the time, including any errors. For help finding your logs, see Finding your logs
- Couldn't parse data file pixelmon:[Insert file] from pixelmon:[file path]
com.google.gson.JsonParseException: com.google.gson.stream.MalformedJsonException:
Unterminated object at [Position] path [Line/broken code]
This error means your file is invalid. This typically means there is a syntax error with your file. Example could be a missing comma ,
or any missing element. To resolve this, copy and paste your entire file and run it through a JSOn validator as mentioned earlier. One can be found here.
- [main/ERROR] [Pixelmon/]: Cannot find ability with name '[Ability]'!
This error means you have added an abiltiy to a Pokemon that is incorrect. This could either be a misspelt Ability or the Ability format is wrong. For example, Compound Eyes
is incorrect and would cause this error. However CompoundEyes
will work fine.
- [main/WARN] [Pixelmon/]: Attack name invalid: [Move]
This error means you have given a Pokemon with an incorrect move. This could either be a misspelt Move or the Move format is wrong. If this error is present in logs but you have not touched the move or added it in any way, it can be safely ignored.
- [Server thread/WARN] [minecraft/ResourcePackInfo]: Couldn't get pack info for: net.minecraft.resources.ResourcePackFileNotFoundException: 'pack.mcmeta' in ResourcePack '.\world\datapacks\[Datapack].zip'
This means your pack.mcmeta
file is invalid or missing. This can be caused by a syntax error in the file itself or you have structured the datapack incorrectly. To structure it correctly, always ensure the base Datapack folder goes directly to the data
folder. For example, the file path My Datapack.zip\My Datapack\data\pixelmon
is incorrect. Minecraft will not look further. The correct file path would be Incorrect Structure.zip\data\pixelmon
(The Datapack itself can be a regular folder, does not need to be zipped). Zipped Datapacks do not need to be unzipped if downloaded from external sources.
- Caused by: java.lang.IllegalArgumentException: No enum constant com.pixelmonmod.pixelmon.api.pokemon.species.gender.Gender.FEALE
- Caused by: java.lang.IllegalArgumentException: No enum constant com.pixelmonmod.pixelmon.api.pokemon.Element.POSON
An error that references Java code or "No enum constant" typically means a hard-coded aspect of Pixelmon is incorrect/mispelt. The error should further clarify what part of the Pokemon is wrong, such as Element (Type) or "Gender".
Other problems
If the above errors do not match your issues or you require further assistance, post the log in a website such as Pastebin, and post the resulting link in either the Pixelmon forum's support tracker or the Pixelmon Discord's #log-upload channel and ask for assistance in the #datapack-support channel.