Skip to Content
Minecraft Modding with Forge
book

Minecraft Modding with Forge

by Aditya Gupta, Arun Gupta
April 2015
Intermediate content levelIntermediate
200 pages
4h 17m
English
O'Reilly Media, Inc.
Content preview from Minecraft Modding with Forge

Chapter 3. Fun with Explosions

Chapter 2 explained how to make your first mod. Now that the basic fundamentals are well understood, we can move at a slightly faster pace and make more interesting mods. This chapter will teach you how to make mods related to explosions.

First, you will make minecarts explode when they collide with a mob. Next, you will make anvils explode when they fall on an entity. Then, you will make diamond ore explode when mined. Lastly, you will increase the size of TNT explosions. Each mod will also include ways to use the mod, such as falling anvil traps or bouncing zombie towers!

Let’s make some explosions!

Exploding Minecarts

Minecarts are one of the main ways of transport in Minecraft. They use rails to travel and can carry mobs or players. However, they don’t do much besides that. This mod aims to make our minecarts do some fun stuff. With this mod, minecarts will make a small explosion when they collide with an entity, possibly killing the entity in question.

As explained in the last chapter, a group of mods need to have only one main file. We already created that, and so the only new file that needs to be created is an event handler. Create the event handler as explained in “Creating a Java Class for Event Handling”, and name it ExplodingMinecarts. Once again, you can use whatever name you like for the file, but it’s best to indicate the mod’s purpose in the filename.

Add a Java method to this class that will listen for the event. The code you will ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Minecraft Modding with Forge

Minecraft Modding with Forge

Aditya Gupta, Arun Gupta

Publisher Resources

ISBN: 9781491918883Errata Page