mc-nbtac-mod icon indicating copy to clipboard operation
mc-nbtac-mod copied to clipboard

NBT Editor Integration / Questions

Open mega12345mega opened this issue 1 year ago • 3 comments

I'm the creator of the mod NBT Editor, and I was wondering if you would be interested in an integration. Multiple people have suggested including an autocomplete feature (Issue 31), but I haven't been sure of a good way to get at list of the possible tags (especially when accounting for different MC versions; I like to include everything in one jar file). I'm hoping you'll be able to answer some of my questions:

  • Based on the resources, it looks like this mod includes all the possible suggestions in it, rather than trying to query them from Minecraft itself at runtime. Is this auto-generated, or did you manually do this? If this was manual, does it include all of the possible tags, or just the most common ones?
  • Would you be interested in making the NBTEditorScreen's create and rename features include the same suggestions?
    • It is probably best if I add some sort of "suggestions callback" to the NBTEditorAPI to avoid complications and make code changes in the future easier to handle. Then you would use the API to easily add the suggestions. Unfortunately, I'm going to be going on a trip soon, so I won't be able to make API changes for the next couple weeks. We could always wait obviously.
    • I'm not sure if mixins can target another mod, but if they can, then you could mixin into the StringInputScreen and NBTEditorScreen#getKey (to determine if the string input is for a key) to supply suggestions. The NBTEditorScreen#path field shows the currently displayed "path"; for example: the value would be display/Lore if you were currently looking at the lore list. The format is non-standard, where everything is separated by a forward slash. This allows for opening SNBT (like display/Lore/0/extra, where the first line of lore is '{...,"extra":{~what is being viewed~}}').
    • I could try to access this mod's methods directly, though an API system is preferable. For this option, if you could point me in the correct direction as to which methods I would need to call to get the suggestions, that would be great!

Thanks!

mega12345mega avatar Jun 30 '23 02:06 mega12345mega

  • Answering your first question, only item NBTs are predefined in resources (I had to manually add them) as there isn't one method responsible for loading all tags for item. Entity and block entity tags are automatically loaded by disassembling methods responsible for loading tags (autocomplete/loader/typeloader). As disassembler isn't perfect and is only limited to reading tag's name and type, resources also contain "predictions" that are adding tags I found missing and more precise types like for example setting registry_key/minecraft:item subtype for id tag contained within tag ending with "Items" suffix.
  • As for mods integration I have plans to add better API in the next version (end of July at the earliest). Currently you can add this mod with Cursemaven and get suggestions using NbtSuggestionManager.get("entity/minecraft:creeper").getAll() (for items use "item/" prefix and for block entities "block/"). Also use Loader.finished.get() to check if it finished loading or just check for null from NbtSuggestionManager.get what I would recommend doing anyway.

mt1006 avatar Jun 30 '23 10:06 mt1006

I've now added this feature to my mod using NbtSuggestionManager.loadFromName. Thanks for the help! I appreciate not having to maintain a list of all the tag names myself :)

mega12345mega avatar Jan 26 '24 06:01 mega12345mega

Hi, generally sorry for not implementing dedicated API yet. I haven't had much time in last couple of month, as well as I was working on another projects. I still have plans to add API, but I don't know when it will be. I'm currently working on the version 1.2, which I plan to release next month, but there won't be any major changes to the code structure so it shouldn't break the compatibility with your mod. Although I planned to add an API in the 1.2, now I think it will be rather 1.3. Also, I will reopen this issue, as I think NBTac not having and API is still an issue.

mt1006 avatar Jan 26 '24 11:01 mt1006