I tried using a launch wrapper script, as you inventively suggested, but then I realized that the cache is reset and emptied on each use, so there’s nothing to copy into the sandbox when the program starts. This is because Amulet doesn’t know what version of Minecraft you need the textures for until you actually open a world, which makes sense. For whatever reason though, when running via a PIP install inside a VENV, this is fine and everything just works. However, when running as a flatpak, things break.
This is how Amulet initializes the directories it needs:
import os
import platformdirs
experimental_bedrock_resources = False
from ._version import get_versions
__version__ = get_versions()["version"]
del get_versions
data_dir = platformdirs.user_data_dir("AmuletMapEditor", "AmuletTeam")
os.environ.setdefault("DATA_DIR", data_dir)
config_dir = platformdirs.user_config_dir("AmuletMapEditor", "AmuletTeam")
if config_dir == data_dir:
config_dir = os.path.join(data_dir, "Config")
os.environ.setdefault("CONFIG_DIR", config_dir)
os.environ.setdefault("CACHE_DIR", platformdirs.user_cache_dir("AmuletMapEditor", "AmuletTeam"))
os.environ.setdefault("LOG_DIR", platformdirs.user_log_dir("AmuletMapEditor", "AmuletTeam"))
from amulet_map_editor.api import config as CONFIG, lang
from amulet_map_editor.api.framework.app import open_level, close_level
When running from natively from PIP, these variables seem to be empty initially, but when running as a Flatpak, they’re not, as you can see from this side-by-side from my terminal logs:
Is this difference in behaviour possibly making things not work quite right? Theoretically, any Linux system that can run Flatpak should use the same folder structure as defined by the XDG standards, right?
Well, in an effort to better control the directory usage, I tried this:
id: io.github.evilsupahfly.amulet_flatpak
runtime: org.freedesktop.Platform
runtime-version: '24.08'
sdk: org.freedesktop.Sdk
command: amulet_map_editor
finish-args:
- --device=all
- --device=dri
- --allow=devel
- --allow=per-app-dev-shm
- --share=network
- --share=ipc
- --socket=wayland
- --socket=fallback-x11
- --unset-env=XDG_STATE_HOME
- --unset-env=XDG_CONFIG_HOME
- --unset-env=XDG_DATA_HOME
- --unset-env=XDG_CACHE_HOME
- --filesystem=host
- --filesystem=host-os
- --filesystem=home:create
- --filesystem=~/.cache/AmuletMapEditor:create
- --filesystem=~/.local/state/AmuletMapEditor:create
- --filesystem=~/.local/state/AmuletMapTeam:create
- --filesystem=~/.local/share/AmuletMapEditor:create
- --filesystem=~/.config/state/AmuletMapEditor:create
- --env=LIBGL_ALWAYS_SOFTWARE="0"
- --env=OPENGL_VERSION=3.3
- --env=OPENGL_LIB=/usr/lib/x86_64-linux-gnu/libGL.so
- --env=PS1=[ AMULET_FLATPAK > \w]\n>
# Uncomment the following options to increase debug output verbosity in the terminal
# - --env=PYTHONDEBUG=3
# - --env=PYTHONVERBOSE=3
# - --env=PYTHONTRACEMALLOC=10
# - --env=G_MESSAGES_DEBUG=all
modules:
- shared-modules/glew/glew.json
- shared-modules/glu/glu-9.json
- updates.yaml
- pip-gen.yaml
- name: metainfo-xml
buildsystem: simple
build-commands:
- install -Dm644 io.github.evilsupahfly.amulet_flatpak.metainfo.xml -t ${FLATPAK_DEST}/share/metainfo/
sources:
- type: file
path: io.github.evilsupahfly.amulet_flatpak.metainfo.xml
- name: metainfo-desktop
buildsystem: simple
build-commands:
- install -Dm755 io.github.evilsupahfly.amulet_flatpak.desktop -t ${FLATPAK_DEST}/share/applications/
sources:
- type: file
path: io.github.evilsupahfly.amulet_flatpak.desktop
- name: metainfo-ico
buildsystem: simple
build-commands:
- install -Dm644 io.github.evilsupahfly.amulet_flatpak.png -t ${FLATPAK_DEST}/share/icons/hicolor/256x256/apps/
sources:
- type: file
path: io.github.evilsupahfly.amulet_flatpak.png
But it didn’t work and I’m still missing water
and lava
:
ERROR - Failed to load block model {'model': 'minecraft:block/lava'}
'/app/lib/python3.12/site-packages/minecraft_model_reader/api/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png'
ERROR - Failed to load block model {'model': 'minecraft:block/water'}
'/app/lib/python3.12/site-packages/minecraft_model_reader/api/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png'
which being built-in, aren’t included in the official texture pack which gets downloaded, and that seems to be the issue.
The files are physically (digitally?) present in the sandbox, and the .JSON is readable:
Attempting to load model /app/lib/python3.12/site-packages/minecraft_model_reader/api/resource_pack/java/java_vanilla_fix/assets/minecraft/models/block/water.json
Attempting to load model /home/evilsupahfly/.var/app/io.github.evilsupahfly.amulet_flatpak/cache/AmuletMapEditor/resource_packs/java/vanilla/assets/minecraft/models/block/rooted_dirt.json
My gut is telling me that there’s some key difference between the way Python’s directories are handled inside versus outside the sandbox, but I’m unable to find it. I’ve loaded the app (which is actually composed of 7 different sub-projects which combine like Power Ranges to make ULTIMA AMULET) down with so many print statements now, tracking every loop, file access and directory assignment that my Flatpak terminal log is now over 10 MB from all the extra info.
To track the key differences, I also installed the modified versions of the Amulet base apps into my VENV with PIP. Those terminal logs are only 7 MB. In the error loop, at one point, I had worked out an override for water
but it treated water like a solid block, not a transparent one, and that was no better.
So, now I’m back to square one: Amulet loads, worlds can be edited, but water and lava are replaced with the black-and-purple checked pattern for missing textures.