You are previewing Absolute Beginner’s Guide to Minecraft® Mods Programming, Second Edition.
O'Reilly logo
Absolute Beginner’s Guide to Minecraft® Mods Programming, Second Edition

Book Description

Minecraft® is a registered trademark of Mojang Synergies / Notch Development AB.

This book is not affiliated with or sponsored by Mojang Synergies / Notch Development AB.

The easiest, quickest, most entertaining introduction to creating Minecraft mods in Java – updated to use the Spigot server for running your own Minecraft server and creating Minecraft mods

  • Ideal for Minecraft users, young and old, who are new to programming

  • Clear and friendly style assumes no prior programming knowledge

  • Popular author Rogers Cadenhead breaks down Minecraft mods programming concepts and terms into short, easily understandable lessons

  • Fun examples provide a step-by-step, hands-on experience that begins with simple tasks and gradually builds

  • Master Minecraft modding and use Java to transform Minecraft’s worlds, tools, behavior, weapons, structures, mobs…everything! (Plus, you’ll learn some basic Java programming skills you can use anywhere.) 

    Learn how to do what you want, the way you want, one incredibly easy step at a time. Modding Minecraft has never been this simple.

    This is the easiest, most practical beginner’s guide to creating killer Minecraft mods in Java… simple, reliable, full-color instructions for doing everything you really want to do. Here’s a small sample of what you’ll learn:

  • Set up your Minecraft server and mod development tools

  • Master Java basics every Minecraft modder needs to know

  • Read, write, store, and change information throughout your mod

  • Build mods that can make decisions and respond to player actions

  • Understand object-oriented programming and the objects you can program in Minecraft

  • Handle errors without crashing Minecraft

  • Use threads to create mobs that can do many things at once

  • Customize your mobs, and build on existing objects to write new mods

  • Spawn new mobs, find hidden mobs, and make one mob ride another

  • Dig holes and build structures

  • Create projectile weapons and potion effects

  • Learn Java programming while enhancing your favorite game

  • Contents at a Glance

    Part I: Java from the Ground Up


    1 Dig into Minecraft Programming with Java

    2 Use NetBeans for Minecraft Programming

    3 Create a Minecraft Mod

    4 Start Writing Java Programs

    5 Understand How Java Programs Work

    6 Store and Change Information in a Mod

    7 Use Strings to Communicate 

    8 Use Conditional Tests to Make Decisions

    9 Repeat an Action with Loops

    10 Store Information with Arrays


    Part II: The World of Java Objects


    11 Create Your First Object

    12 Describe What Your Object Is Like

    13 Make the Most of Existing Objects

    14 Store Objects in Data Structures

    15 Handle Errors in a Mod

    16 Create a Threaded Mod

    17 Read and Write Files


    Part III: Create Killer Minecraft Mods


    18 Spawn a Mob

    19 Make One Mob Ride Another

    20 Take a Census of Mobs and Villages 

    21 Transmute Materials in an Inventory

    22 Dig a Giant Hole

    23 Chop Down a Forest of Trees

    24 Respond to Events in the Game

    25 Display a Mob’s Health During Combat

    26 Make a World Change over Time

    27 Befriend the God of Lightning

    Appendix A Visit This Book’s Website

    Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Contents at a Glance
    5. Table of Contents
    6. About the Author
    7. Dedication
    8. Acknowledgments
    9. We Want to Hear from You!
    10. Reader Services
    11. Part I: Java from the Ground Up
      1. 1. Dig into Minecraft Programming with Java
        1. Setting Up a Minecraft Server
          1. Fixing Problems Running the Server
        2. Connecting to the Server
          1. Fixing a Server Connection Problem
      2. 2. Use NetBeans for Minecraft Programming
        1. Installing NetBeans
        2. Creating a New Project
        3. Creating a New Java Class
        4. Running the Application
        5. Fixing Errors
      3. 3. Create a Minecraft Mod
        1. Creating Your First Mod
      4. 4. Start Writing Java Programs
        1. What You Need to Write Programs
        2. Creating the Splash Program
        3. Beginning the Program
          1. The class Statement
          2. What the main Statement Does
          3. Those Squiggly Bracket Marks
        4. Storing Information in a Variable
          1. Displaying the Contents of a Variable
        5. Saving the Finished Product
        6. Compiling the Program into a Class File
        7. Fixing Errors
        8. Running a Java Program
          1. Blank Spaces and Whitespace in a Java Program
      5. 5. Understand How Java Programs Work
        1. Creating an Application
        2. Sending Arguments to Applications
        3. The Java Class Library
      6. 6. Store and Change Information in a Mod
        1. Statements and Expressions
        2. Assigning Variable Types
          1. Integers and Floating-Point Numbers
          2. Characters and Strings
          3. Other Numeric Variable Types
          4. The boolean Variable Type
        3. Naming Your Variables
        4. Storing Information in Variables
        5. All About Operators
          1. Incrementing and Decrementing a Variable
          2. Operator Precedence
        6. Using Expressions
      7. 7. Use Strings to Communicate
        1. Storing Text in Strings
        2. Displaying Strings in Programs
        3. Using Special Characters in Strings
        4. Pasting Strings Together
        5. Using Other Variables with Strings
        6. Advanced String Handling
          1. Comparing Two Strings
          2. Determining the Length of a String
          3. Changing a String’s Case
          4. Looking for a String
        7. Presenting Credits
      8. 8. Use Conditional Tests to Make Decisions
        1. if Statements
          1. Less-Than and Greater-Than Comparisons
          2. Equal and Not Equal Comparisons
          3. Organizing a Program with Block Statements
        2. if-else Statements
        3. switch Statements
        4. The Ternary Operator
        5. Watching the Clock
      9. 9. Repeat an Action with Loops
        1. for Loops
        2. while Loops
        3. do-while Loops
        4. Exiting a Loop
        5. Naming a Loop
          1. Complex for Loops
        6. Testing Your Computer Speed
      10. 10. Store Information with Arrays
        1. Creating Arrays
        2. Using Arrays
        3. Multidimensional Arrays
        4. Sorting an Array
        5. Counting Characters in Strings
    12. Part II: The World of Java Objects
      1. 11. Create Your First Object
        1. How Object-Oriented Programming Works
        2. Objects in Action
        3. What Objects Are
        4. Understanding Inheritance
        5. Building an Inheritance Hierarchy
        6. Converting Objects and Simple Variables
          1. Casting Simple Variables
          2. Casting Objects
          3. Converting Simple Variables to Objects and Back
          4. Autoboxing and Unboxing
        7. Creating an Object
      2. 12. Describe What Your Object Is Like
        1. Creating Variables
        2. Creating Class Variables
        3. Creating Behavior with Methods
          1. Declaring a Method
          2. Similar Methods with Different Arguments
          3. Constructor Methods
          4. Class Methods
          5. Variable Scope Within Methods
        4. Putting One Class Inside Another
        5. Using the this Keyword
        6. Using Class Methods and Variables
      3. 13. Make the Most of Existing Objects
        1. The Power of Inheritance
          1. Inheriting Behavior and Attributes
          2. Overriding Methods
        2. Establishing Inheritance
          1. Using this and super in a Subclass
        3. Working with Existing Objects
        4. Storing Objects of the Same Class in Array Lists
          1. Looping Through an Array List
        5. Creating a Subclass
      4. 14. Store Objects in Data Structures
        1. Array Lists
        2. Hash Maps
          1. Why Classes Are Synchronized
      5. 15. Handle Errors in a Mod
        1. Exceptions
          1. Catching Exceptions in a try-catch Block
          2. Catching Several Different Exceptions
          3. Handling Something After an Exception
          4. Throwing Exceptions
          5. Ignoring Exceptions
          6. Exceptions That Don’t Need Catch
        2. Throwing and Catching Exceptions
      6. 16. Create a Threaded Mod
        1. Threads
          1. Slowing Down a Program
          2. Creating a Thread
        2. Working with Threads
          1. The class Declaration
          2. Setting Up Variables
        3. The Constructor
        4. Catching Errors as You Set Up URLs
        5. Starting the Thread
          1. Running the Thread
        6. Handling Mouse Clicks
        7. Displaying Revolving Links
          1. Stopping a Thread
      7. 17. Read and Write Files
        1. Streams
          1. Files
          2. Reading Data from a Stream
          3. Buffered Input Streams
        2. Writing Data to a Stream
        3. Reading and Writing Configuration Properties
    13. Part III: Create Killer Minecraft Mods
      1. 18. Spawn a Mob
        1. The Mod Framework
        2. Starting a Mod Project
        3. Writing the Mod’s Code
          1. Deploying a Mod
      2. 19. Make One Mob Ride Another
        1. Starting the Project
        2. Writing the Mod
        3. Deploying the Mod
      3. 20. Take a Census of Mobs and Villages
        1. Starting the Project
        2. Creating the Project
          1. Deploying a Mod
      4. 21. Transmute Materials in an Inventory
        1. Starting the Project
        2. Creating the Project
          1. Deploying the Mod
      5. 22. Dig a Giant Hole
        1. Starting the Project
        2. Creating the Project
          1. Deploying the Mod
          2. Backing Up a Minecraft World
      6. 23. Chop Down a Forest of Trees
        1. Starting the Project
        2. Creating the Project
          1. Deploying the Mod
      7. 24. Respond to Events in the Game
        1. Starting the Project
        2. Creating the Project
          1. Deploying the Mod
      8. 25. Display a Mob’s Health During Combat
        1. Starting the Project
        2. Creating the Project
          1. Deploying the Mod
          2. Learning Spigot Methods from NetBeans
      9. 26. Make a World Change over Time
        1. Starting the Project
        2. Creating the Project
          1. Deploying the Mod
      10. 27. Befriend the God of Lightning
        1. Starting the Project
        2. Stepping Through Mod Development
        3. Creating the Project
          1. Deploying the Mod
          2. Joining the Community of Mod Developers
    14. Appendix A. Visit This Book’s Website
    15. Index
    16. Code Snippets