Closed StealthyExpertX closed 6 months ago
Can you open another issue for the translation issues with a world attached for me to debug.
Clearly something is going wrong with the application downloading the resource pack and the zip library can't read it because it isn't valid. I can't reproduce the issue on my computer running from source or in the compiled build.
Can I get you to install the program from source and modify this file minecraft_model_reader\api\resource_pack\java\download_resources.py
.
Add the following before line 162
with open("C:\Users\mayhe\Downloads\download.zip", "wb") as f:
f.write(b"".join(data))
And then send me download.zip
Hello, I have the same problem. And the path cannot be found. My path looks like this: C:\Users\PATTE\Desktop\Amulet\minecraft_model_reader\api\resource_pack\java\java_vanilla_fix He tells me he has no connection to the Internet even though Windows Firewall is disabled and the virus program Norton is in sleep mode.
After adding your code and running the Minecraft-Model-Reader-master\tests\java_resource_pack_test.py
I get the following exception it does not download the file.
INFO - PyMCTranslate Version 261
Traceback (most recent call last):
File "E:\Downloads\model_reader\Minecraft-Model-Reader-master\tests\java_resource_pack_test.py", line 13, in <module>
fire: Block = Block(
File "C:\Users\USERNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\amulet\api\block.py", line 137, in __init__
assert isinstance(properties, dict) and all(
AssertionError: {'age': '0', 'east': 'true', 'north': 'true', 'south': 'false', 'up': 'false', 'west': 'false'}
I may be using this incorrectly or something? @gentlegiantJGC
I meant run Amulet from source, modify that file and open the application to reproduce the issue.
Can you open another issue for the translation issues with a world attached for me to debug.
Clearly something is going wrong with the application downloading the resource pack and the zip library can't read it because it isn't valid. I can't reproduce the issue on my computer running from source or in the compiled build.
Can I get you to install the program from source and modify this file
minecraft_model_reader\api\resource_pack\java\download_resources.py
.Add the following before line 162
with open("C:\Users\mayhe\Downloads\download.zip", "wb") as f: f.write(b"".join(data))
And then send me download.zip
This is what I receive with the modified code
Traceback (most recent call last):
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\api\framework\amulet_ui.py", line 157, in open_level
world = WorldPageUI(self, path)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\api\framework\pages\world_page.py", line 76, in __init__
self._load_extensions()
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\api\framework\pages\world_page.py", line 101, in _load_extensions
load_extensions()
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\api\framework\pages\world_page.py", line 37, in load_extensions
extensions.append(load_extension(module_name))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\api\framework\pages\world_page.py", line 49, in load_extension
module = importlib.import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\programs\edit\__init__.py", line 6, in <module>
from amulet_map_editor.programs.edit.edit import EditExtension
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\programs\edit\edit.py", line 19, in <module>
from amulet_map_editor.programs.edit.api.canvas.edit_canvas import EditCanvas
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\programs\edit\api\__init__.py", line 2, in <module>
from .canvas import EditCanvas
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\programs\edit\api\canvas\__init__.py", line 1, in <module>
from .edit_canvas import EditCanvas
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\programs\edit\api\canvas\edit_canvas.py", line 8, in <module>
from .base_edit_canvas import BaseEditCanvas
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\amulet_map_editor\programs\edit\api\canvas\base_edit_canvas.py", line 14, in <module>
from minecraft_model_reader.api.resource_pack.java.download_resources import (
File "C:\Users\mayhe\Desktop\virtualamulet\venv\Lib\site-packages\minecraft_model_reader\api\resource_pack\java\download_resources.py", line 162
with open("C:\Users\mayhe\Downloads\download.zip", "wb") as f:
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
I replaced all of the \
from "C:\Users\mayhe\Downloads\download.zip", "wb"
with /
and got this as a result.
The zip file was created, but appears to be corrupt
Inside META-INF
EDIT: WinRAR rebuild seems to do the trick to view the files
That is odd. It has not downloaded the last 1/5th of the file
I still don't understand why it would only download part of the file. I would expect if the internet connection dropped it would time out and raise an error.
Here is the code extracted from the application if you want to experiment reproducing it outside of the application.
from urllib.request import urlopen
url = "https://piston-data.mojang.com/v1/objects/82d1974e75fc984c5ed4b038e764e50958ac61a0/client.jar"
chunk_size = 4096
with urlopen(url, timeout=20) as response, open("client.jar", "wb") as jar:
data_size = int(response.headers["content-length"].strip())
index = 0
chunk = b"hello"
while chunk:
chunk = response.read(chunk_size)
jar.write(chunk)
index += 1
print(min(1.0, index * chunk_size / data_size))
I think I have found the reason for the resource pack not downloading. I currently use a 4G router as my primary network. I'm pretty sure this makes use of IP pooling which may be causing the download issues. I noticed on streaming platforms I briefly disconnect and reconnect (extremely quickly). Amulet seems to work completely fine on my other network though so I'm assuming that's the cause. I'll keep retesting it for a while.
Amulet V0.10.24 using 4G router
Traceback (most recent call last):
File "minecraft_model_reader\api\resource_pack\java\download_resources.py", line 162, in download_resources_iter
File "zipfile.py", line 1266, in __init__
File "zipfile.py", line 1333, in _RealGetContents
zipfile.BadZipFile: File is not a zip file
Same thing on multiple Bedrock and Java worlds, nothing loads
Amulet V0.10.24 using a non lte router
Works as expected for Bedrock and Java worlds
Amulet V0.10.25 using 4G router
Traceback (most recent call last):
File "minecraft_model_reader\api\resource_pack\java\download_resources.py", line 162, in download_resources_iter
File "zipfile.py", line 1266, in __init__
File "zipfile.py", line 1333, in _RealGetContents
zipfile.BadZipFile: File is not a zip file
Same thing on multiple Bedrock and Java worlds, nothing loads
Amulet V0.10.25 using a non lte router
Works as expected for Bedrock and Java worlds
Same stuff as above. Not Working with the 4G lte connection but working perfectly with a non lte connection
I strongly believe that the 4G lte connection is what is causing the download issue. I'm not even sure if anything can be done to actually fix this other than a manual resource pack download.
Here is some more code with retries if the downloaded file does not match the expected file length
from urllib.request import urlopen, Request
def download_with_retry(url: str, chunk_size: int = 4096, attempts: int = 5) -> bytes:
content_length_found = 0
content = []
for _ in range(attempts):
request = Request(url, headers={"Range": f"bytes={content_length_found}-"})
with urlopen(request, timeout=20) as response:
content_length = int(response.headers["content-length"].strip())
while True:
chunk = response.read(chunk_size)
if not chunk:
break
content.append(chunk)
content_length_found += len(chunk)
print(min(1.0, content_length_found / content_length))
if content_length == content_length_found:
break
else:
raise RuntimeError("Failed to download client.jar")
return b"".join(content)
def main():
url = "https://piston-data.mojang.com/v1/objects/82d1974e75fc984c5ed4b038e764e50958ac61a0/client.jar"
data = download_with_retry(url)
with open("client.jar", "wb") as jar:
jar.write(data)
if __name__ == '__main__':
main()
This should be solved by gentlegiantJGC/Minecraft-Model-Reader#32 I am also adding a dialog giving the user the option to try downloading it again.
Bug Report
Current Behaviour:
I am unable to load any of my words in both Amulet v0.10.18 through v0.10.23. The issue persists even after a fresh install and clearing of my Amulet folders.
Expected behavior:
I expect my worlds to load without any errors.
Steps To Reproduce:
Environment:
Additional context
The console log suggests a BadZipFile error with the amulet resource pack from Java it tried installing and numerous warnings regarding block translation information. The issues with block definitions are believed to be due to the recent Minecraft v1.20.40 update which changed block state values a lot. I recommend updating the PyMCTranslate package and investigating the bad zip issue.
Attachments
Screenshots
Worlds
N/A - This happens everywhere that I attempted to test.