Litematica

Litematica

9M Downloads

Make temporary edits persistent across dimension changes.

Arimodu opened this issue ยท 5 comments

commented

Is your feature request related to a problem? Please describe.
Temporary edits made via edit schematic mode lost when changing dimensions. ie: I change cobble to deepslate in the schematic as the building mat, then enter nether and then I have to do that again.

Describe the solution you'd like
Edits made to placements are remembered across dimension changes and game restarts.

Describe alternatives you've considered
Currently I have to enter a creative world locally, place the schematic, then use commands to replace the blocks I want to replace and then save the schematic again.

Additional context
Game and server version: 1.21.1
Mod version: 0.21.1

commented

So after you have edited the schematic, you would need to go to the Loaded Schematics menu, and click on the Save to file (or whatever it says exactly) button for that particular schematic, and then just save it to some preferably new file (instead of overwriting the original **). If you save it to a new file, then you will need to load it again from that file though, since the placement will refer to the old file (by path). (The newer development code in 1.12.2 has an option to update any placements to refer to the new file when saving a modified schematic, but unfortunately any of the 1.13+ mod versions still don't have that yet...)

** Overwriting the original schematic file carries the risk that if the edited copy is corrupted for whatever reason, then you would ofc lose the original too. Some older mod versions has a bug that could "seemingly" corrupt the edited version when it was loaded from file again. It was possible to fix the corrupted schematic with an NBT editor, but from the user point of view the edited copy was corrupted when loading it from the newly saved file.

Encoding any info in the file name itself is not a good solution. The mod supports loading schematics from arbitrary paths, and at least using sub directories for organization is very common and encouraged. So if we would assume the schematics are always inside the main schematic directory tree, then trying to load from a temp path first would probably be a viable solution, although personally I kinda don't like it. I would rather want to explicitly store info in the placement if the schematic has been modified. And if the schematic is not inside the main schematic directory tree, then appending the full path to the file as a sub directory under the temp directory would be kinda janky at least on Windows where you have the drive letter in the path.

As for multiple placements referencing the same file, that's actually kinda inconsistent behavior atm. Because you can load the same schematic file to memory multiple times, creating a placement for each. And if you then edit one of those schematics, the edit would only happen for that one loaded copy at first, so only one placement would have the edits. But the placements refer to the schematic by its full path, so if you log out and log back in, then all the placements would then refer to the same one loaded copy of that schematic (the holder or placement or whatever doesn't load it multiple times in this case if it's already in memory). So editing it again at that point (or if you just create multiple placements of one loaded schematic in the first place) would then affect all the placements.

But anyway, I will work on that persistent edits support in the main development code at some point. And I think I'll store a second schematic reference in the placement and set some flag to indicate that the placement has an edited schematic. Then there is also the second related design question of should "in-memory-only" schematics that are referenced by a placement also be automatically stored to a file, until the schematic is unloaded by the user... currently they just get wiped out on any dimension change or logout just like any other loaded schematics, and since they don't have any backing file, they are gone for good (just like any unsaved edited schematic changes).

commented

You can save the edited schematic from the Loaded Schematics list.

But as for making the edits persistent automatically, this is on my (very long) todo list. Hopefully some day I actually get to implementing it... I think it just needs to automatically save the edited schematic somewhere, and then replace the schematic reference in the placement to point to that edited copy until the changes are reverted/reloaded.

commented

Oh, cool!
Gonna be honest I got so mad when I accidentally entered the nether today and my heavily edited schematic got reset, so thats what got me to make this issue (and the parametrisation one goes hand-in-hand with that, cuz with that, the edits would not be necessary).
In fact I considered cloning the repo and looking if I could figure it out myself, but java is not my expertise (im a beatsaber modder mosly), so it wouldnt be good either way xD
Thanks for a great mod btw :)

commented

Yeah the way it works currently is that the SchematicHolder class that keeps the schematics that are currently loaded in memory will clear all of them when you leave a dimension, and when the placements for the dimension where you are going to get loaded those will then load their referenced schematics from file. So this means any edited schematics will get reset when you log out or change dimensions.

So it would need some logic added to handle edited schematics separately, automatically saving them somewhere and then modify the placements to reference those edited copies. And if the user clicks on Reload in the Loaded Schematics list, then it should delete that edited copy and revert back to the original schematic. Another option would be to just keep the edited copies in memory over dimension changes, but I don't know if that is really useful in any way as it wouldn't work for the case where the game is closed, so the separate saved copy method would still be needed anyway.

commented

Yah, so I gave it an honest try, I just cant wrap my head around the saving between dimensions. I might give it another try at some point, maybe ill figure it out some other day.
Thanks for the pointer to SchematicHolder btw, without that I would be completely lost. :)

Food for thought, would modifying the reference in the loaded schematic be necessary? You could just check if a schematic by that name exists in the temp directory and load that instead if it does (and also delete it after loading). That would solve the Reload button problem since the placement is not actually modified. And in case of multiple placements for a single schematic, just include some info in the filename of the temp file, since its temp anyway and storage is cheap I dont see an issue with keeping multiple copies of the same schematic... (and also the chance of two placements having the same modifications is quite low, since humans are humans)