Litematica

Litematica

9M Downloads

failed to load chinese-named .litematic file

bAdOoWindy opened this issue · 9 comments

commented

Minecraft version
.1.17.1

Mod version and malilib version
litematica-fabric-1.17.1-0.0.0-dev.20210927.173826
malilib-fabric-1.17.1-0.10.0-dev.25
fabric-loader-0.11.7-1.17.1
[1.17.1] Fabric API 0.41.0
Java i'm using Minecraft Launcher included

Description of the bug
in main world load chinese-named .litematic file is ok
after "Save & Quit to Title"
load world again file name is garbled code
and show red text
Failed to read schematic from file '.minecraft\schematics"garbled code".litematic'

tmp

commented

图片
3 mod only
still not fixed

commented

Can you paste one such name in here so that I can test this? Not sure if it matters, but put it inside the code block just in case.

This has been reported a number of times over time, but all the reporters vanish somewhere when I ask for test cases (schematic files or at least the file names to test with).

commented

What do you see in the Load Schematics menu? Is the name there still correct? What is your system locale/character set set to?

The file name I see in the zip, and what I get when I extract it is already broken.
But if I just make a copy of the file and then rename it to the name shown in your previous message, then I basically have these two test schematics:
image

If I have the system locale (I'm on Linux) LC_ALL and LANG set to en_GB.UTF-8, then I see the file names like this, where the second file is the one where I copy pasted the name from the above message:
image

When I then log out of the world, then the placement config file has this (and both schematics are loaded successfully when I log back in):
image

But if I launch the game with the LC_ALL and LANG environment variables set to en_US.ISO-8859-1, then I see this:
image

And the placement config looks like this (if interpreted as UTF-8 in the text editor):
image

However with both locales, the placements are persistent and loaded successfully, as long as the same system locale was used when saving and loading the config file. So I would need to know at what stage does it get corrupted. Also, if you use area selection names with these characters, do those break when you restart the game, or does it store that correctly?

commented

What do you see in the Load Schematics menu?
file name is correct
Is the name there still correct?
yes and can correct load
What is your system locale/character set set to?
windows 10 X64 region setting not enable UTF-8
Also, if you use area selection names with these characters, do those break when you restart the game, or does it store that correctly?
it store correct
Schematics load well
area selection names NOT correct

i load Schematics in main world
it break when
1."save and quit to title" and back to same save , it breaks with garbled code filename
2.load Schematics in main world and leave main world back to main world break again with garbled code filename
PS:leave main world like goto "The Nether"
i'm trying enable UTF-8 in region setting
not working

i use jdk-17 have same break also jre1.8.0_301 breaks too
file name of cmd output is correct
[19:22:19] [Render thread/WARN]: Failed to load schematic 'F:.minecraft\schematics\分类单片.litematic'

area selection name will breaks too!
just like schematic file
图片
in area selections - garbled code named configure - can not Save Schematic even holded shift
found somthing new

with not chinese area name CAN use chinese named Sub-region for just one time even garbled code named
after second leave and back again main world Sub-region garbled code name changed and lost hold Sub-region
Sub-region CAN fix by "Reset all sub-region button" in Config Schematic placment
fix means Sub-region garbled code name chang back to first time it loaded and also blocks

commented

I'm not sure at what stage the encoding gets messed up then. You are using malilib 0.10.0-dev.25 right? At least in the first message and screenshots it looks like it. That version should always be using UTF-8 encoding when saving the config JSON files. But I'm not sure how it determines the encoding when reading the config, it's not specifically set in that version yet. I'm not sure if it uses the system character set, or if it tries to detect it from the file.

But could you try checking what is in the actual config files? The placement data is in the current version saved to a file at:

.minecraft/config/litematica/litematica_<world_or_server_name>_dim_<dimension_id>.json

(So in my test world's case: .minecraft/config/litematica/litematica_charset_test_dim_minecraft_overworld.json)

I don't know how character sets are handled in other text editors, but at least in Sublime Text it is shown in the bottom bar, in this case it's set to UTF-8:
image

If you click on the UTF-8 text on the bottom bar, then you can also re-open the file using other encodings.
You can use the evaluation version of Sublime Text for free if you want to try it out (you don't even need to install it, the portable version can just be extracted somewhere and launched directly): https://www.sublimetext.com/download

I don't really know how Windows handles the character set/locale, as I don't remember ever touching that stuff on Windows. I'll probably have to try it out on my old PC which still has Windows 10. But to fix this issue I need to know where in this process something is using the wrong character set. I'm assuming though that if your system is not using UTF-8, then the file name is probably getting converted/save wrong to the config file. So I assume for this to work correctly, your system character set would have to be UTF-8.

commented

So it seems like it's written to the file correctly, but then probably read from there wrong.

Try if using this malilib version fixes it or changes anything. It forces the config files to always also be read using UTF-8 encoding, instead of the system default charset or whatever it used before.
https://masa.dy.fi/mcmods/malilib/malilib-fabric-1.17.1-0.10.0-dev.26+pre.1.jar

commented

i emptied .minecraft/config/litematica/ and load schematic.

there is two .json file
litematica_fe80__e5bb_c30e_3f03_9b47_dim_minecraft_overworld.json

图片

notepad++ down right says is utf-8

litematica_fe80__e5bb_c30e_3f03_9b47.json

图片

commented

IT IS FIXED!