Add onInstalled and onUninstalled to Module
Vexatos opened this issue ยท 3 comments
Those methods would take the item stack used for installation / the itemstack you get back when uninstalling a module as a parameter. This would allow initializing from the stack's NBT data as well as writing own data back to the ItemStack for persistence.
For initialization I'd say ModuleProvider.createModule
is well enough suited (just grab the NBT from the stack provided there). Alternatively onEnable
(read on).
For saving what you'd probably really want is to write it back to the stack in onDisable
, so it's also saved on chunk unloads and such? At least that should be called there, too... I think. If it isn't yet I just forgot. So that plus I'll add IInventory
to the Casing
interface and that should be all you need, right?
Out of curiosity, what state do you want to store in the module's item stack? (Since they're ususally non-persistent / reset when the computer powers down I didn't really expect having to store data on their items.)
I do not have any intentions to use it just yet, I just thought it might be nice if you could make the module, in case something changes "physically", keep this state even when you uninstall it and install it in some other casing, since really only data should be reset, not "phyical changes to the module itself". Resetting that too on power loss if it doesn't even "use electricity" to happen would make no sense.