Learn to Program with Minecraft英文版LEARN TOPROGRAM WITHMINECRAFTTRANSFORM YOUR WORLD WITH THEPOWER OF PYTHONBY CRAIG RICHARDSONno starchpressSan franciscoLEARN TO PROGRAM WITH MINECRAFT. Copyright o 2016 by Craig RichardsonAll rights reserved. No part of this work may be reproduced or transmitted in any form or by any meanselectronic or mechanical, including photocopying, recording, or by any information storage or retrievalsystem, without the prior written permission of the copyright owner and the publisherPrinted on demand in usaISBN-10:1-59327-670-2ISBN-13:978-1-59327-670-6Publisher: William pollockProduction editor: riley hoffmanCover Illustration: Josh EllingsonDevelopmental Editors: Hayley Baker and Tyler OrtmanTechnical Reviewer: John LutzCopyeditor: Anne marie WalkerCompositor: riley hoffmanProofreader: Paula L. FlemingFor information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directlyNo Starch press. Inc245 8th Street. San francisco, cA 94103ohone: 415.863.9900: info@nostarch comwww.nostarch.comLibrary of Congress Cataloging-in-Publication dataNames: Richardson, Craig(Software developer), authorTitle: Learn to program with Minecraft transform your world with the powerof python by Craig richardsonDescription: San Francisco: No Starch Press,[2016]| Includes indexIdentifiers:LCN2015035298|ISBN9781593276706ISBN1593276702Subjects: LCSH: Python(Computer program language) Computergames--Programming .I Minecraft (Game)I Raspberry Pi( Computer)Classification: LCC QA7673 P98 R53 2016 DDC 005.13/3--dc23Lcrecordavailableathttp://iccn.loc.gov/201503529No Starch Press and the no starch Press logo are registered trademarks of No starch press, Inc. Otherproduct and company names mentioned herein may be the trademarks of their respective owners. Ratherthan use a trademark symbol with every occurrence of a trademarked name, we are using the names onlyin an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of thetrademarkMinecraft is a registered trademark of Mojang Synergies AB, which does not authorize or endorse this bookThe information in this book is distributed on an"As Is" basis, without warranty. While every precautionhas been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have anyliability to any person or entity with respect to any loss or damage caused or alleged to be caused directly orindirectly by the information contained in itTo the countless adults and children that read the early draftsof this book, used my recipe cards, and attended my talks andworkshops: thank you so much for your enthusiasm and supportThis book is for youABOUT THE AUTHORCraig richardson is a software developer and python educator. Hehas worked for the raspberry pi foundation taught high schoolcomputing classes, and led many workshops on Python programmingwith minecraftABOUT THE TECHNICAL REVIEWERJohn lutz is a math teacher in the new orleans public school systemwhere he also teaches extracurricular courses on scratch. arduinorobotics, and 3d printing. He piloted his schools computer scienceprogram, which continues to grow and attract bright new minds tocoding. Since helping with this book, John is working on a Pythonprogram that will destroy all baby zombies in his minecraft world,foreverBRIEF CONTENTSAcknowledgmentsIntroductionXIXChapter 1: Setting Up for Your AdventureChapter 2 Teleporting with variables27Chapter 3: Building Quickly and Traveling Far with Math47Chapter 4: Chatting with Strings65Chapter 5 Figuring Out What's True and False with booleans81Chapter 6: Making Mini-Games with if Statements.103Chapter 7: Dance Parties and Flower Parades with while Loops….123Chapter 8: Functions Give You Superpowers145Chapter 9: Hitting Things with Lists and Dictionaries167Chapter 10: Minecraft Magic with for Loops195Chapter 11: Saving and Loading Buildings with Files and Modules231Chapter 12: Getting Classy with Object-Oriented Programming..257Afterword283Block id cheat sheet285Index....291CONTENTS IN DETAILACKNOWLEDGMENTSINTRODUCTIONXIXWhy Learn to ProgramXXWhy Python?XXWhyny minecraftWhat's in This BookeXXXXOnline resourcesXXIet the adventure begin!SETTING UP FOR YOUR ADVENTURESetting Up your Windows PCInstalling MinecraftInstalling PythonInstalling javaInstalling the minecraft python apl and spigotSpigot and Creating a GameStarting Over with a New World2346789Playing OfflineSwitching to Survival Mode10Setting Up your macInstalling minecraftInstalling pythonInstalling javaInstalling the minecraft Python APl and SpigotRunning Spigot and Creating a GameStarting Over with a New World7Playing offline18Switching to survival mode18etting Up Your Raspberry PiGetting to Know IDLE20Getting to Know the Python Shell20Say hello to idle's text Editor2When to Use the python Shell and When to Use the Text Editor23The Prompts Used in This book23Testing Your Minecraft Python Setup24