SleepyTrousers / EnderCore

Library mod used by EnderIO, EnderZoo, and others
Creative Commons Zero v1.0 Universal
50 stars 71 forks source link

Ported annotation-based NBT handling #34

Open HenryLoenwind opened 8 years ago

HenryLoenwind commented 8 years ago

This is what I've been using in Ender IO Addon for ages. No changes other than Java 1.6 and Minecraft 1.8.9 compatibility and a different package name.

The changes to the TileEntity are a bit different because we don't need compatibility with an existing Ender IO class hierarchy. It may need some changes once we port over classes that actually use it.

In a nutshell: There are no callbacks for world saving/loading and description packet handling anymore. Instead fields that should be saved are annotated (see EIOA for examples). There are two tool methods to read/write data from/to an item's NBT. A subclass that wants to do that, needs to call them.

CrazyPants commented 8 years ago

one quick question, is ti still easy to add special NBT handling code? The situation I am thinking of is migrating a change in TEs. In the past when I have changed a field, added new ones etc, I have added code that would read the old tags and transform them into the new object.

HenryLoenwind commented 8 years ago

yes, it is. For one, that "final" on those methods doesn't mean we cannot add a new "handleMigrateNbt()" call to the read methods (I put the final there to help us not miss a method when migrating), and on the other hand we can easily add handlers for specific TEs.

And in general, do we really expect people to migrate their modded 1.7.10 worlds to 1.8.9?

kylev commented 7 years ago

Is this still viable in 1.10.2?

HenryLoenwind commented 7 years ago

This has been put into Ender IO during porting to 1.8.9 and is in use there.