<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://forge.gemwire.uk/index.php?action=history&amp;feed=atom&amp;title=Saved_Data%2F1.18</id>
	<title>Saved Data/1.18 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://forge.gemwire.uk/index.php?action=history&amp;feed=atom&amp;title=Saved_Data%2F1.18"/>
	<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=Saved_Data/1.18&amp;action=history"/>
	<updated>2026-05-22T23:36:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=Saved_Data/1.18&amp;diff=3218&amp;oldid=prev</id>
		<title>ShrimpBot: Copy Saved Data to MC1.18 archive</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=Saved_Data/1.18&amp;diff=3218&amp;oldid=prev"/>
		<updated>2022-06-10T07:45:44Z</updated>

		<summary type="html">&lt;p&gt;Copy &lt;a href=&quot;/wiki/Saved_Data&quot; title=&quot;Saved Data&quot;&gt;Saved Data&lt;/a&gt; to MC1.18 archive&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;code&amp;gt;SavedData&amp;lt;/code&amp;gt; is an alternative to capabilities that stores data per dimension or globally depending on how the context is passed.&lt;br /&gt;
&lt;br /&gt;
==Class Structure==&lt;br /&gt;
&lt;br /&gt;
The class can be broken down into two important methods:&lt;br /&gt;
 - &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt;: Write the data to nbt.&lt;br /&gt;
 - &amp;lt;code&amp;gt;setDirty&amp;lt;/code&amp;gt;: Tell the game that the data has changed and needs to be saved to file.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; method need to be implemented while &amp;lt;code&amp;gt;setDirty&amp;lt;/code&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
==Attaching to a Level ==&lt;br /&gt;
&lt;br /&gt;
To attach a Saved Data to a particular level, you must have access to an instance of &amp;lt;code&amp;gt;ServerLevel&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ServerChunkCache&amp;lt;/code&amp;gt;. From there, you can call the method &amp;lt;code&amp;gt;#getSavedData&amp;lt;/code&amp;gt; which will give you an instance of the &amp;lt;code&amp;gt;DimensionDataStorage&amp;lt;/code&amp;gt;: 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 &amp;lt;code&amp;gt;DimensionDataStorage#computeIfAbsent&amp;lt;/code&amp;gt;. This takes in three arguments: the first to construct a saved data with data already existing in some &amp;lt;code&amp;gt;CompoundTag&amp;lt;/code&amp;gt;, the second to construct a saved data with no existing data, and the third to specify the name of the file to save the data to within the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; folder in the overworld or in the specific dimension of the save.&lt;br /&gt;
&lt;br /&gt;
Global attachments are the same except that they should only be attached to the overworld as that level will always persist.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Data Storage/1.18|Category:Data Storage]]&lt;/div&gt;</summary>
		<author><name>ShrimpBot</name></author>
	</entry>
</feed>