Minecraft Modding: How to Create the Basic Spleef Scene

By Sarah Guthals, Stephen Foster, Lindsey Handley

The first step in creating your Minecraft game is to build the scene. These instructions explain how to create the scene for a basic game called Spleef. The scene in Spleef is an arena that has a fence around it.

image0.jpg

To make this arena, you use the ArenaBuilder library on LearnToMod. A library is a mod that is already written for you. You can use it without having to know how it is written.

To explore the library, follow these steps:

  1. Go to mod.learntomod.com/programs/sarah-ArenaBuilder.

    You see these five functions:

    • init

    • move_drone

    • ArenaWithFence

    • Platform

    • Fence

  2. Click the question mark (?) on each function.

    A comment pops up, describing what the function does. For example, here is the comment for the Fence function.

    image1.jpg

  3. Look through this code, and its parameters, to see what the code is doing.

    Notice that there’s no main function, because this mod cannot run on its own in Minecraft. Instead, it must be called from other mods.

    Also notice the block: export. The export block makes the function that’s written in the block accessible to other mods, meaning other mods can call the functions even though they’re in a different mod.

    image2.jpg

    Three functions are being exported: ArenaWithFence, init, and move_drone.

  4. Now you can use these three functions in your Spleef game.

After you have exposed the ArenaBuilder library, go back to your Spleef mod and import the library. Follow these steps:

  1. Under the Misc category, find the import block.

    image3.jpg

  2. Drag it into the mod and type sarahArenaBuilder to replace the text lib-name.

    image4.jpg

    If you enter the mod name correctly, the block stays green and new functions appear under the Functions category.

    image5.jpg

    Notice that the three functions you now have access to the three that were exported from the ArenaBuilder library.

  3. Create a main function, and add a call to the init function from the ArenaBuilder library.

    The init function, if you look back at the library, basically creates the drone that will be used to create the arena for you.

    image6.jpg

  4. After your drone is ready to build your arena, add a call to the ArenaWithFence function from the ArenaBuilder library to the main function.

    This shows how to make a 20 x 20 arena made of diamond with a fence that’s five blocks high and a platform width of one block. The arena will be filled with air. This makes the arena where you will play Spleef.

    image7.jpg

  5. Even though you didn’t write the ArenaBuilder library, test your code as you’re building it. To test your code, make sure that the mod is saved, click the Mod button, and test the code in Minecraft.

    You see a scene like this one.

    image8.jpg

  6. Before moving on, refactor the code — change it without changing what it does.

  7. In this case, you’re refactoring the code so that the arena is built in a function named arena and so that the arena function is called from main.

    image9.jpg

Congratulations — you’ve created the basic Spleef scene!