diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/CompoundSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/CompoundSpell.java index 1c9a25eb..d4b8dfe3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/CompoundSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/CompoundSpell.java @@ -38,9 +38,8 @@ public class CompoundSpell extends AbstractDelegatingSpell { public void toNBT(NbtCompound compound) { super.toNBT(compound); NbtList spells = new NbtList(); - this.spells.forEach(spell -> { - spells.add(spell.toNBT()); - }); + this.spells.stream().map(SpellType::toNBT).forEach(spells::add); + compound.put("spells", spells); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java index 92e135f0..6b63a581 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java @@ -100,17 +100,19 @@ public class PlaceableSpell extends AbstractDelegatingSpell { compound.putString("dimension", dimension.toString()); } compound.put("castEntity", castEntity.toNBT()); + compound.put("spell", SpellType.toNBT(spell)); } @Override public void fromNBT(NbtCompound compound) { - super.toNBT(); + super.fromNBT(compound); if (compound.contains("dimension")) { dimension = new Identifier(compound.getString("dimension")); } if (compound.contains("castEntity")) { castEntity.fromNBT(compound.getCompound("castEntity")); } + spell = SpellType.fromNBT(compound.getCompound("spell")); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java index b9fe94cc..f826b28e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java @@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import net.minecraft.entity.LivingEntity; +import net.minecraft.nbt.NbtCompound; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.world.World; @@ -62,6 +63,18 @@ public class ThrowableSpell extends AbstractDelegatingSpell { return Optional.empty(); } + @Override + public void toNBT(NbtCompound compound) { + super.toNBT(compound); + compound.put("spell", SpellType.toNBT(spell)); + } + + @Override + public void fromNBT(NbtCompound compound) { + super.fromNBT(compound); + spell = SpellType.fromNBT(compound.getCompound("spell")); + } + @Override public ThrowableSpell toThrowable() { return this;