Indianapolis, Indiana 46240

 Minecraft Mods

Programming

Rogers Cadenhead

800 East 96th Street,

Indianapolis, Indiana 46240

Minecraft Mods Programming Absolute Beginner¡¯s

Guide

Acquisitions Editor

Mark Taber

Copyright ?2015 by Pearson Education, Inc.

Managing Editor

Sandra Schroeder

All rights reserved. No part of this book shall be reproduced, stored in

a retrieval system, or transmitted by any means, electronic, mechanical,

photocopying, recording, or otherwise, without written permission from

the publisher. No patent liability is assumed with respect to the use of

the information contained herein. Although every precaution has been

taken in the preparation of this book, the publisher and author assume no

responsibility for errors or omissions. Nor is any liability assumed for damages

resulting from the use of the information contained herein.

ISBN-13: 978-0-7897-5360-1

ISBN-10: 0-7897-5360-X

Library of Congress Control Number: 2014953021

Printed in the United States of America

First Printing: November 2014

Trademarks

All terms mentioned in this book that are known to be trademarks or service

marks have been appropriately capitalized. Que Publishing cannot attest to

the accuracy of this information. Use of a term in this book should not be

regarded as affecting the validity of any trademark or service mark.

Warning and Disclaimer

Every effort has been made to make this book as complete and as accurate

as possible, but no warranty or fitness is implied. The information provided

is on an ¡°as is¡± basis. The author and the publisher shall have neither liability

nor responsibility to any person or entity with respect to any loss or damages

arising from the information contained in this book.

Special Sales

For information about buying this title in bulk quantities, or for special sales

opportunities (which may include electronic versions; custom cover designs;

and content particular to your business, training goals, marketing focus,

or branding interests), please contact our corporate sales department at

corpsales@ or (800) 382-3419.

For government sales inquiries, please contact

governmentsales@.

For questions about sales outside the U.S., please contact

international@.

Senior Project Editor

Tonya Simpson

Copy Editor

Megan Wade-Taxter

Indexer

Heather McNeill

Proofreader

Kathy Ruiz

Technical Editor

Boris Minkin

Publishing Coordinator

Vanessa Evans

Cover Designer

Matt Coleman

Compositor

Mary Sudul

Contents at a Glance

Part I

1

2

3

4

5

6

7

8

9

10

Part II

11

12

13

14

15

16

17

Part III

Java from the Ground Up

Dig Into Minecraft Programming with Java ............................................ 1

Use NetBeans for Minecraft Programming ........................................... 15

Create a Minecraft Mod .......................................................................... 25

Start Writing Java Programs ................................................................... 37

Understand How Java Programs Work .................................................. 51

Store and Change Information in a Mod .............................................. 63

Use Strings to Communicate .................................................................. 79

Use Conditional Tests to Make Decisions ............................................. 91

Repeat an Action with Loops................................................................107

Store Information with Arrays ...............................................................119

The World of Java Objects

Create Your First Object .......................................................................131

Describe What Your Object Is Like ......................................................147

Make the Most of Existing Objects ......................................................163

Store Objects in Data Structures ..........................................................177

Handle Errors in a Mod .........................................................................189

Create a Threaded Mod........................................................................205

Read and Write Files..............................................................................223

Create Killer Minecraft Mods

18

Spawn a Mob..........................................................................................241

19

Make One Mob Ride Another ..............................................................257

20

Take a Census of Mobs and Villages ...................................................267

21

Transmute Materials in an Inventory ....................................................281

22

Dig a Giant Hole ...................................................................................293

23

Chop Down a Forest of Trees ..............................................................307

24

Respond to Events in the Game ..........................................................321

25

Display a Mob¡¯s Health During Combat .............................................335

26

Make a World Change Over Time .......................................................349

27

Befriend the God of Lightning .............................................................359

A

Visit This Book¡¯s Website ......................................................................371

Index

..........................................................................................................373

iv

Table of Contents

I Java from the Ground Up

1

Dig Into Minecraft Programming with Java ....................................................... 1

Setting Up a Minecraft Server .................................................................................. 2

Fixing Problems Running the Server .................................................................. 5

Connecting to the Server ......................................................................................... 9

Fixing a Server Connection Problem ............................................................... 10

2

Use NetBeans for Minecraft Programming.......................................................15

Installing NetBeans ................................................................................................. 16

Creating a New Project........................................................................................... 16

Creating a New Java Class ..................................................................................... 18

Running the Application ......................................................................................... 21

Fixing Errors ............................................................................................................. 22

3

Create a Minecraft Mod .......................................................................................25

Creating Your First Mod ......................................................................................... 26

4

Start Writing Java Programs................................................................................37

What You Need to Write Programs ...................................................................... 38

Creating the Splash Program ................................................................................. 38

Beginning the Program........................................................................................... 40

The class Statement ........................................................................................... 42

What the main Statement Does ....................................................................... 42

Those Squiggly Bracket Marks.......................................................................... 43

Storing Information in a Variable ........................................................................... 44

Displaying the Contents of a Variable ............................................................. 44

Saving the Finished Product .................................................................................. 45

Compiling the Program into a Class File .............................................................. 46

Fixing Errors ............................................................................................................. 46

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download