O'Reilly logo

Minecraft Modding with Forge by Arun Gupta, Aditya Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. New Commands

In this chapter, you’ll learn how to add new commands to the game and customize them to your liking. Minecraft already has many commands—for example, the /summon command lets you spawn an entity wherever you want to, and /setblock lets you place a block anywhere you wish. Each new command you create using Forge requires two things: first, a new file containing the command’s details, and second, a line in a new method that registers the command in the main file. This chapter has a lot more Java code than the previous ones, so pay attention carefully.

The first command you will create will spawn a specified number of flaming pigs at the sender’s location. This can be used for fun things like a cloud of particles or tons of porkchops. Then, you will make a command that lets you choose two locations, and when you use the command, the area between the two locations gets filled with the block of your choice.

Flaming Pigs

In Minecraft, pigs aren’t normally on fire. The only way to ignite them is to push them into a fire block or into lava. This mod will add a command that lets you spawn whatever number of pigs you want and also sets them on fire. It isn’t really very useful—it’s just funny to see a bunch of pigs on fire. And isn’t that what the entire game of Minecraft is about?

First, create a new class and call it FlamingPigs. This will be the file that stores all of the command’s details. We will fill in all the details of this class later. Server commands ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required