24. Respond to Events in the Game

In This Chapter

Turn a mod’s functionality on and off

Create a mod that listens to events

Run code the first time a server loads a mod

Access the server and server’s mod manager

Use the this keyword in a Java class

Listen every time a player moves in Minecraft

Find the block below a player’s location

Mods can do something once when a command is entered by a player. Enter a /choptrees command and chop down a forest of trees.

Mods can do something that affects game play for a sustained time. Enter /petwolf multiple times and attract a pack of wolves who come to your defense whenever mobs attack.

Mods also can do nothing.

The mod you create during this chapter does nothing until an event happens ...

Get Minecraft Mods Programming Absolute Beginner’s Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.