Minecraft Blogs / Tutorial

Function Data Packs for Dummies #4 | Debugging & Quality Control

  • 2,682 views, 2 today
  • 41
  • 20
  • 1
Bertiecrafter avatar Bertiecrafter
Site Moderator
Level 67 : High Grandmaster Stack
This series of tutorials will teach you how to create your very own data packs, assuming you know absolutely nothing about commands. Although data packs could just contain files that replace built-in assets like resource packs, these posts will focus on adding new features and mechanics to the game. In every part I assume you've read the previous parts.

Oops, something went wrong :/

Problems that cause code to show unexpected behavior are called "bugs". The process of removing bugs is "debugging". Unfortunately code rarely work first time, but that doesn't have to mean that fixing bugs has to be a pain. If you would write "/notfound" in chat you would get the following error:
Unknown or incomplete command, see below for error

If you were to put "notfound" on a new line in a function you don't get this helpful message and the function doesn't even get loaded. This means that all other commands in that same function won't execute either. Although the message doesn't appear in-game anymore, it still appears in the logs. To view the logs, open up the Minecraft launcher and press Settings. Tick the checkbox that says "Open output log when Minecraft: Java Edition starts". When you now start the game, you'll see a second window listing the Minecraft logs as soon as they are generated. You can uncheck the "info" category to hide unnecessary logs. If you now do a "/reload" with the bad command still in place, you will see an error appear in the log window. The error below was caused by me putting "gamemode epic" into my function file. I'll mark the useful parts in bold underline.
Failed to load function bertiecrafter:my-first-data-pack/my-first-function
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Whilst parsing command on line 3: Incorrect argument for command at position 9: gamemode <--[​HERE]
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1584)
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1574)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.IllegalArgumentException: Whilst parsing command on line 3: Incorrect argument for command at position 9: gamemode <--[​HERE]
at cw.a(SourceFile:62)
at ut.a(SourceFile:84)
at ut$$Lambda$3620/224789883.get(Unknown Source)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1582)
... 5 more

See how useful the log window can be?

Quality Control

Besides all features working correctly 100% of the time, data pack quality also consists of compatibility with other data packs, compatibility with new versions of the game and safety created by not executing any dangerous commands. In the previous blog I explained that you should add an extra folder inside the "functions" folder, which is one of the guidelines that help prevent clashes with other data packs. The guidelines that are mentioned in this tutorial series are not enforced by Minecraft, but I do recommend following them.

In order to help you follow these guidelines and achieve good quality, I created software that checks your data pack and helps you improve it. The software is a style checker, showing you red text if there are any issues and green text if you passed a rule. A rule is basically a little bit of code that checks if your data pack follows a guideline.

You can find a post dedicated to the Data Pack Checker here and documentation to get started here. On the documentation page, you'll find links to the recommended rules and a configuration file.

Note: One of the rules mentions an uninstall function, which will be explained in the next tutorial. Another rule also mentions As/At comments, which will be introduced in a much later tutorial. You can ignore any issues regarding these rules for now.

Challenge Yourself

After every tutorial, I'll include a section where you are challenged to apply what you've learned. I recommend you playing with what you've learned, it helps you getting familiar with new concepts and be able to find solutions to problems. You don't have to do exactly what's written below, you can always challenge yourself in a different way.

Set up your Minecraft Launcher to open up the log window. Make deliberate mistakes in commands within function files and see if you can understand the error messages. Try to pinpoint where the useful information is in case your data pack stops working because of a broken command. Also read the documentation of the Data Pack Checker linked above and try to get it working. See what you need to do in order to get all the rules to light up green.

What's next?

Next up we're going to look at the built in tick and load events as well as writing an uninstall function.
Subscribe if you want to get notified of new posts.

Function Data Packs for Dummies #4 | Debugging &amp; Quality Control
Function Data Packs for Dummies #4 | Debugging &amp; Quality Control

Create an account or sign in to comment.

02/07/2021 8:35 amhistory
Level 67 : High Grandmaster Stack
Bertiecrafter avatar
Thank you FishStacks, Luracasmus, usernamed_, Gheppio, Eyynom, TheBigPug, DinoDesmond, JitteryPluto, McMeddon, Yellowglacier, pettyGamingHD, MegaMushroomJack, Vellariya, PMC, jeanluccy, Sir_Wodr, Drakio-X, A_Bread_Boii, RoBoo1194, Mega_Bea, User3500563G, SUPERIONtheKnight, Blip_Creations, luci_gamer123, CuteCatsXXL1, Bartyv, LieutenanT_T, Milwit, Zeyrox_21, dale_miro2020, RedCreeper430, MrDead8, ChoiceTheorem, ThorsMaps, GizaBuilder0811, HappeeGhost, SlyNeptune and Unavalible_User for the diamonds!
Planet Minecraft


© 2010 - 2022