Add mcpit
This commit is contained in:
parent
81f1cbea89
commit
92900001e0
|
@ -1,123 +0,0 @@
|
|||
# MCPIL texturepack code
|
||||
# Coded by NikZapp for the MCPIL project by Alvarito050506
|
||||
# This program is sadly not protected in any way.
|
||||
import os
|
||||
import shutil
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def loadTextures(filename):
|
||||
print("Loading the following textures into the game files:")
|
||||
global foundInTexturepack
|
||||
zipObj = zipfile.ZipFile(filename, "r")
|
||||
zipObj.extractall()
|
||||
for i in foundInTexturepack:
|
||||
# i = i[:-2]
|
||||
print(i[:-2])
|
||||
tempFiles = zipObj.namelist()
|
||||
for t in tempFiles:
|
||||
if t == i[-int(i[-2:]) - 2 : -2]:
|
||||
if True:
|
||||
Path(t).rename(i[:-2])
|
||||
print("from", t)
|
||||
print("to ", i[:-2])
|
||||
|
||||
# print('Permission error. Run this in a terminal using sudo.')
|
||||
zipObj.close()
|
||||
for t in tempFiles:
|
||||
try:
|
||||
Path(t).unlink()
|
||||
except:
|
||||
pass # print('Permission error. Run this in a terminal using sudo.')
|
||||
|
||||
|
||||
print(
|
||||
"""
|
||||
Input texturepack file path (.zip)
|
||||
Leave blank to recover textures:"""
|
||||
)
|
||||
filePath = input()
|
||||
if filePath == "":
|
||||
filePath = "recoveryPack.zip"
|
||||
archive = zipfile.ZipFile("recoveryPack.zip", "r")
|
||||
print("Recovering textures to an old state")
|
||||
else:
|
||||
try:
|
||||
archive = zipfile.ZipFile(filePath, "r")
|
||||
except:
|
||||
print("Error while accessing texturepack file")
|
||||
|
||||
texturePaths = [
|
||||
"~/.minecraft-pi/overrides/images/armor/chain_1.png11",
|
||||
"~/.minecraft-pi/overrides/images/armor/chain_2.png11",
|
||||
"~/.minecraft-pi/overrides/images/armor/cloth_1.png11",
|
||||
"~/.minecraft-pi/overrides/images/armor/cloth_2.png11",
|
||||
"~/.minecraft-pi/overrides/images/armor/diamond_1.png13",
|
||||
"~/.minecraft-pi/overrides/images/armor/diamond_2.png13",
|
||||
"~/.minecraft-pi/overrides/images/armor/gold_1.png10",
|
||||
"~/.minecraft-pi/overrides/images/armor/gold_2.png10",
|
||||
"~/.minecraft-pi/overrides/images/armor/iron_1.png10",
|
||||
"~/.minecraft-pi/overrides/images/armor/iron_2.png10",
|
||||
"~/.minecraft-pi/overrides/images/art/kz.png06",
|
||||
"~/.minecraft-pi/overrides/images/environment/clouds.png10",
|
||||
"~/.minecraft-pi/overrides/images/font/default8.png12",
|
||||
"~/.minecraft-pi/overrides/images/gui/background.png14",
|
||||
"~/.minecraft-pi/overrides/images/gui/bg32.png08",
|
||||
"~/.minecraft-pi/overrides/images/gui/cursor.png10",
|
||||
"~/.minecraft-pi/overrides/images/gui/default_world.png17",
|
||||
"~/.minecraft-pi/overrides/images/gui/gui.png07",
|
||||
"~/.minecraft-pi/overrides/images/gui/gui2.png08",
|
||||
"~/.minecraft-pi/overrides/images/gui/gui_blocks.png14",
|
||||
"~/.minecraft-pi/overrides/images/gui/icons.png09",
|
||||
"~/.minecraft-pi/overrides/images/gui/itemframe.png13",
|
||||
"~/.minecraft-pi/overrides/images/gui/items.png09",
|
||||
"~/.minecraft-pi/overrides/images/gui/pi_title.png12",
|
||||
"~/.minecraft-pi/overrides/images/gui/spritesheet.png15",
|
||||
"~/.minecraft-pi/overrides/images/gui/title.png09",
|
||||
"~/.minecraft-pi/overrides/images/gui/touchgui.png12",
|
||||
"~/.minecraft-pi/overrides/images/gui/badge/minecon140.png14",
|
||||
"~/.minecraft-pi/overrides/images/gui/logo/raknet_high_72.png18",
|
||||
"~/.minecraft-pi/overrides/images/gui/logo/raknet_low_18.png17",
|
||||
"~/.minecraft-pi/overrides/images/item/arrows.png10",
|
||||
"~/.minecraft-pi/overrides/images/item/camera.png10",
|
||||
"~/.minecraft-pi/overrides/images/item/sign.png08",
|
||||
"~/.minecraft-pi/overrides/images/mob/char.png08",
|
||||
"~/.minecraft-pi/overrides/images/mob/chicken.png11",
|
||||
"~/.minecraft-pi/overrides/images/mob/cow.png07",
|
||||
"~/.minecraft-pi/overrides/images/mob/creeper.png11",
|
||||
"~/.minecraft-pi/overrides/images/mob/pig.png07",
|
||||
"~/.minecraft-pi/overrides/images/mob/pigzombie.png13",
|
||||
"~/.minecraft-pi/overrides/images/mob/sheep.png09",
|
||||
"~/.minecraft-pi/overrides/images/mob/sheep_fur.png13",
|
||||
"~/.minecraft-pi/overrides/images/mob/skeleton.png12",
|
||||
"~/.minecraft-pi/overrides/images/mob/spider.png10",
|
||||
"~/.minecraft-pi/overrides/images/mob/zombie.png10",
|
||||
"~/.minecraft-pi/overrides/images/particles.png13",
|
||||
"~/.minecraft-pi/overrides/images/terrain.png11",
|
||||
]
|
||||
|
||||
foundInSystem = []
|
||||
notFoundInSystem = []
|
||||
foundInTexturepack = []
|
||||
notFoundInTexturepack = []
|
||||
|
||||
for fn in texturePaths:
|
||||
if Path(fn[:-2]).is_file():
|
||||
foundInSystem.append(fn)
|
||||
else:
|
||||
notFoundInSystem.append(fn)
|
||||
|
||||
try:
|
||||
imgdata = archive.read(fn[-int(fn[-2:]) - 2 : -2])
|
||||
print("Found", fn[-int(fn[-2:]) - 2 : -2], "in tp")
|
||||
foundInTexturepack.append(fn)
|
||||
except:
|
||||
notFoundInTexturepack.append(fn)
|
||||
|
||||
print("MCPI Texture check:", str(len(foundInSystem)), "out of", str(len(texturePaths)))
|
||||
if len(foundInSystem) < len(texturePaths):
|
||||
print("The following textures were not found:")
|
||||
for i in notFoundInSystem:
|
||||
print(i[-int(i[-2:]) - 2 : -2])
|
||||
loadTextures(filePath)
|
|
@ -19,64 +19,14 @@ Copyright (C) 2022 Alexey Pavlov
|
|||
|
||||
"""
|
||||
|
||||
from zipfile import *
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
import click
|
||||
|
||||
INDEX = [
|
||||
# Armor
|
||||
"armor/chain_1.png",
|
||||
"armor/chain_2.png",
|
||||
"armor/cloth_1.png",
|
||||
"armor/cloth_2.png",
|
||||
"armor/diamond_1.png",
|
||||
"armor/diamond_2.png",
|
||||
"armor/gold_1.png",
|
||||
"armor/gold_2.png",
|
||||
"armor/iron_1.png",
|
||||
"armor/iron_2.png",
|
||||
# Miscelannous
|
||||
"art/kz.png",
|
||||
"environment/clouds.png",
|
||||
# Font and GUI
|
||||
"font/default8.png",
|
||||
"gui/background.png",
|
||||
"gui/bg32.png",
|
||||
"gui/cursor.png",
|
||||
"gui/default_world.png",
|
||||
"gui/gui.png",
|
||||
"gui/gui2.png",
|
||||
"gui/gui_blocks.png",
|
||||
"gui/icons.png",
|
||||
"gui/itemframe.png",
|
||||
"gui/items.png", # Items
|
||||
"gui/pi_title.png",
|
||||
"gui/spritesheet.png",
|
||||
"gui/title.png",
|
||||
"gui/touchgui.png",
|
||||
"gui/badge/minecon140.png",
|
||||
"gui/logo/raknet_high_72.png",
|
||||
"gui/logo/raknet_low_18.png",
|
||||
# Item entitites
|
||||
"item/arrows.png",
|
||||
"item/camera.png",
|
||||
"item/sign.png",
|
||||
# Mobs
|
||||
"mob/char.png",
|
||||
"mob/chicken.png",
|
||||
"mob/cow.png",
|
||||
"mob/creeper.png",
|
||||
"mob/pig.png",
|
||||
"mob/pigzombie.png",
|
||||
"mob/sheep.png",
|
||||
"mob/sheep_fur.png",
|
||||
"mob/skeleton.png",
|
||||
"mob/spider.png",
|
||||
"mob/zombie.png",
|
||||
# Misc entities
|
||||
"particles.png",
|
||||
# Blocks
|
||||
"terrain.png",
|
||||
]
|
||||
USER = os.getenv("USER")
|
||||
|
||||
INDEX = [
|
||||
# Armor
|
||||
|
@ -109,7 +59,7 @@ INDEX = [
|
|||
"spritesheet.png",
|
||||
"title.png",
|
||||
"touchgui.png",
|
||||
"minecon140.png",
|
||||
"badge/minecon140.png",
|
||||
"raknet_high_72.png",
|
||||
"raknet_low_18.png",
|
||||
# Item entitites
|
||||
|
@ -117,7 +67,6 @@ INDEX = [
|
|||
"camera.png",
|
||||
"sign.png",
|
||||
# Mobs
|
||||
"char.png",
|
||||
"chicken.png",
|
||||
"cow.png",
|
||||
"creeper.png",
|
||||
|
@ -134,9 +83,68 @@ INDEX = [
|
|||
"terrain.png",
|
||||
]
|
||||
|
||||
def install_pack():
|
||||
pass
|
||||
TEXTURE_PATHS = [
|
||||
"armor/chain_1.png",
|
||||
"armor/chain_2.png",
|
||||
"armor/cloth_1.png",
|
||||
"armor/cloth_2.png",
|
||||
"armor/diamond_1.png",
|
||||
"armor/diamond_2.png",
|
||||
"armor/gold_1.png",
|
||||
"armor/gold_2.png",
|
||||
"armor/iron_1.png",
|
||||
"armor/iron_2.png",
|
||||
"art/kz.png",
|
||||
"environment/clouds.png",
|
||||
"font/default8.png",
|
||||
"gui/background.png",
|
||||
"gui/bg32.png",
|
||||
"gui/cursor.png",
|
||||
"gui/default_world.png",
|
||||
"gui/gui.png",
|
||||
"gui/gui2.png",
|
||||
"gui/gui_blocks.png",
|
||||
"gui/icons.png",
|
||||
"gui/itemframe.png",
|
||||
"gui/items.png",
|
||||
"gui/pi_title.png",
|
||||
"gui/spritesheet.png",
|
||||
"gui/title.png",
|
||||
"gui/touchgui.png",
|
||||
"gui/badge/minecon140.png",
|
||||
"gui/logo/raknet_high_72.png",
|
||||
"gui/logo/raknet_low_18.png",
|
||||
"item/arrows.png",
|
||||
"item/camera.png",
|
||||
"item/sign.png",
|
||||
"mob/chicken.png",
|
||||
"mob/cow.png",
|
||||
"mob/creeper.png",
|
||||
"mob/pig.png",
|
||||
"mob/pigzombie.png",
|
||||
"mob/sheep.png",
|
||||
"mob/sheep_fur.png",
|
||||
"mob/skeleton.png",
|
||||
"mob/spider.png",
|
||||
"mob/zombie.png",
|
||||
"particles.png",
|
||||
"terrain.png"
|
||||
]
|
||||
|
||||
def install_pack(zip_path):
|
||||
not_found = list()
|
||||
found = list()
|
||||
with ZipFile(zip_path) as zip_file:
|
||||
for file in zip_file.namelist():
|
||||
if file in INDEX:
|
||||
found.append(file)
|
||||
else:
|
||||
not_found.append(file)
|
||||
for file in found:
|
||||
zip_file.extract(file, path=f"/home/{USER}/.minecraft-pi/overrides/images/"+TEXTURE_PATHS[INDEX.index(file)][:-len(INDEX[INDEX.index(file)])])
|
||||
|
||||
def erase_pack():
|
||||
shutil.rmtree(f"/home/{USER}/.minecraft-pi/overrides/images")
|
||||
|
||||
|
||||
@click.group()
|
||||
|
@ -146,11 +154,15 @@ def main():
|
|||
@main.command(help="Install a texture pack")
|
||||
@click.option("--file", "--zipfile", "-f", "texture_path", help="Texture pack path.", type=click.Path(exists=True))
|
||||
#@click.option("--mcpit", is_flag=True, default=True)
|
||||
def install(texture_path, mcpit):
|
||||
def install(texture_path):
|
||||
if texture_path == None:
|
||||
click.echo("Please supply a path")
|
||||
return
|
||||
click.echo("Path is "+click.format_filename(texture_path))
|
||||
install_pack(texture_path)
|
||||
|
||||
@main.command(help="Erase the pack files")
|
||||
def erase():
|
||||
erase_pack()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -5,7 +5,7 @@ Maintainer: mcpiscript <mcpiscript@gmail.com>
|
|||
Depends: python3-pyqt5, python3:any, python3-pyqt5.qtwebkit, python3-pyqt5.qtsvg, python3-pyqt5.qtwebkit, python3-pyqt5.qtmultimedia, gcc
|
||||
Replaces: mcpil, mcpil-r, gmcpil, jmcpil
|
||||
Recommends: python3-pyqtdarkmode, python3-minecraftpi
|
||||
Provides: pi-nbt
|
||||
Provides: pi-nbt, mcpiedit, mcpit
|
||||
Section: games
|
||||
Priority: optional
|
||||
Homepage: https://github.com/mcpiscript/Planet
|
||||
|
|
|
@ -2,4 +2,5 @@ pip3 install pyqtdarktheme pypresence pillow darkdetect qtwidgets pynbt
|
|||
link /usr/lib/planet-launcher/main.py /usr/bin/planet-launcher
|
||||
chmod 755 /usr/lib/planet-launcher/main.py
|
||||
link /usr/lib/planet-launcher/assets/misc/planet-launcher.desktop /usr/share/applications/planet-launcher.desktop
|
||||
link /usr/lib/planet-launcher/textures.py /usr/bin/mcpit
|
||||
gcc /usr/lib/planet-launcher/pi-nbt.c -o /usr/bin/pi-nbt
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
rm -rf /usr/bin/planet-launcher
|
||||
rm -rf /usr/share/applications/planet-launcher.desktop
|
||||
rm -rf /usr/bin/pi-nbt
|
||||
rm -rf /usr/bin/mcpit
|
||||
|
|
Loading…
Reference in New Issue