CC: Tweaked

CC: Tweaked

42M Downloads

Unable to mount resources

LemADEC opened this issue ยท 3 comments

commented

Useful information to include:

  • Minecraft version 1.15.2
  • CC: Tweaked version 1.95.3
  • Logs:
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling getClass().getResource("/assets/warpdrive/lua.computercraft/common")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is file:/C:/_mcdev/_sandbox/_mods/WarpDrive-1.15/build/resources/main/assets/warpdrive/lua.computercraft/common
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling getClass().getResource("/assets/warpdrive/lua.computercraft/commonInvalid")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "lua.computercraft/common")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "/assets/lua.computercraft/common/")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "/assets/lua.computercraft/common")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "assets/lua.computercraft/common/")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "assets/lua.computercraft/common")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "/assets/warpdrive/lua.computercraft/common")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "/assets/warpdrive/lua.computercraft/common/")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "assets/warpdrive/lua.computercraft/common")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Calling ComputerCraftAPI.createResourceMount("warpdrive", "assets/warpdrive/lua.computercraft/common/")
[12:55:26] [ComputerCraft-Computer-Runner-0/INFO] [warpdrive/]: [CC] Returned value is null
  • Detailed reproduction steps:
    I'm updating my mod from 1.12.2 to 1.15.2. The resources mounting was working back on 1.12.2.
    Apart from renaming the assets to be lowercase, not much else have changed in terms of creating the resources.

The first 2 calls to getClass().getResource() shows that the folder exist and an invalid one is properly detected.
All following calls to ComputerCraftAPI.createResourceMount() are failling while trying different variations of the path.

I was expecting at least a debug log from ComputerCraftAPI itself about this failure, but nothing is seen here.

Here's the code snippet used for above logs :

String resourcePath = "/assets/" + WarpDrive.MODID + "/" + pathAsset;
WarpDrive.logger.info(String.format("[CC] Calling getClass().getResource(\"%s\")",
                                    resourcePath ));
URL url = getClass().getResource(resourcePath);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    url ));

resourcePath = "/assets/" + WarpDrive.MODID + "/" + pathAsset + "Invalid";
WarpDrive.logger.info(String.format("[CC] Calling getClass().getResource(\"%s\")",
                                    resourcePath ));
url = getClass().getResource(resourcePath);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    url ));

String pathTest = pathAsset;
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "/assets/" + pathAsset + "/";
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "/assets/" + pathAsset;
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "assets/" + pathAsset + "/";
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "assets/" + pathAsset;
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "/assets/warpdrive/" + pathAsset;
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "/assets/warpdrive/" + pathAsset + "/";
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "assets/warpdrive/" + pathAsset;
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));

pathTest = "assets/warpdrive/" + pathAsset + "/";
WarpDrive.logger.info(String.format("[CC] Calling ComputerCraftAPI.createResourceMount(\"%s\", \"%s\")",
                                    WarpDrive.MODID, pathTest ));
mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.MODID, pathTest);
WarpDrive.logger.info(String.format("[CC] Returned value is %s",
                                    mountCommon ));
commented

As per the docs, this accepts a path relative to your mod's datapack root, rather than the jar root.

https://github.com/SquidDev-CC/CC-Tweaked/blob/058d63e77ffe45fea917dde8a641277c68b53be2/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java#L100-L104

So you'll want a call like createResourceMount(WarpDrive.MODID, "lua.computercraft/common"), which resolves to /data/warpdrive/lua.computercraft/common.

I'll try to clarify the docs a little and make the mount warn if we can't find any matching files.

commented

I've probably missed something when testing the datapack approach. It works now, keep up the good updates!

commented

Hopefully that should be a little clearer now. Sorry, didn't really think about how usable that was before.

I know the API has changed a lot since 1.12, so do shout if you have any other problems!