diff --git a/docs/storage/getting-started/creating-a-storage.md b/docs/storage/getting-started/creating-a-storage.md new file mode 100644 index 00000000..fe62b231 --- /dev/null +++ b/docs/storage/getting-started/creating-a-storage.md @@ -0,0 +1,27 @@ +# Creating a custom Storage + +Creating a custom Storage is fairly simple. All you need is to create a class that extends the `Storage` class and +implement the required methods. +```java +public static class ExampleStorage extends Storage { + private int exampleInt = 0; + + public ExampleStorage(StorageHolder holder) { + super(holder); + } + + @Override + public void save(CompoundTag data) { + data.putInt("exampleInt", exampleInt); + } + + @Override + public void load(CompoundTag data) { + exampleInt = data.getInt("exampleInt"); + } + + public int getExampleInt() { + return exampleInt; + } +} +```