Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit a88e57a

Browse files
authored
PersistentState implements INBTSerializable (#117)
1 parent 6bee13c commit a88e57a

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Minecraft Forge, Patchwork Project
3+
* Copyright (c) 2016-2020, 2019-2020
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation version 2.1
8+
* of the License.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
package net.patchworkmc.mixin.capability;
21+
22+
import org.spongepowered.asm.mixin.Mixin;
23+
import net.minecraftforge.common.util.INBTSerializable;
24+
25+
import net.minecraft.nbt.CompoundTag;
26+
import net.minecraft.world.PersistentState;
27+
28+
@Mixin(PersistentState.class)
29+
public class PersistentStateMixin implements INBTSerializable<CompoundTag> {
30+
@Override
31+
public void deserializeNBT(CompoundTag nbt) {
32+
((PersistentState) (Object) this).fromTag(nbt);
33+
}
34+
35+
@Override
36+
public CompoundTag serializeNBT() {
37+
return ((PersistentState) (Object) this).toTag(new CompoundTag());
38+
}
39+
}

patchwork-capabilities/src/main/resources/patchwork-capabilities.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"EntityMixin",
99
"ItemEntityMixin",
1010
"ItemStackMixin",
11+
"PersistentStateMixin",
1112
"ServerWorldMixin",
1213
"WorldChunkMixin",
1314
"WorldMixin"

0 commit comments

Comments
 (0)