Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
torralbaa committed Aug 22, 2020
1 parent c02d094 commit 3470fb7
Show file tree
Hide file tree
Showing 85 changed files with 343 additions and 186 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Python stuff
# Old stuff
.old/

__pycache__/
build/
# Builds
*.pyc
Binary file removed .install_files/application-x-mcpimod.png
Binary file not shown.
Binary file removed .install_files/icon.png
Binary file not shown.
Binary file removed .install_files/minecraft-pe.bsdiff
Binary file not shown.
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,42 @@ A simple launcher for Minecraft: Pi Edition.

## Getting started
### Prerequisites
To use MCPIL you need to have `Python >= 3.7.x` pre-installed and root privileges.
To use MCPIL you need to have Python 3.7 pre-installed.

### Installation
To install MCPIL, download or clone the repository:
To install MCPIL, download or clone the repository and run the `build.py` file in the root of the repo:
```shell
git clone https://github.com/Alvarito050506/MCPIL.git
git clone https://github.com/MCPI-Devs/MCPIL.git
cd ./MCPIL/
python3.7 ./build.py
```
and then run the `install.py` file. It will create a desktop file that you can access in the "Games" category.
It will generate a `install.pyc` file under the `build` directory, run it:
```shell
cd ./build/
python3.7 ./install.pyc
```
It will "install" MCPI and MCPE, and configure the Launcher.

## Features
+ Switch between Minecraft Pi and PE
+ Username change
+ Skin change
+ Mod load
+ Username changing
+ Skin changing
+ Mod loading
+ Mod API
+ Mod compilation
+ World game mode and name change
+ World setting (game mode and name) changing
+ Join non-local servers
+ Coming soon: Pi Realms
+ Coming soon: More stuff

## Usage
Launch the MCPIL desktop file or run the `mcpil.py` file to see the magick! :wink:
Launch the MCPIL desktop file or run the `mcpil.pyc` file in the `build` folder as following to see the magic! :wink:
```shell
python3.7 ./mcpil.pyc
```

## API
**Warning**: The API will be refactored in the next release.

There is an MCPIL API that you can use by importing the `mcpil` module into your Python mod. It exposes the following functions:

### `def get_user_name()`
Expand All @@ -47,9 +59,9 @@ Returns the game mode of the current world as an interger:
## Mod compilation
To compile (compress) a Python mod, run the `mcpim.py` file passing the filename of the mod as the first argument. For example:
```shell
./mcpim.py example.py
python3.7 ./mcpim.pyc example.py
```
will produce a `example.mcpi` mod file.
This will produce an `example.mcpi` mod file.

## Thanks
To [@Phirel](https://www.minecraftforum.net/members/Phirel) for his Pi2PE (a.k.a. "survival") patch.
Expand Down
36 changes: 11 additions & 25 deletions mcpip.py → build.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
#
# mcpip.py
# build.py
#
# Copyright 2020 Alvarito050506 <donfrutosgomez@gmail.com>
#
Expand All @@ -21,32 +21,18 @@
#
#


import sys
import socket
import py_compile
import glob
from os import chdir

def main(args):
ss = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP);
sc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP);
server = (args[1], int(args[2]));
client = ("0.0.0.0", 19134);
sc.setblocking(0);
ss.setblocking(0);
sc.bind(client);
client_addr = None;

while True:
try:
data, addr = ss.recvfrom(16384);
sc.sendto(data, client_addr);
except BlockingIOError:
pass;
try:
data, addr = sc.recvfrom(16384);
client_addr = addr;
ss.sendto(data, server);
except BlockingIOError:
pass;
src = glob.glob("./src/*.py");
i = 0;
while i < len(src):
py_compile.compile(src[i], cfile="./build/" + src[i].replace("./src", "").replace(".py", ".pyc"), optimize=2);
i += 1;

return 0;

if __name__ == '__main__':
Expand Down
6 changes: 6 additions & 0 deletions build/minecraft/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*** The real license isn't finished yet, here's what goes in plain english ***

You may execute the minecraft-pi binary on a Raspberry Pi or an emulator
You may use any of the source code included in the distribution for any purpose (except evil)

You may not redistribute any modified binary parts of the distribution
Binary file added build/minecraft/data/images/armor/chain_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/chain_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/cloth_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/cloth_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/diamond_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/diamond_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/gold_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/gold_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/iron_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/armor/iron_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/art/kz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/font/default8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/bg32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/default_world.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/gui2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/gui_blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/itemframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/minecraft/data/images/gui/items.png
Binary file added build/minecraft/data/images/gui/pi_title.png
Binary file added build/minecraft/data/images/gui/spritesheet.png
Binary file added build/minecraft/data/images/gui/title.png
Binary file added build/minecraft/data/images/gui/touchgui.png
Binary file added build/minecraft/data/images/item/arrows.png
Binary file added build/minecraft/data/images/item/camera.png
Binary file added build/minecraft/data/images/item/sign.png
Binary file added build/minecraft/data/images/mob/char.png
Binary file added build/minecraft/data/images/mob/chicken.png
Binary file added build/minecraft/data/images/mob/cow.png
Binary file added build/minecraft/data/images/mob/creeper.png
Binary file added build/minecraft/data/images/mob/pig.png
Binary file added build/minecraft/data/images/mob/pigzombie.png
Binary file added build/minecraft/data/images/mob/sheep.png
Binary file added build/minecraft/data/images/mob/sheep_fur.png
Binary file added build/minecraft/data/images/mob/skeleton.png
Binary file added build/minecraft/data/images/mob/spider.png
Binary file added build/minecraft/data/images/mob/zombie.png
Binary file added build/minecraft/data/images/particles.png
Binary file added build/minecraft/data/images/terrain.png
Binary file added build/minecraft/lib/brcm/libEGL.so
Binary file not shown.
Binary file added build/minecraft/lib/brcm/libGLESv2.so
Binary file not shown.
1 change: 1 addition & 0 deletions build/minecraft/lib/mesa/libEGL.so
1 change: 1 addition & 0 deletions build/minecraft/lib/mesa/libGLESv2.so
Binary file added build/minecraft/lib/mesa/libbcm_host.so.1.0
Binary file not shown.
Binary file added build/minecraft/minecraft-pe
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

cd /opt/minecraft-pi || exit
cd $HOME/.mcpil/minecraft || exit

if grep -q okay /proc/device-tree/soc/v3d@7ec00000/status \
/proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null; then
export LD_PRELOAD=libbcm_host.so.1.0
export LD_LIBRARY_PATH=lib/mesa
export LD_LIBRARY_PATH=./lib/mesa
else
export LD_LIBRARY_PATH=lib/brcm
export LD_LIBRARY_PATH=./lib/brcm
fi

./minecraft-pe
Binary file added build/minecraft/minecraft-pi
Binary file not shown.
13 changes: 13 additions & 0 deletions build/minecraft/minecraft-pi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

cd $HOME/.mcpil/minecraft || exit

if grep -q okay /proc/device-tree/soc/v3d@7ec00000/status \
/proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null; then
export LD_PRELOAD=libbcm_host.so.1.0
export LD_LIBRARY_PATH=./lib/mesa
else
export LD_LIBRARY_PATH=./lib/brcm
fi

./minecraft-pi
Empty file added build/minecraft/options.txt
Empty file.
Binary file added build/res/application-x-mcpimod_128px.png
Binary file added build/res/application-x-mcpimod_16px.png
Binary file added build/res/application-x-mcpimod_32px.png
Binary file added build/res/application-x-mcpimod_48px.png
Binary file added build/res/application-x-mcpimod_64px.png
Binary file added build/res/mcpil_128px.png
Binary file added build/res/mcpil_16px.png
Binary file added build/res/mcpil_32px.png
Binary file added build/res/mcpil_48px.png
Binary file added build/res/mcpil_64px.png
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=MCPIL
Comment=Minecraft Pi Launcher
Exec=$(EXECUTABLE_PATH) %f
Exec=$(EXECUTABLE_PATH)
Icon=mcpil
Terminal=false
Type=Application
Expand Down
Binary file added example.mcpi
Binary file not shown.
24 changes: 23 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#!/usr/bin/env python3
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
#
# example.py
#
# Copyright 2020 Alvarito050506 <donfrutosgomez@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#


import sys
import time
Expand Down
77 changes: 0 additions & 77 deletions install.py

This file was deleted.

Binary file removed mods/example.mcpi
Binary file not shown.
2 changes: 1 addition & 1 deletion api/mcpil/__init__.py → src/api/mcpil/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
#
# __init__.py
Expand Down
17 changes: 11 additions & 6 deletions api/setup.py → src/api/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
#
# setup.py
Expand All @@ -21,17 +21,22 @@
#
#

from distutils.core import setup
from os import chdir, path

chdir(path.dirname(__file__));
from setuptools import setup, find_packages

setup(
name="mcpil",
version="v0.1.1",
description="MCPI API extensions",
description="MCPI API extensions.",
author="Alvarito050506",
author_email="donfrutosgomez@gmail.com",
url="https://github.com/Alvarito050506/MCPIL",
project_urls={
"Bug Tracker": "https://github.com/Alvarito050506/MCPIL/issues",
"Documentation": "https://github.com/Alvarito050506/MCPIL#readme",
"Source Code": "https://github.com/Alvarito050506/MCPIL",
},
packages=["mcpil"],
install_requires=["psutil>=5.7.0"],
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
Expand Down
59 changes: 59 additions & 0 deletions src/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
#
# install.py
#
# Copyright 2020 Alvarito050506 <donfrutosgomez@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#

import subprocess
import sys
from os import uname, getenv, path, makedirs, mkdir, getcwd, chdir
import shutil

def main():
if "arm" not in uname()[4] and "aarch" not in uname()[4]:
sys.stdout.write("Error: Minecraft Pi Launcher must run on a Raspberry Pi.\n");
return 1;

sizes = ["16", "32", "48", "64", "128"];
chdir(path.dirname(path.realpath(__file__)));

if not path.exists(getenv("HOME") + "/.mcpil"):
subprocess.call(["pip3.7", "install", "--user", "-qq", "psutil"]);
subprocess.call(["python3.7", "../src/api/setup.py", "-q", "install"]);
if not path.exists(getenv("HOME") + "/.local/share/applications"):
makedirs(getenv("HOME") + "/.local/share/applications");
i = 0;
while i < len(sizes):
subprocess.call(["xdg-icon-resource", "install", "--novendor", "--size", sizes[i], "./res/application-x-mcpimod_" + sizes[i] + "px.png", "application-x-mcpimod"]);
subprocess.call(["xdg-icon-resource", "install", "--novendor", "--size", sizes[i], "./res/mcpil_" + sizes[i] + "px.png", "mcpil"]);
i += 1;
subprocess.call(["xdg-mime", "install", "--novendor", "./res/mcpimod.xml"]);
mkdir(getenv("HOME") + "/.mcpil");
shutil.copytree("./minecraft", getenv("HOME") + "/.mcpil/minecraft");
mkdir(getenv("HOME") + "/.mcpil/mods");
desktop_template = open("./res/tk.mcpi.mcpil.desktop", "r");
desktop_file = open(getenv("HOME") + "/.local/share/applications/tk.mcpi.mcpil.desktop", "w");
desktop_file.write(desktop_template.read().replace("$(EXECUTABLE_PATH)", "python3.7 " + getcwd() + "/mcpil.pyc"));
desktop_template.close();
desktop_file.close();
return 0;

if __name__ == '__main__':
sys.exit(main());
Loading

0 comments on commit 3470fb7

Please sign in to comment.