Changes

1,765 bytes added ,  06:45, 20 December 2020
Basic WSD Explanation
World Saved Data is an alternative to capabilities that stores data per dimension or globally depending on how the context is passed.

==Class Structure==

The class can be broken down into three important methods:
- <code>read</code>: Read the stored nbt data.
- <code>write</code>: Write the object to nbt.
- <code>markDirty</code>: Tell the object to save the data to file.

The <code>read</code> and <code>write</code> methods need to be implemented while <code>markDirty</code> should be called whenever the data is going to be manipulated. As the class is abstract, it should be subclassed with these three methods implemented.

The super call requires a <code>String</code> argument. This is used to denote the name of the data file within the dimension itself. For example, if the argument was "pipes", then a file would be created within each dimension folder called <code>data/pipes.dat</code>.

==Attaching to a Dimension==

To attach a World Saved Data to a particular dimension, you must have access to an instance of <code>ServerWorld</code> or <code>ServerChunkProvider</code>. From there, you can call the method <code>#getSavedData</code> which will give you an instance of the <code>DimensionSavedDataManager</code>: the class that stores all saved data for that particular dimension. You can attach an instance or get the current instance of the data using <code>DimensionSavedDataManager#getOrCreate</code>. This should be used in most cases to get an instance of the specified data or create a new one if not available. From there, you can operate on your saved data as if it was a capability.

Global attachments are the same by either synchronizing the data between the three worlds or using the same object reference stored in each world.