Closed DashFury closed 9 years ago
After further testing, it appears that the crates are actually completely unusable in those dimensions, as they won't even be saved when the dimension is unloaded. Restarting the server and trying to access those crates will throw another exception: java.lang.ArithmeticException: / by zero
similar to this issue.
Weird, I wonder why this has only been reported now. Every crate pile is saved to an individual <dim>/data/crates/<id>.dat
file. This is just how I got the dimension's folder at the time. There probably is a better way (I assume villages work, they use the same folder afaik).
I'd like to have a try at fixing this, but I stopped modding - I don't even have Java or an IDE installed - and the only way I could imagine to come back to it is by starting from scratch. Crates would really need to be redone.
Maybe @Victorious3 or one of the other guys would like to have a stab at it?
I don't know if crates needs to be redone, but your implementation seems fine by me.
As far as I can tell, it's just a matter of casting on the interface and not the class. Everything's alright in dimensions that use the default SaveHandler instead of declaring their own. Casting on ISaveHandler
would make it work with everything.
Isn't it already ISaveHandler? And that is lacking getWorldDirectory() afair.
Currently, it's just SaveHandler, as you can see from the CratePileCollection file:
File saveFolder = ((SaveHandler)world.getSaveHandler()).getWorldDirectory();
getWorldDirectory()
shouldn't be a problem, it's declared in the interface too :)
I could swear it wasn't when I first wrote that.
Hmm... It seems like a simple fix, so I'm going to fix it.
Nice :)
Thanks, @skyem123 and @Victorious3 :heart:
Does this fix the issue?
Yes :D
Thanks to all of you!
When breaking a storage crate in a dimension created by ForgeEssentials with its Multiworld module, the following exception is thrown:
If the broken crate is also the only one of a crate group, meaning that the inventory will be deleted, the client crash when playing in single player, or is disconnected from the server in multiplayer. When reconnecting, the crate is deleted, but its inventory and the crate itself aren't dropped on the ground.
This is the line throwing the exception:
ForgeEssentials's
MultiworldSaveHandler
implementsISaveHandler
and notSaveHandler
. SinceSaveHandler
also implementsISaveHandler
, and sincegetSaveHandler()
is declared inISaveHandler
, BetterStorage should cast to the interface and not the classes that implements it.This has been tested with BetterStorage 0.13.1.126, ForgeEssentials 1.4.3.1012 and Forge 10.13.4.1517.
Stacktrace: