-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caa8f0e
commit 1fedf19
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
``` |