Facebook Twitter Instagram Pinterest YouTube
    Trending
    • Add Kodi to RetroPie Menu
    • Disable Auto-login in Raspberry Pi OS
    • Raspberry Pi Cloud Storage with MEGA
    • RetroPie Temperature Monitor from Menu
    • Pi Pico Pinout and Power Pins
    • Install Arduino IDE on Raspberry Pi
    • Raspberry Pi 400 SSD Upgrade
    • Raspberry Pi Temperature Monitoring
    Facebook Twitter Instagram Pinterest YouTube RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        May 6, 2022

        Add Kodi to RetroPie Menu

        February 26, 2022

        Disable Auto-login in Raspberry Pi OS

        February 2, 2022

        Raspberry Pi Cloud Storage with MEGA

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Software»Minecraft»How To Create A Pyramid In Minecraft With Python
      Minecraft Pyramid Building On The Pi

      How To Create A Pyramid In Minecraft With Python

      0
      By Matt on September 4, 2014 Minecraft, Python, Tutorials & Help

      The great thing about Minecraft on the Raspberry Pi is that you write Python scripts to manipulate the game world. This opens up a lot of creative possibilities. It can also make Python a lot more appealing to budding programmers.

      In this tutorial I want to explain how to create a Pyramid using Minecraft.

      Here is an example of a 10 level pyramid with a block on top :

      Minecraft Pyramids on the Pi

      By creating a Python function to create the Pyramid we can easily create a set of Pyramids of varying sizes at specific locations. My goal was to create the famous Pyramids of Giza without having to use a single slave or a single piece of ancient alien technology.

      Setup

      To use the script below you will need to have Minecraft and the Python API setup. In the latest Raspbian image Minecraft and the API are already setup so you dive straight into the fun bit.

      The Pyramid Builder Function

      Here is the Python function I used to build the pyramid :

      def CreatePyramid(posx,posy,posz,width,mybase,mywalls,mytopblock):
        # Function to create a pyramid at x,y,z
        # with specified width using the specified
        # block materials for the base, walls and top.
      
        mc.postToChat("About to create pyramid!")
      
        # May sure width is odd number so pyramid ends
        # with a single block
        if width%2==0:
          width=width+1
      
        height = (width+1)/2
        halfsize = int(math.floor(width/2))
      
        print "Player : {} {} {}".format(posx,posy,posz)
        print "Size : {} Height : {} Halfsize : {}".format(width,height,halfsize)
      
        # Create base for pyramid
        print "Create solid base"
        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)      
      
        # Create solid Pyramid
        print "Create 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)
      

      The CreatePyramid function takes some arguments. These are :

      • Position (posx, posy, posz)
      • Width (in blocks)
      • Materials (mybase,mywalls,mytopblock)

      The full example script can be downloaded directly to your Pi using :

      wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/minecraft/pyramids.py

      The script :

      • Imports the Minecraft API library
      • Defines the “CreatePyramid” function
      • Calls the function a number of times to create a set of pyramids of varying sizes

      With Minecraft running you can execute the Python script in a terminal window using :

      python pyramids.py

      The scripts doesn’t take long to complete but it may take about 30-60 seconds for Minecraft to update. Here is the result :

      Minecraft Pyramids on the Pi

      Once you’ve got your Pyramid complex built you can consider how to modify it. There is plenty of scope for carving doorways and building secret passages!

      Minecraft Pyramids on the Pi

      I gave up on an accurate re-creation of the Giza complex because with the draw distance on the Pi version of Minecraft you can’t really fit it all in without making the Pyramids quite small.

      Minecraft Pyramids on the Pi

      In my script the pyramids are topped with a block of gold. You can change this or the pyramid base and wall blocks to another type. Take a look at my Minecraft Block ID Reference for ideas.

      Minecraft Pyramids on the Pi
      By changing the parameters passed to the “CreatePyramid” function at the end of the script you can change the size and position of the pyramids. By adding or removing calls to the function you can adjust the number built.

      What Next

      Once you can build a pyramid you could hide an object in a random one and see how long it takes to find. Maybe you could adjust the function to automatically add some tunnels underneath the pyramids and build a secret network?

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleRaspberry Pi Minecraft Block ID Number Reference
      Next Article Cambridge Raspberry Jam – September 2014

      Related Posts

      Add Kodi to RetroPie Menu

      Disable Auto-login in Raspberry Pi OS

      Raspberry Pi Cloud Storage with MEGA

      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      May 6, 2022

      Add Kodi to RetroPie Menu

      February 26, 2022

      Disable Auto-login in Raspberry Pi OS

      February 2, 2022

      Raspberry Pi Cloud Storage with MEGA

      January 7, 2022

      RetroPie Temperature Monitor from Menu

      January 24, 2021

      Pi Pico Pinout and Power Pins

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      3D Printing Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter LCD LED Linux media Minecraft Model A Model B motionEyeOS PCB photography photos Pi-Lite portable power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives
      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Recent Posts
      May 6, 2022

      Add Kodi to RetroPie Menu

      February 26, 2022

      Disable Auto-login in Raspberry Pi OS

      February 2, 2022

      Raspberry Pi Cloud Storage with MEGA

      Facebook Twitter Instagram Pinterest YouTube RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2022 - All Rights Reserved - Matt Hawkins

      Type above and press Enter to search. Press Esc to cancel.