Skip to content

Instantly share code, notes, and snippets.

@thikade
Last active December 10, 2022 16:19
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thikade/3ca6d336e0fd8d3568e94586364cf221 to your computer and use it in GitHub Desktop.
Save thikade/3ca6d336e0fd8d3568e94586364cf221 to your computer and use it in GitHub Desktop.
control minecraft-pi using xbox controller on raspberry pi
[Desktop Entry]
Name=Minecraft Pi MCP
Comment=Fun with Blocks
# TryExec=minecraft-pi
Exec=/home/pi/mcp.sh
Icon=/usr/share/pixmaps/minecraft-pi.png
Terminal=false
Type=Application
Categories=Application;Game;
StartupNotify=true
sudo xboxdrv --detach-kernel-driver --config /home/pi/minecraftpi.xboxdrv /usr/bin/minecraft-pi

How to setup & run minecraft-pi and python scripts

  • minecraft-pi is part of Raspbian by now - no action required.

  • update mcpi:

    • sudo pip install -U mcpi
    • sudo pip install minecraftstuff
    • sudo pip show mcpi minecraftstuff
  • Dont forget to start minecraft-pi!

examples

git clone https://github.com/martinohanlon/minecraft-bridge.git
cd minecraft-bridge
python minecraft-bridge.py

more repos

excellent starting point for minecraft scripts

http://www.stuffaboutcode.com/p/minecraft.html

sudo apt install xboxdrv
sudo xboxdrv --detach-kernel-driver
### xboxdrv config file
#### for playing minecraft using an xbox controller
# left stick controls movement; emulates WSAD
# right stick controls view direction (like mouse)
# left button/ right button cycles through items
# Buttons:
# X - Jump / Fly
# Y - Enter Key to select item in inventory
# A - Left mnouse button = attack
# B - right mouse button = put/use block
# Back-key = inventory
# start-key = Escape / Exit inventory
[xboxdrv]
ui-clear=true
silent=true
trigger-as-button=true
[ui-axismap]
x1=KEY_A:KEY_D
y1=KEY_W:KEY_S
x2^dead:4000 = REL_X:750:-1
y2^dead:4000 = REL_Y:750:-1
[ui-buttonmap]
lt = BTN_LEFT
rt = BTN_RIGHT
[ui-buttonmap]
lb = REL_WHEEL:1:500
rb = REL_WHEEL:-1:500
[ui-buttonmap]
# tl = KEY_E
# tr = KEY_F3
[ui-buttonmap]
back = KEY_E
guide = KEY_O
start = KEY_ESC
[ui-buttonmap]
x = KEY_SPACE
y = KEY_ENTER
a = BTN_LEFT
b = BTN_RIGHT
[ui-buttonmap]
dl = KEY_A
dr = KEY_D
du = KEY_W
dd = KEY_S
# EOF #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment