Amulet-Team / Amulet-Map-Editor

A new Minecraft world editor and converter that supports all versions since Java 1.12 and Bedrock 1.7.
https://www.amuletmc.com/
1.78k stars 123 forks source link

[Bug Report] World Load & Resource Pack Errors in Amulet v0.10.18 - v0.10.23 #994

Closed StealthyExpertX closed 6 months ago

StealthyExpertX commented 1 year ago

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:

  1. Go to 'Amulet'
  2. Click and 'Open the World'
  3. Select any World from the list
  4. Encounter errors in the console, Amulet will refuse to render any blocks in the map correctly.

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.

INFO - PyMCTranslate Version 252
INFO - Loading level C:\Users\mayhe\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\minecraftWorlds\PdM4ZSk9CgA=
INFO - Downloading java launcher manifest file.
INFO - Finished downloading java launcher manifest file.
INFO - Downloading Java resource pack for version 1.20.2
ERROR - Failed to download and extract the Java resource pack for version 1.20.2.

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

INFO - OpenGL Version 4.6.0 NVIDIA 536.23
WARNING - Could not find translation information for block minecraft:white_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:light_blue_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:cyan_stained_glass to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:black_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:gray_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message

INFO - Finished setting up texture atlas in OpenGL
WARNING - Could not find translation information for block minecraft:white_concrete_powder to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:black_stained_glass_pane to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:light_blue_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:cyan_stained_glass from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:black_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:gray_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_concrete_powder from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:black_stained_glass_pane from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_terracotta to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:yellow_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_terracotta from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:yellow_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:purple_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:purple_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:gray_stained_glass_pane to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:gray_stained_glass_pane from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:lime_terracotta to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:lime_terracotta from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:red_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:red_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:light_gray_stained_glass_pane to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:light_gray_stained_glass_pane from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:green_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:green_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_stained_glass_pane to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:red_terracotta to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_stained_glass_pane from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:red_terracotta from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:light_gray_concrete to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:light_gray_concrete from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:gray_stained_glass to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:gray_stained_glass from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_stained_glass to universal in PyMCTranslate.Version(bedrock, (1, 20, 0)). If this is not a vanilla block ignore this message
WARNING - Could not find translation information for block minecraft:white_stained_glass from universal in PyMCTranslate.Version(java, (1, 20, 0)). If this is not a vanilla block ignore this message

Attachments

Screenshots

image

Worlds

N/A - This happens everywhere that I attempted to test.

gentlegiantJGC commented 1 year 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

Patte1994 commented 1 year ago

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.

StealthyExpertX commented 1 year ago

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'}
StealthyExpertX commented 1 year ago

I may be using this incorrectly or something? @gentlegiantJGC

gentlegiantJGC commented 1 year ago

I meant run Amulet from source, modify that file and open the application to reproduce the issue.

mayhembst commented 1 year 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

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
mayhembst commented 1 year ago

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

image image

Inside META-INF image

download.zip

EDIT: WinRAR rebuild seems to do the trick to view the files

gentlegiantJGC commented 1 year ago

That is odd. It has not downloaded the last 1/5th of the file

gentlegiantJGC commented 1 year ago

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))
mayhembst commented 1 year ago

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.

mayhembst commented 1 year ago

Compiled Builds:

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

Running from Source:

Same stuff as above. Not Working with the 4G lte connection but working perfectly with a non lte connection

Conclusion

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.

gentlegiantJGC commented 1 year ago

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()
gentlegiantJGC commented 6 months ago

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.