diff --git a/planet/main.py b/planet/main.py index cf2c700..f2a9bed 100644 --- a/planet/main.py +++ b/planet/main.py @@ -34,7 +34,7 @@ import json import pathlib import gettext -LOCALE = os.getenv('LANG', 'en') +LOCALE = os.getenv("LANG", "en") # Define the path used for later absolute_path = pathlib.Path(__file__).parent.absolute() @@ -49,7 +49,9 @@ if os.path.exists("/usr/lib/planet-launcher/"): sys.path.append("/usr/lib/planet-launcher/") -_ = gettext.translation('main', localedir=str(absolute_path)+"/assets/translations/", languages=[LOCALE]).gettext +_ = gettext.translation( + "main", localedir=str(absolute_path) + "/assets/translations/", languages=[LOCALE] +).gettext # Local imports import launcher @@ -131,18 +133,20 @@ class ConfigPluto(QDialog): titlewidget.setLayout(titlelayout) # Set the layout # Label with information - info_label = QLabel(_( - 'Please select the executable you downloaded.\nIf you installed a DEB, please select the "Link" option' - )) + info_label = QLabel( + _( + 'Please select the executable you downloaded.\nIf you installed a DEB, please select the "Link" option' + ) + ) self.executable_btn = QPushButton(_("Select executable")) # Button for AppImage self.executable_btn.clicked.connect( self.get_appimage ) # Connect to the function - self.premade_btn = QPushButton(_( - "Link /usr/bin/minecraft-pi-reborn-client" - )) # Button for Pre-installed debs + self.premade_btn = QPushButton( + _("Link /usr/bin/minecraft-pi-reborn-client") + ) # Button for Pre-installed debs self.premade_btn.clicked.connect(self.link_appimage) # Connect to the function self.flatpak_btn = QPushButton(_("Link flatpak")) # Button for linking flatpak @@ -179,7 +183,10 @@ class ConfigPluto(QDialog): self.hide() # Hide the dialog # Open the file dialog self.filename = QFileDialog.getOpenFileName( - self, _("Select executable"), "/", "Executable files (*.AppImage *.bin *.sh *)" + self, + _("Select executable"), + "/", + "Executable files (*.AppImage *.bin *.sh *)", ) def link_appimage(self): @@ -297,7 +304,9 @@ class Planet(QMainWindow): # mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods") # tabs.setTabIcon(mods_tab, QIcon(f"{absolute_path}/assets/portal512.png")) settings_tab = tabs.addTab(self.settings_tab(), _("Settings")) # Changelog tab - tabs.setTabIcon(settings_tab, QIcon(f"{absolute_path}/assets/img/full/wrench512.png")) + tabs.setTabIcon( + settings_tab, QIcon(f"{absolute_path}/assets/img/full/wrench512.png") + ) self.layout.addWidget(tabs) @@ -375,7 +384,9 @@ class Planet(QMainWindow): splashlabel.adjustSize() # Adjust the size just in case splashlabel.setAlignment(Qt.AlignHCenter) # Align the label - usernamelabel = QLabel(_("Username")) # Label that is used to direct the line edit + usernamelabel = QLabel( + _("Username") + ) # Label that is used to direct the line edit self.usernameedit = QLineEdit() # Line Edit for username self.usernameedit.setPlaceholderText(_("StevePi")) # Set ghost value @@ -388,7 +399,9 @@ class Planet(QMainWindow): self.distancebox.addItems(["Far", "Normal", "Short", "Tiny"]) # Set the values self.distancebox.setCurrentText("Short") # Set the default option - profilelabel = QLabel(_("Profile")) # Label that is used to direct the combo box + profilelabel = QLabel( + _("Profile") + ) # Label that is used to direct the combo box self.profilebox = QComboBox() self.profilebox.addItems( @@ -532,7 +545,9 @@ class Planet(QMainWindow): ) # Set the text of the text editing area infolabel = QLabel( # Label with information about the server format - _('Servers are stored in the format of IP: Port') + _( + 'Servers are stored in the format of IP: Port' + ) ) layout.addWidget(self.serversedit, 0, 0) # Add the widgets @@ -718,7 +733,9 @@ class Planet(QMainWindow): dialog = QMessageBox() dialog.setWindowTitle(_("Are you sure you want to reset?")) dialog.setText( - _("Are you sure you want to delete the config? This action is unrecoverable.") + _( + "Are you sure you want to delete the config? This action is unrecoverable." + ) ) dialog.setStandardButtons(QMessageBox.Ok | QMessageBox.Abort) dialog.setIcon(QMessageBox.Warning) @@ -735,7 +752,9 @@ class Planet(QMainWindow): dialog = QMessageBox() dialog.setWindowTitle(_("Are you sure you want to reset?")) dialog.setText( - _("Are you sure you want to delete the AppImage? This action is unrecoverable.") + _( + "Are you sure you want to delete the AppImage? This action is unrecoverable." + ) ) dialog.setStandardButtons(QMessageBox.Ok | QMessageBox.Abort) dialog.setIcon(QMessageBox.Warning) diff --git a/planet/mcpiedit.py b/planet/mcpiedit.py index 9e7d1cf..ad7ff12 100644 --- a/planet/mcpiedit.py +++ b/planet/mcpiedit.py @@ -26,7 +26,7 @@ import os import pathlib import gettext -LOCALE = os.getenv('LANG') +LOCALE = os.getenv("LANG") from PyQt5.QtCore import * from PyQt5.QtWidgets import * @@ -47,8 +47,12 @@ if os.path.exists("/usr/lib/planet-launcher/"): if not os.path.exists(f"/home/{USER}/.minecraft-pi/games/com.mojang/minecraftWorlds/"): os.makedirs(f"/home/{USER}/.minecraft-pi/games/com.mojang/minecraftWorlds/") - -_ = gettext.translation('mcpiedit', localedir=str(absolute_path)+"/assets/translations/", languages=[LOCALE]).gettext + +_ = gettext.translation( + "mcpiedit", + localedir=str(absolute_path) + "/assets/translations/", + languages=[LOCALE], +).gettext GAME_TYPES = {"Survival": nbt.pynbt.TAG_Int(0), "Creative": nbt.pynbt.TAG_Int(1)} @@ -71,7 +75,9 @@ class AboutWindow(QWidget): label.setFont(font) # Aplly the font onto the label desc_label = QLabel( - _("The default built-in NBT editor for Planet.\n\nMCPIedit makes use of Pi-NBT\n from the original MCPIedit project\nby TheBrokenRail, which is\nlicensed under the MIT license.") + _( + "The default built-in NBT editor for Planet.\n\nMCPIedit makes use of Pi-NBT\n from the original MCPIedit project\nby TheBrokenRail, which is\nlicensed under the MIT license." + ) ) desc_label.setAlignment(Qt.AlignHCenter) @@ -88,7 +94,9 @@ class FileSelectorTab(QWidget): layout = QVBoxLayout() info_label = QLabel( - _("NBT editors allow you to edit your world\nfiles to change game modes, time,\nand even the world name. Select an NBT\nfile to edit using the button below.") + _( + "NBT editors allow you to edit your world\nfiles to change game modes, time,\nand even the world name. Select an NBT\nfile to edit using the button below." + ) ) info_label.setAlignment(Qt.AlignHCenter) @@ -260,7 +268,9 @@ class EditorTab(QWidget): layout.addWidget(player_z_label, 5, 0) note_label = QLabel( - _("Note:\nPlayer spawnpoints are very buggy!\nYou might spawn in the wrong\nplace or even outside the world!\nDo not use on valuable worlds.") + _( + "Note:\nPlayer spawnpoints are very buggy!\nYou might spawn in the wrong\nplace or even outside the world!\nDo not use on valuable worlds." + ) ) layout.addWidget(self.spawn_x_box, 0, 1) diff --git a/planet/textures.py b/planet/textures.py index 5a58726..406e454 100755 --- a/planet/textures.py +++ b/planet/textures.py @@ -27,7 +27,7 @@ import shutil import click -USER = os.getenv("USER") +USER = os.getenv("USER") INDEX = [ # Armor @@ -129,13 +129,15 @@ TEXTURE_PATHS = [ "mob/spider.png", "mob/zombie.png", "particles.png", - "terrain.png" + "terrain.png", ] + def pepack_install(zip_path): with ZipFile(zip_path) as zip_file: zip_file.extractall(path=f"/home/{USER}/.minecraft-pi/overrides/") + def mcpit_install(zip_path): not_found = list() found = list() @@ -145,23 +147,29 @@ def mcpit_install(zip_path): 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)])]) - - if "changelog" in zip_file.namelist(): + zip_file.extract( + file, + path=f"/home/{USER}/.minecraft-pi/overrides/images/" + + TEXTURE_PATHS[INDEX.index(file)][: -len(INDEX[INDEX.index(file)])], + ) + + if "changelog" in zip_file.namelist(): with zip_file.open("changelog") as file: click.echo(file.read()) - if "credits" in zip_file.namelist(): + if "credits" in zip_file.namelist(): with zip_file.open("credits") as file: click.echo(file.read()) -def install_pack(zip_path, pack_format): + +def install_pack(zip_path, pack_format): if pack_format == "mcpit": mcpit_install(zip_path) elif pack_format == "pepack": pepack_install(zip_path) + def erase_pack(): shutil.rmtree(f"/home/{USER}/.minecraft-pi/overrides/images") @@ -170,21 +178,40 @@ def erase_pack(): def main(): pass + @main.command(help="Install a texture pack") -@click.argument("pack_path", type=click.Path(exists=True)) -@click.option("--mcpit", "-m", "pack_format", is_flag=True, default=True, help="Use MCPiT format.", flag_value="mcpit") -@click.option("--pepack", "-p", "pack_format", is_flag=True, default=False, help="Use PEPack format.", flag_value="pepack") -def install(pack_path, pack_format): - install_pack(pack_path, pack_format) - +@click.argument("pack_path", type=click.Path(exists=True)) +@click.option( + "--mcpit", + "-m", + "pack_format", + is_flag=True, + default=True, + help="Use MCPiT format.", + flag_value="mcpit", +) +@click.option( + "--pepack", + "-p", + "pack_format", + is_flag=True, + default=False, + help="Use PEPack format.", + flag_value="pepack", +) +def install(pack_path, pack_format): + install_pack(pack_path, pack_format) + + @main.command(help="Erase the pack files") def erase(): erase_pack() - -@main.command(help = "Show version and license") + + +@main.command(help="Show version and license") def version(): click.echo(__doc__) - + if __name__ == "__main__": main() diff --git a/planet/weaving.py b/planet/weaving.py index 58e382a..a8feec6 100644 --- a/planet/weaving.py +++ b/planet/weaving.py @@ -1,34 +1,137 @@ +""" +This file is part of mcpit/Planet. +mcpit/Planet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +mcpit/Planet 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 Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License along with mcpit/Planet. If not, see . +""" from PIL import Image POSITIONS = { - "grass_top" : (0, 0, 16, 16), - "stone": (16, 0, 32, 16), + # Row 1 + "grass_carried": (0, 0, 16, 16), + "stone": (16, 0, 32, 16), "dirt": (32, 0, 48, 16), - "grass_side_carried": (48, 0, 64, 16), - "planks_oak": (64, 0, 80, 16), - "stone_slab_side" : (80, 0, 96, 16), - "stone_slab_top":(96, 0, 112, 16), - "brick":(112, 0, 128, 16), - "tnt_side":(128, 0, 144, 16), - "tnt_top":(144, 0, 160, 16), - "tnt_bottom":(160, 0, 176, 16), - "web": (176, 0, 192, 16), - "flower_rose":(192, 0, 208, 16), - "flower_dandelion":(208, 0, 224, 16), - "sapling_oak": (240, 0, 256, 16), - "cobblestone": (0, 16, 16, 32), - "bedrock": (16, 16, 32, 32), - "sand":(32, 16, 48, 32), # I love these blocks - "gravel":(48, 16, 64, 32), - "log_oak":(64, 16, 80, 32), - "log_oak_top":(80, 16, 96, 32), - - - + "grass_side_carried": (48, 0, 64, 16), + "planks_oak": (64, 0, 80, 16), + "stone_slab_side": (80, 0, 96, 16), + "stone_slab_top": (96, 0, 112, 16), + "brick": (112, 0, 128, 16), + "tnt_side": (128, 0, 144, 16), + "tnt_top": (144, 0, 160, 16), + "tnt_bottom": (160, 0, 176, 16), + "web": (176, 0, 192, 16), + "flower_rose": (192, 0, 208, 16), + "flower_dandelion": (208, 0, 224, 16), + "sapling_oak": (240, 0, 256, 16), + # Row 2 + "cobblestone": (0, 16, 16, 32), + "bedrock": (16, 16, 32, 32), + "sand": (32, 16, 48, 32), # I love these blocks + "gravel": (48, 16, 64, 32), + "oak_log": (64, 16, 80, 32), + "oak_log_top": (80, 16, 96, 32), + "iron_block": (96, 16, 112, 32), + "gold_block": (112, 16, 128, 32), + "diamond_block": (128, 16, 144, 32), + "chest_top": (144, 16, 160, 32), + "chest_side": (160, 16, 176, 32), + "chest_front": (176, 16, 192, 32), + "mushroom_red": (192, 16, 208, 32), + "mushroom_brown": (208, 16, 224, 32), + "fire_0_placeholder": (240, 16, 256, 32), + # Row 3 + "gold_ore": (0, 32, 16, 48), + "iron_ore": (16, 32, 32, 48), + "coal_ore": (32, 32, 48, 48), + "bookshelf": (48, 32, 64, 48), + "cobblestone_mossy": (64, 32, 80, 48), + "obsidian": (80, 32, 96, 48), + "grass_side": (96, 32, 112, 48), + "tallgrass": (112, 32, 128, 48), + "grass_top": (128, 32, 144, 48), + "crafting_table_top": (176, 32, 192, 48), + "furnace_front": (192, 32, 208, 48), + "furnace_side": (208, 32, 224, 48), + "fire_1_placeholder": (240, 32, 256, 48), + # Row 4 + "glass": (16, 48, 32, 64), + "diamond_ore": (32, 48, 48, 64), + "redstone_ore": (48, 48, 64, 64), + "leaves_oak_carried": (64, 48, 80, 64), + "leaves_big_oak_carried": (80, 48, 96, 64), + "stonebrick": (96, 48, 112, 64), + "deadbush": (112, 48, 128, 64), + "shrub": (128, 48, 144, 64), + "crafting_table_side": (176, 48, 192, 64), + "crafting_table_front": (192, 48, 208, 64), + "furnace_front_on": (208, 48, 224, 64), + "furnace_top": (224, 48, 240, 64), + "spruce_sapling": (240, 48, 256, 64), + # Row 5 + "white_wool": (0, 64, 16, 80), + "snow": (32, 64, 48, 80), + "ice": (48, 64, 64, 80), + "grass_block_snow": (64, 64, 80, 80), + "cactus_top": (80, 64, 96, 80), + "cactus_side": (96, 64, 112, 80), + "cactus_bottom": (112, 64, 128, 80), + "clay": (128, 64, 144, 80), + "sugarcane_extracted": (144, 64, 160, 80), + "birch_sapling": (240, 64, 256, 80), + # Row 6 + "torch": (0, 80, 16, 96), + "oak_door_top": (16, 80, 32, 96), + "iron_door_top": (32, 80, 48, 96), + "ladder": (48, 80, 64, 96), + "oak_trapdoor": (64, 80, 80, 96), + "farmland_moist": (96, 80, 112, 96), + "farmland": (112, 80, 128, 96), + "wheat_stage0": (128, 80, 144, 96), + "wheat_stage1": (144, 80, 160, 96), + "wheat_stage2": (160, 80, 176, 96), + "wheat_stage3": (176, 80, 192, 96), + "wheat_stage4": (192, 80, 208, 96), + "wheat_stage5": (208, 80, 224, 96), + "wheat_stage6": (224, 80, 240, 96), + "wheat_stage7": (240, 80, 256, 96), + # Row 7 + "oak_door_bottom": (16, 96, 32, 112), + "iron_door_bottom": (32, 96, 48, 112), + "mossy_stone_bricks": (48, 96, 64, 112), + "cracked_stone_bricks": (64, 96, 80, 112), + "netherrack": (96, 96, 112, 112), + "soul_sand": (112, 96, 128, 112), + "glowstone": (128, 96, 144, 112), + "melon_stem": (240, 96, 256, 112), + # Row 8 + "black_wool": (16, 112, 32, 128), + "gray_wool": (32, 112, 48, 128), + "dark_oak_log": (64, 112, 80, 128), + "birch_log": (80, 112, 96, 128), + "attached_melon_stem": (240, 112, 256, 128), + # Row 9 + "red_wool": (16, 128, 32, 144), + "pink_wool": (32, 128, 48, 144), + "birch_leaves": (48, 128, 64, 144), + "dark_oak_leaves": (32, 128, 48, 144), + "bed1": (48, 128, 64, 144), + "bed2": (64, 128, 80, 144), + "melon_side": (80, 128, 96, 144), + "melon_top": (96, 128, 112, 144), + "lapis_block": (112, 128, 128, 144), } + +def extract_fire(): + pass + + if __name__ == "__main__": - with Image.open("/home/leha2/.minecraft-pi/overrides/images/terrain.png") as img: - region=img.crop(POSITIONS["gravel"]) + with Image.open( + "/usr/lib/minecraft-pi-reborn-client/data/images/terrain.png" + ) as img: + region = img.crop(POSITIONS["black_wool"]) region.show()