WorldsEnder Posted September 4, 2016 Share Posted September 4, 2016 I am porting a mod from 1.7.10 to 1.9. Previously I used a self-written WorldChunkManager that used the perWorldStorage to have some data associated with the world it is used for. But now (thank god) chunk manager are a thing of the past, and it's solved via WorldProviders, ISaveHandlers and IChunkGenerators. What I did previously to access the data, was (CustomChunkManagerClass) server.getWorldChunkManager() and then work with the custom instance. The question I have is, what is the simplest method to attach data to the world (must only be done on the server, I allocate some "building slots" and keep track of them on the server, that the client doesn't need to know of) that fulfills the following: 1) I can reliably save and load the data when the world gets loaded/unloaded 2) I can access the data when I have WorldServer instance Is there some sort of Capability system as there is for Entities, Items, etc...? Quote Link to comment Share on other sites More sharing options...
Choonster Posted September 4, 2016 Share Posted September 4, 2016 In 1.9.x, use World Saved Data. In 1.10.2, Forge has implemented World capabilities. Quote 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. Link to comment Share on other sites More sharing options...
WorldsEnder Posted September 4, 2016 Author Share Posted September 4, 2016 Okay, got it, so I write a static method inside the SaveData public static ExampleWorldSavedData retrieveFor(World world){ ExampleWorldSavedData instance = (ExampleWorldSavedData) world.getPerWorldStorage().loadData(ExampleWorldSavedData.class, DATA_NAME); if (instance == null) { instance = new ExampleWorldSavedData(); storage.setData(DATA_NAME, instance); } } for now and use Capabilities in 1.10.2 Quote Link to comment Share on other sites More sharing options...
Choonster Posted September 4, 2016 Share Posted September 4, 2016 Okay, got it, so I write a static method inside the SaveData public static ExampleWorldSavedData retrieveFor(World world){ ExampleWorldSavedData instance = (ExampleWorldSavedData) world.getPerWorldStorage().loadData(ExampleWorldSavedData.class, DATA_NAME); if (instance == null) { instance = new ExampleWorldSavedData(); storage.setData(DATA_NAME, instance); } } for now and use Capabilities in 1.10.2 That's correct. Quote 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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.