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

In Minecraft, you have no way to indicate that you no longer want to trigger events. To trigger an event means that Minecraft recognizes that the event has happened and then calls the function that was set up in the event call.

For example, this shows the SetupPlayer function, which has an event setup block in it. This event is triggered after two seconds, and then it teleports the player to the center of the arena.


Because you don’t always want events to be triggered, testing your code can be difficult. For example, in Spleef you replace only the block below you with air if you’re walking on diamond blocks (the arena).

If you run the Spleef mod and play it and then decide to explore a cave instead, you start to fall through the ground. That’s because, as you can see below, every 1 second the removeBlockAfterStep function is called and the block below you is replaced with an air block.


You can get an event to stop triggering, but you have to disconnect from the server and reconnect.

To avoid having to disconnect from the server every time you play a game of Spleef, you can add a simple conditional statement that checks to make sure that you’re walking on a diamond block before it changes it to an air block.

This shows the blocks you need to add to the removeBlock function to check the type of block you’re walking on.


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: