Woll
Posts: 472
Joined: Mon Jul 06, 2015 2:14 am
Location: Cloud Cuckoo Land

Minecraft_Map Sense Hat

Mon Oct 19, 2015 11:52 pm

I'm playing around with the Sense Hat and following the Minecraft Map trutorial on the Raspberry Pi Resources section. However, I can't get the program to work as I keep getting the following error messages.

>>>
Traceback (most recent call last):
File "/home/pi/minecraft-map/Minecraft-map Download.py", line 6, in <module>
mc = Minecraft.create()
File "/usr/lib/python3/dist-packages/mcpi/minecraft.py", line 171, in create
return Minecraft(Connection(address, port))
File "/usr/lib/python3/dist-packages/mcpi/connection.py", line 17, in __init__
self.socket.connect((address, port))
ConnectionRefusedError: [Errno 111] Connection refused
>>>

I started out typing the code as I want to learn coding and I got the error message. So I copied and pasted it from the Resources page, just to make sure I wasn't tpying anything wrong and I still get the same message.

I'm using the Pi 2B and the Raspbian Jessie OS if that's any help.

The full coded from the Resources page is written below.

Code: Select all

from sense_hat import SenseHat
from mcpi.minecraft import Minecraft
from time import sleep

sense = SenseHat()
mc = Minecraft.create()

known_blocks = {}

def get_blocks():
    global known_blocks

    x, y, z = mc.player.getTilePos()
    y -= 1

    blocks = []
    for dz in range(z-3, z+5):
        for dx in range(x-3, x+5):
            b = (dx, y, dz)
            if b in known_blocks:
                block = known_blocks[b]
            else:
                block = mc.getBlock(dx, y, dz)
                known_blocks[b] = block
            blocks.append(block)

    return blocks

def lookup_colour(block):
    if block in colours:
        return colours[block]
    else:
        return white

def map_blocks_to_colours(blocks):
    return [lookup_colour(block) for block in blocks]

# blocks
air = 0
grass = 2
water = 9
sand = 12

# colours
white = (150, 150, 150)
green = (0, 150, 0)
blue = (0, 0, 150)
yellow = (150, 150, 0)
black = (0, 0, 0)

# block: colour
colours = {
    air: white,
    grass: green,
    water: blue,
    sand: yellow,
}

player_pos = 27

while True:
    blocks = get_blocks()
    pixels = map_blocks_to_colours(blocks)
    pixels[player_pos] = black  # denote player as black pixel
    sense.set_pixels(pixels)
Who ate all the Pi's? Who ate all the Pi's?
Boris Johnson, Boris Johnson,
Who ate all the Pi's?

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Minecraft_Map Sense Hat

Tue Oct 20, 2015 7:09 am

Do you have

Code: Select all

auto lo
iface lo inet loopback
in your /etc/network/interfaces file
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Woll
Posts: 472
Joined: Mon Jul 06, 2015 2:14 am
Location: Cloud Cuckoo Land

Re: Minecraft_Map Sense Hat

Tue Oct 20, 2015 5:22 pm

DougieLawson wrote:Do you have

Code: Select all

auto lo
iface lo inet loopback
in your /etc/network/interfaces file
Thanks for the reply. I'm not sure. I'm using Raspbian Jessie so I thought everything was up to date. How would I add the above, using Terminal? I'm doing the command line course on
https://www.codecademy.com/courses/lear ... mmand-line
so hopefully I'll be able to add it. Which directory would I access /etc/network/interfaces from?
Who ate all the Pi's? Who ate all the Pi's?
Boris Johnson, Boris Johnson,
Who ate all the Pi's?

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Minecraft_Map Sense Hat

Tue Oct 20, 2015 7:31 pm

OK so what ports are in use? Is there something listening on port 4711 (that isn't Minecraft)?

sudo netstat -tlnp
should show you.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Woll
Posts: 472
Joined: Mon Jul 06, 2015 2:14 am
Location: Cloud Cuckoo Land

Re: Minecraft_Map Sense Hat

Tue Oct 20, 2015 7:58 pm

Thanks for the reply. This is what shows after doing sudo netstat -tlnp
I don't know what they are thou.

Code: Select all

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      551/sshd        
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      668/cupsd       
tcp6       0      0 :::22                   :::*                    LISTEN      551/sshd        
tcp6       0      0 ::1:631                 :::*                    LISTEN      668/cupsd   
Who ate all the Pi's? Who ate all the Pi's?
Boris Johnson, Boris Johnson,
Who ate all the Pi's?

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Minecraft_Map Sense Hat

Tue Oct 20, 2015 9:00 pm

Those are all normal, so your error is something else.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Woll
Posts: 472
Joined: Mon Jul 06, 2015 2:14 am
Location: Cloud Cuckoo Land

Re: Minecraft_Map Sense Hat

Tue Oct 20, 2015 9:17 pm

I saw this in another thread

Code: Select all

sudo apt-get install libjpeg-dev
sudo pip-3.2 install pillow
But when I do the pillow, I get this.

Code: Select all

$ sudo pip-3.2 install pillow
Requirement already satisfied (use --upgrade to upgrade): pillow in /usr/lib/python3/dist-packages
Cleaning up...
I've done a sudo apt-get upgrade today and I'm running Jessie. I would have thought everything would be working fine?
Who ate all the Pi's? Who ate all the Pi's?
Boris Johnson, Boris Johnson,
Who ate all the Pi's?

Return to “Astro Pi”