-
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.
Differnet way to save persistent data
- Loading branch information
1 parent
53c66dc
commit 8ede4bb
Showing
3 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/java/net/miavalley/roughleaderboards/mixin/ModEntityDataSaverMixin.java
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,21 @@ | ||
package net.miavalley.roughleaderboards.mixin; | ||
|
||
|
||
import net.miavalley.roughleaderboards.util.IEntityDataSaver; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.nbt.NbtCompound; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(Entity.class) | ||
public abstract class ModEntityDataSaverMixin implements IEntityDataSaver { | ||
private NbtCompound persistentData; | ||
|
||
|
||
@Override | ||
public NbtCompound getPersistentData() { | ||
if (this.persistentData == null) { | ||
this.persistentData = new NbtCompound(); | ||
} | ||
return persistentData; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/net/miavalley/roughleaderboards/util/IEntityDataSaver.java
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,7 @@ | ||
package net.miavalley.roughleaderboards.util; | ||
|
||
import net.minecraft.nbt.NbtCompound; | ||
|
||
public interface IEntityDataSaver { | ||
NbtCompound getPersistentData(); | ||
} |