HACKING MINECRAFT.

Slides:



Advertisements
Similar presentations
This Week More Types boolean string Modules print statement Writing programs if statement Type boolean.
Advertisements

MINECRAFT MOD PROGRAMMING Part III of Minecraft: Pi Edition October 31, 2015.
Computer Science 111 Fundamentals of Programming I More Digital Image Processing.
A Christmas Scratch game
© red ©
HACKING MINECRAFT. LET’S OVERCLOCK sudo raspi-config Change 7: Over clock 900Mhz at max Change 8: Select memory share = 128MB.
Programing App Inventor. Variable Declaration App Inventor: Declare Variables using the “Define Variable As” Block – Find the Blocks Editor (top-left),
CMPT 120 Lists and Strings Summer 2012 Instructor: Hassan Khosravi.
Fundamentals of Python: From First Programs Through Data Structures
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
Fundamentals of Python: First Programs
Introduction to TouchDevelop
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 3: Treasures and Hazards.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Checking for Collisions: Alternative Method Erin Taylor Under the Direction of Susan Rodger July 2015 Duke University.
Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.
[1] Intro The following instructions will show you how to create an Excel worksheet that allows students to take multiple choice tests (practice or real)
If statements while loop for loop
Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and.
Hey, Ferb, I know what we’re gonna do today! Aims: Use formatted printing. Use the “while” loop. Understand functions. Objectives: All: Understand and.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
GAME:IT Pinball Objectives: Review skills from Introduction Introduce gravity and friction Introduce GML coding into programming.
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
COUNTING Directions: Write your word on the I pad and on the paper. Count the amount of letters in your word and then find the color that matches that.
USING GOOGLE EARTH GRAPHS FOR DATA PRESENTATION Add placemarks to the sites that you have collected data for. Make sure they are appropriately titled.
Simple Collision Detection By David Yan Under the direction of Professor Susan Rodger and Chari Distler Duke University, June 2015.
Last Week Modules Save functions to a file, e.g., filename.py The file filename.py is a module We can use the functions in filename.py by importing it.
Hacking Minecraft on the Raspberry Pi using Python
Variables and Random Numbers Computer App Session 4.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Updating to X6 Mike DeButts. Updating to X6 How to Install X6 What Not to do when Updating to X6 Migration Utility New File Locations introduced in X6.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Introduction to Minecraft Pi Aims: To know what Minecraft is To learn how to enter code into Minecraft Pi To successfully enter at least 2 Python programs.
HACKING MINECRAFT 1. LET’S OVERCLOCK Type sudo raspi-config Change 7: Over clock 900Mhz at max Change 8: Select memory share = 128MB.
Hacking Minecraft on the Raspberry Pi using Python Lesson 2 1.
Lecture 6: Basic Entities TEALS MINECRAFT PROJECT.
Login using your own username and password Go to programming -> geany Enter the following program: Open LX Terminal, enter these 2 commands from mcpi.minecraft.
Introduction to Programming
Introduction to Programming
Introduction to Python
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
Introduction to Programming
Butterfly Maths Each caterpillar must be coloured the correct pattern for it to turn into a butterfly. Work out each problem to know how to colour each.
Hacking Minecraft on the Raspberry Pi using Python
Hacking Minecraft on the Raspberry Pi using Python
Hacking Minecraft on the Raspberry Pi using Python
Basic Graphics Drawing Shapes 1.
EECS 110: Lec 10: Definite Loops and User Input
Go to =>
Hacking Minecraft on the Raspberry Pi using Python
Checking for Collisions: Using Functions in Alice
Introduction to Programming
Directions: Color your name with any tiles you want.
Example shows when a DataSourceSelectionID is needed
Python programming exercise
Game Over Module 4 Lesson 2.
When a DataSourceSelectionID is needed?
LEARNING STRATEGIES: TRUE COLOURS The True Colours Test.
Introduction to Programming
Starter Activities GCSE Python.
LEARNING STRATEGIES: TRUE COLOURS The True Colours Test.
The Step Parameter & Nested For … To … Next loops
Project Name name.
GCSE Computing Mini Assignment.
Lecture 23 – Practice Exercises 5
Presentation transcript:

HACKING MINECRAFT

LET’S OVERCLOCK sudo raspi-config Change 7: Over clock 900Mhz at max Change 8: Select memory share = 128MB

HACKING MINECRAFT In the LX Terminal: sudo idle Open a ‘new’ window Type the code and click save Save into the PI/Home folder Pess F5 to save and run the code

Minecraft Trampoline from mcpi import minecraft  from mcpi import minecraft mc = minecraft.Minecraft.create() while True: p = mc.player.getTilePos() b = mc.getBlock(p.x,p.y-1,p.z) if b == 2: ###grass mc.player.setPos(p.x, p.y+20, p.z) ###+20 means 20 blocks up Bounces when on grass

How High is the world? from mcpi import minecraft mc = minecraft.Minecraft.create() y = mc.getHeight(0,0) mc.postToChat("Height of the world is") mc.postToChat(y) Finds the height of your world

Hide a Diamond, Find a Diamond from mcpi import minecraft mc = minecraft.Minecraft.create() from time import sleep mc.postToChat("Here is the diamond block I have hidden.") mc.setBlock(100, 25, 100, 57) mc.camera.setFixed() mc.camera.setPos(100, 30, 100) sleep(10) mc.postToChat("Go find it!") mc.camera.setNormal() Hides a diamond in the game, shows you then you have to find it

mc.camera.setFollow() Stalker! Replace the last line with the line below and the camera follows you around the world mc.camera.setFollow() Stalk the player

Force Field def forcefield(): pos = mc.player.getPos() import mcpi.minecraft as minecraft import time from mcpi import block mc=minecraft.Minecraft.create() def forcefield(): pos = mc.player.getPos() mc.setBlocks(pos.x-3, pos.y, pos.z-3, pos.x+3, pos.y+3, pos.z+3, block.AIR) while True: pos = mc.player.getTilePos() air = mc.getBlock(pos.x+1, pos.y+1, pos.z+1) if air != block.AIR.id: mc.postToChat ("Forcefield Active") forcefield() Walk into a wall or hill and the force field protects you and removes the blocks

MIDAS TOUCH while True: pos = mc.player.getTilePos() from mcpi import minecraft mc = minecraft.Minecraft.create() Import time gold = 41 water = 9 air = 0 while True: pos = mc.player.getTilePos() blockBelow = mc.getBlock(pos.x, pos.y - 1, pos.z) if blockBelow != air and blockBelow != water: mc.setBlock(pos.x, pos.y -1, pos.z, gold) time.sleep(0.1) Turn everything to Gold!

Rainbow Road mc = minecraft.Minecraft.create() import mcpi.minecraft as minecraft import mcpi.block as block import random import time mc = minecraft.Minecraft.create() pos = mc.player.getPos() def SetRoad(): mc.setBlock(pos.x, pos.y-1, pos.z, 35,1)#orange mc.setBlock(pos.x-1, pos.y-1, pos.z, 35,2)#pinky mc.setBlock(pos.x-2, pos.y-1, pos.z, 35,3)#sky blue mc.setBlock(pos.x-3, pos.y-1, pos.z, 35,4)#yellow mc.setBlock(pos.x-4, pos.y-1, pos.z, 35,5)#green mc.setBlock(pos.x-5, pos.y-1, pos.z, 35,6)#pink mc.setBlock(pos.x-8, pos.y-1, pos.z, 35,9)#blue mc.setBlock(pos.x-9, pos.y-1, pos.z, 35,10)#purple while True: SetRoad() time.sleep(0.05) Walk around and create a rainbow road

Rainbow Disco import mcpi.minecraft as minecraft import mcpi.block as block import random import time mc = minecraft.Minecraft.create() pos = mc.player.getPos() def SetRoad(): colour = random.randint(1,11) mc.setBlock(pos.x, pos.y-1, pos.z, 35,colour)#random while True: SetRoad() time.sleep(0.05) Now it is a Disco

Minecraft: Drop some Sand 1 from mcpi import minecraft mc = minecraft.Minecraft.create() pos = mc.player.getTilePos() mc.setBlock(pos.x, pos.y + 25, pos.z, 13) Add a while True statement Drop sand blocks from the sky

Minecraft: Drop some Sand 2 from mcpi import minecraft mc = minecraft.Minecraft.create() from time import sleep pos = mc.player.getTilePos() while mc.getBlock(pos.x, pos.y, pos.z) != 13: mc.setBlock(pos.x, pos.y + 25, pos.z, 13) sleep(1) mc.postToChat("Got you!") Make it into a game, dodge the sand, don’t get caught!

Torches from mcpi import minecraft from mcpi import block mc = minecraft.Minecraft.create() pos = mc.player.getTilePos() mc.setBlock(pos.x, pos.y + 2, pos.z, block.STONE) # create torches # on top mc.setBlock(pos.x, pos.y + 3, pos.z, block.TORCH) # to the east mc.setBlock(pos.x + 1, pos.y + 2, pos.z, block.TORCH) # to the west mc.setBlock(pos.x - 1, pos.y + 2, pos.z, block.TORCH) # to the north mc.setBlock(pos.x, pos.y + 2, pos.z - 1, block.TORCH) # to the south mc.setBlock(pos.x, pos.y + 2, pos.z + 1, block.TORCH) Create a block of torches!

Cover my World from mcpi import minecraft mc = minecraft.Minecraft.create() while True: pos = mc.player.getTilePos() for x in range(pos.x, pos.x + 10): for z in range(pos.z, pos.z + 10): y = mc.getHeight(x,z) mc.setBlock(x, y, z, 78) Flood the world around you

Build A Glass Bridge What happens if you change the GLASS to AIR? from mcpi import minecraft mc = minecraft.Minecraft.create() from mcpi import block import time while True: myX, myY, myZ = mc.player.getTilePos() #find out where we are mc.setBlocks(myX - 1, myY - 1, myZ - 1, myX + 1,myY -1, myZ +1,block.GLASS) time.sleep(0.1) # Add a 0.1 second delay What happens if you change the GLASS to AIR? Remove the last myY -1 Create a glass bridge wherever you walk.

Are we there yet? from mcpi import minecraft from math import sqrt from time import sleep mc = minecraft.Minecraft.create() startPos = mc.player.getTilePos() while True: posNow = mc.player.getTilePos() xDiff = startPos.x - posNow.x yDiff = startPos.y - posNow.y zDiff = startPos.z - posNow.z xSquare = xDiff * xDiff ySquare = yDiff * yDiff zSquare = zDiff * zDiff total = xSquare + ySquare + zSquare distance = sqrt(total) mc.postToChat(distance) sleep(1) Measure the distance that you have moved from your starting point, use it to find your way home.

Finding some Treasure import time from mcpi import minecraft mc = minecraft.Minecraft.create() import time treasureList = [14,15,16,41,42,49,73,89,56,57] #The block ID for Gold Ore, Diamond Ore, etc... while True: # A loop to keep checking playerx, playery, playerz = mc.player.getTilePos() # Find out where you are for i in range (0,50): # build a loop to check the 50 blocks below you blocktype = mc.getBlock(playerx, playery -i, playerz) #find the block if blocktype in treasureList: # check if the block ID is in the treasureList mc.postToChat("We've found treasure!") time.sleep(0.01) #Only check every 100th of a second - otherwise our pi will freeze... Treasure detector, activities if you are above treasure

Minecraft Escalator import mcpi.minecraft as minecraft import mcpi.block as block import time LineColour = 46 mc = minecraft.Minecraft.create() def Main(): x,y,z = mc.player.getPos() CurrentBlock = mc.getBlock(x,y-1,z) if CurrentBlock == 46 & mc.getBlock(x,y-1,z-1)== 46: mc.player.setPos(x,y,z-1) elif CurrentBlock == 46 & mc.getBlock(x+1,y-1,z)== 46: mc.player.setPos(x+1,y,z) elif CurrentBlock == 2 & mc.getBlock(x,y-1,z+1)== 2: mc.player.setPos(x,y,z+1) elif CurrentBlock == 2 & mc.getBlock(x-1,y-1,z)== 2: mc.player.setPos(x-1,y,z) while True: Main() Lay down some TNT at right angles and it will follow it Place blocks of TNT, go back to the first block, run the code, you travel along like an escalator!

Minecraft Instant Messenger Part 1 import time import random import mcpi.minecraft as minecraft import mcpi.block as block mc = minecraft.Minecraft.create() global TempList def letterI(): ###This creates the letter I row1 = (35, 35, 46, 46, 46, 35, 35) row2 = (35, 35, 35, 46, 35, 35, 35) row3 = (35, 35, 35, 46, 35, 35, 35) row4 = (35, 35, 35, 46, 35, 35, 35) row5 = (35, 35, 46, 46, 46, 35, 35) Templist = [row1,row2,row3,row4,row5] return Templist Build a messaging service in MC.

Minecraft Instant Messenger Part 2 def PrintWall(ImportedList): pos = mc.player.getTilePos() mc.player.setPos(pos.x,pos.y,pos.z) mylist = ImportedList for row in range (0,5): for column in range (0,6): mc.setBlock(pos.x+column, pos.y+row, pos.z-20, mylist[row][column]) while True: PrintWall(letterI()) time.sleep(0.3) Now create other letters and add them underneath the Letter I, use this to build up words. Create a variable to allow he user to type in a word and the Minecraft prints it Part two of the IM

Can you create a Pyramid?

Pyramid

1. Pyramid Prep import sys import math sys.path.append("./mcpi/api/python/mcpi") ( if using old version of Raspberry Pi) import minecraft as minecraft (use if using new version of Raspberry Pi) import minecraft mc = minecraft.Minecraft.create() # Import specific Minecraft libraries import minecraft as minecraft import block as block # Block definitions AIR = 0 DIRT = 3 SAND = 12 SANDSTONE = 24 GOLD = 41

2. Pyramid Math def CreatePyramid(posx,posy,posz,width,mybase,mywalls,mytopblock): # Function to create a pyramid at x,y,z with specified width using block materials for the base, walls and top. mc.postToChat("About to create pyramid!") if width%2==0: # May sure width is odd number so pyramid ends, with a single block width=width+1 height = (width+1)/2 halfsize = int(math.floor(width/2)) # Create base for pyramid mc.setBlocks(posx-halfsize-2,posy-2,posz-halfsize-2,posx+halfsize+2,posy- 2,posz+halfsize+2,DIRT) mc.setBlocks(posx-halfsize-2,posy-1,posz-halfsize-2,posx+halfsize+2,posy- 1,posz+halfsize+2,mybase)

3. Pyramid Math # Create solid Pyramid for y in range(posy,posy+height): mc.setBlocks(posx-halfsize,y,posz-halfsize,posx+halfsize,y,posz+halfsize,mywalls) halfsize = halfsize-1 # Change top block print "Set top block" mc.setBlock(posx,posy+height-1,posz,mytopblock) print "Position player on top" mc.player.setPos(posx,posy+height,posz)

Create that Pyramid def CreatePyramid(posx,posy,posz,width,mybase,mywalls,mytopblock): # Function to create a pyramid at x,y,z with specified width using block materials for the base, walls and top CreatePyramid(0,1,0,51,SANDSTONE,SANDSTONE,GOLD)

Volcano import minecraft as minecraft, block,time,random mc = minecraft.Minecraft.create() layers = 10 # How high our volcano is going to be vec = (0,0,0) # the starting point for our volcano mc.setBlocks(0,0,0,100,100,100,block.AIR) # let's make some space for our volcano for layer in range(0,layers): # Build the volcano mc.setBlocks(layer + vec[0],layer + vec[1],layer + vec[2],vec[0] + (2*layers)-layer,vec[1] + layer,vec[2] + (2*layers)-layer,block.STONE) time.sleep(1) count = 0 while count < (layers*layers*3): # Add some random blocks on the top to make it look a bit more real x = random.randint(vec[0],vec[0]+(2*layers)+1) z = random.randint(vec[2],vec[2]+(2*layers)+1) mc.setBlock(x,layers+10,z,block.GRAVEL) time.sleep(0.01) count+=1 while True: # Get the lava flowing! mc.setBlocks(vec[0]+int(layers)-1,vec[1]+layers,layers-1,vec[0]+int(layers),vec[1]+layers,layers+1,block.LAVA_FLOWING) # This is not a new line!