Jump to content

[1.10.2] Any real need to convert working NBT system to Capabilities?


Recommended Posts

Posted

This question is about updating my mods from older versions. In most of my mods, I essentially created my own "capability" interfaces that directly worked with the NBT data (for entities, itemstacks, tileentities, etc.). The important point is I typically did this only for my own custom stuff -- I was not trying to add data to vanilla or other mod objects. My interface included saving and loading as well as syncing with client via custom packets. So it is a working system.

 

Now I'm going through the chore of upgrading all my mods to 1.10.2. At first I read a lot about the capability system and then realized it pretty much does the same thing as my NBT-based custom interfaces.

 

Is there any good reason that when upgrading I should convert my system to the new capability system? It seems like a lot of work that is likely unnecessary if I have a working NBT system already...

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Once you have got the basics down for the Capability stuff, it is actually just really easy.

As diesieben07 said, nbt is clunky and shouldn't be used for runtime storage.

 

so yes, upgrading is the best option.

 

some aid if needed : Read The Docs : Capabilities

 

Good luck. It will be a chore, but in the end, the compatibilty with other mods, and ease of updating to latter versions will be easier !

Posted

Thanks, I guess I'll try. I am of course planning to use Capability for new mods, but I just find updating mods quite a chore in general. Even the simplest things, like having constant fields renamed in all-caps can take quite a while to update if you used them extensively, and the more fundamental changes (like moving events to common bus) take a while to work through. Takes me about a week of evenings after work to update each mod and I've got half a dozen mods so it is usually a couple months duration to get everything working. So I'm interested in minimizing updating unless forced to do it...

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Use your IDE's refactor tools.  Eclipse and IntelliJ should both be smart enough to update all of those references at once.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Hi.

 

I started reading up about Capabilities at this page but even after a few readings I'm still struggling to understand the big picture let alone the details.

http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

 

Before I try to reverse engineer it from the forge code, does anyone have some good example code showing Capabilities they have used and/or implemented?  Preferably one I could patch into MinecraftByExample as well?

 

-TGG

 

 

Posted

Hi.

 

I started reading up about Capabilities at this page but even after a few readings I'm still struggling to understand the big picture let alone the details.

http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

 

Before I try to reverse engineer it from the forge code, does anyone have some good example code showing Capabilities they have used and/or implemented?  Preferably one I could patch into MinecraftByExample as well?

 

-TGG

 

There are some examples linked in this thread.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Hi.

 

I started reading up about Capabilities at this page but even after a few readings I'm still struggling to understand the big picture let alone the details.

http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

 

Before I try to reverse engineer it from the forge code, does anyone have some good example code showing Capabilities they have used and/or implemented?  Preferably one I could patch into MinecraftByExample as well?

 

-TGG

 

There are some:

 

I also have written a tutorial on PMC about capabilities.

Blockbuster – simple machinimas and cinematics for Minecraft
Posted

Use your IDE's refactor tools.  Eclipse and IntelliJ should both be smart enough to update all of those references at once.

 

I do do that, but I mean lets say I have recipes that use Items.leather, Items.iron_ingot, etc. and have almost all the items in the game somewhere in my code. I refactor each one (Items.leather to Items.LEATHER) and so forth but it is still quite a bit of work -- select it, call up refactor window, type in the new one, ignore the warning about refactoring when there are errors (when updating you have a lot of errors that can impact easy refactoring), then repeat another 50 times. It literally can take hours.

 

Or do you mean there is some easy way to change all the Items fields to refactor at once?

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Use your IDE's refactor tools.  Eclipse and IntelliJ should both be smart enough to update all of those references at once.

 

I do do that, but I mean lets say I have recipes that use Items.leather, Items.iron_ingot, etc. and have almost all the items in the game somewhere in my code. I refactor each one (Items.leather to Items.LEATHER) and so forth but it is still quite a bit of work -- select it, call up refactor window, type in the new one, ignore the warning about refactoring when there are errors (when updating you have a lot of errors that can impact easy refactoring), then repeat another 50 times. It literally can take hours.

 

Or do you mean there is some easy way to change all the Items fields to refactor at once?

 

 

I fixed that issue using Notepad++'s Find in All files feature & regex. Open Notepad++ and press Ctrl+Shift+F to open the Find in All Files dialog. Set it to regular expression mode and set the directory to your mod's src folder. Use the regexes in this gist and click Replace in Files.

I recommend making a backup of your source before you run the regex in case it hits an edge case and does something odd. The worst thing it can do is capitalise a single word that comes after a target.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.