775
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.
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.
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.
Subscribe if you want to get notified of new posts.
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
/notfound<--[HERE]
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-functionSee how useful the log window can be?
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
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.
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.
Tags |
tools/tracking
4944853
6
function-data-packs-for-dummies-4-debugging-amp-quality-control
Create an account or sign in to comment.