mojira.dev
MC-105886

World File Names Containing Brackets Will Not Load Packaged Resource Packs

If the name of your world file contains any of the following brackets: [ { } ], and you have a resources.zip resource pack packaged with the map, the map will not load that resource pack when opened.

I have provided an example world file in the attachments. The resource pack packaged with this world file is an empty one to demonstrate that the game is not loading any resources. This bug will occur even if the resource pack is not empty. When you open the map, view the launcher and you will notice that there is no indication of any resource pack being loaded. If you remove the brackets in the world file name and load it, you will notice that the launcher DOES indicate a pack being loaded this time.


Code analysis by @unknown in this comment.

Attachments

Comments 7

This world has a file name containing brackets. If you open this world, the resource pack also provided will not be loaded in the world.

Are you specifically referring to the square brackets, the curly braces, or both?

Can confirm with both.

Yes all of the brackets. If any of them exist in the file name, the resource pack won't load.
[ { } ] <- these four

It looks like these characters are not properly escaped in the level:// URI.

Based on 1.10.2 code decompiled via MCP 9.30

net.minecraft.server.MinecraftServer.setResourcePackFromWorld(String, ISaveHandler)

public void setResourcePackFromWorld(String worldNameIn, ISaveHandler saveHandlerIn)
    {
        File file1 = new File(saveHandlerIn.getWorldDirectory(), "resources.zip");

        if (file1.isFile())
        {
            this.setResourcePack("level://" + worldNameIn + "/" + "resources.zip", "");
        }
    }

The method java.net.URLEncoder.encode(String, String) with java.nio.charset.StandardCharsets.UTF_8.toString() as encoding could be used to escape the file properly, see this stackoverflow comment.

The method net.minecraft.client.network.NetHandlerPlayClient.handleResourcePack(SPacketResourcePackSend) reading the file should then call the method java.net.URLDecoder.decode(String, String) to decode the file path, see Java: how to get a File from an escaped URL? (stackoverflow).

onnowhere

Erik Broes

Confirmed

Minecraft 1.10.2

Minecraft 16w36a

Retrieved