eclipseisoffline / bookcopy

This mod adds a simple client-side /bookcopy command, which allows you to save written books and import them later in another book.
https://modrinth.com/mod/book-copy
GNU General Public License v3.0
2 stars 1 forks source link

[IMPLEMENTED] JSON Format Support #4

Open wiskiw opened 1 week ago

wiskiw commented 1 week ago

Hey, I forked the project to add JSON support, but it went a bit further than planned. You can check out the repo.

Problem to solve: I wanted to use the JSON format to create or modify books outside of Minecraft using a plain text editor.

Solution: I added JSON format support while retaining the option to import/export in the original NBT format. You can check the updated README.

I don't have any plans to support my fork or upload it to CurseForge or elsewhere, but I think it might be useful for other people. The implementation required some refactoring, but now it should be easier to maintain and to add new data formats in the future. If you'd like, I can open a PR to your repository.

best.

eclipseisoffline commented 1 week ago

Hi, this is pretty cool!

I've been thinking about adding support for JSON and the Stendhal format for a while now, but haven't had the time to get to it. I'm hoping to add support for it this week though. I'll probably change to using Mojang's codecs system for serialization as this makes it easy to switch between JSON and NBT - I might have to figure out how to get the Stendhal format working with it though. Might require an additional abstraction layer.

Additionally, I've also been thinking about adding a feature to read from commands generated by sites like these, converting the text components into strings with legacy formatting codes, and then writing to a book - this would make it easier to use formatting codes in books, as users can use 3rd-party sites to easily design a book and just copy it straight into game, without mods on the server. This is definitely a future plan for now though, until I have time to get to it.

I like the auto sign option you added as well! I'm not fluent in coding with Kotlin, and generally prefer Java for mod coding as it doesn't require an additional dependency and integrates better with the game at times, so a PR probably wouldn't work well. However, I could copy the idea, and give proper credit in the README, if you were to be okay with that?

wiskiw commented 1 week ago

Hi again I like your idea of adding other formats. It can definitely be useful. And I would like to participate. The only issue stopping me from making a small, clean pull request is the lack of abstraction for import/export implementations. If you could add that, it would be very helpful for other devs to contribute. Respectfully.

Regarding this PR, of course you can take whatever you need from my repo, feel free to copy-paste if you need to :) And sorry about Kotlin, I haven't used Java for the last 4 years. And it is a bit painful to get back to it since I start using Kotlin.😅

Stendhal - is the reason why I found your mod. In Stendhal exporting and importing the same file doesn't work as expected. It wasn't usable at all for me. So be careful if you decide to add Stendhal format support, it may lead to unexpected bugs.

To sum up, I'd like to contribute (even with Java). And I have some spare time rn. So feel free to contact me if you need any help. Best.

PS. You can close this pr if you dont need it.