Skip to content

Commit

Permalink
add creating-a-storage.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Charismara committed Aug 29, 2024
1 parent caa8f0e commit 1fedf19
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/storage/getting-started/creating-a-storage.md
Original file line number Diff line number Diff line change
@@ -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;
}
}
```

0 comments on commit 1fedf19

Please sign in to comment.