Minecraft Modding For Kids For Dummies
Book image
Explore Book Buy On Amazon

When the code in your Minecraft mod isn’t working the way you want, such as when you make a row of eight bricks instead of two rows of four bricks, it may have an error, or bug. If your code has a bug in it, you have to debug it, or fix it. Writing large, complex mods makes it even more likely that you’ll run into mistakes that are hard to find.

Here are four strategies for debugging your code:

  • Walk away. When your code stops making sense, just walk away and watch a video or TV show, and then get back to the task at hand. Sometimes, when you work on one problem for a long time, you miss the error that would be easy to find if you were to simply take a break.

    Tech companies such as Microsoft, Google, and Facebook often have game rooms with Xbox, PlayStation, foosball, and ping-pong set up so that their programmers can take breaks when they run into tricky bugs.

  • Draw using pencil and paper. The great thing about programming something you can see is that you can trace your code and draw it out on paper. Go line by line and move your pencil just like the drone, and draw a block whenever the drone places a block. That will help you see anything that is going wrong.

  • Disable blocks. In this helpful technique, you add the blocks into your mod 1 block by 1 block. Rather than delete your code, you can just disable specific lines that may be causing trouble.

    image0.jpg

    When you have a bug you can’t find, disable all blocks except the main function and the first block in the main function. Then run your mod. Then enable the next block, and run your mod. Continue doing that until you find the bug.

    image1.jpg
  • Ask for help in the forums. LearnToMod has forums where you can ask for help.

    image2.jpg

You can search by clicking on the magnifying glass or just browse topics to find them. Here’s a sample screen from a forum. Sometimes, someone else has already found the bug that you’ve run across, so the answer might even already be there.

The term bug referred to a technical error even before computers were invented. Admiral Grace Hopper (an amazing computer scientist!) found a literal bug — a moth, to be exact — in one of the first computers, which was causing her program to misbehave.

About This Article

This article is from the book:

About the book authors:

Sarah Guthals, Ph.D. is the CTO of ThoughtSTEM and has dedicated her life to coding education.

Stephen Foster, Ph.D. is the CEO of ThoughtSTEM, a company that teaches computer science to kids across America.

Lindsey Handley, Ph.D. is the COO of ThoughtSTEM and has hundreds of hours of experience as a classroom instructor for Minecraft based science and computer science classes.

This article can be found in the category: