mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-20 03:44:23 +01:00
Fixed serialization of delegate spell types
This commit is contained in:
parent
7d830a3474
commit
9bb2818c2c
3 changed files with 18 additions and 4 deletions
|
@ -38,9 +38,8 @@ public class CompoundSpell extends AbstractDelegatingSpell {
|
||||||
public void toNBT(NbtCompound compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
NbtList spells = new NbtList();
|
NbtList spells = new NbtList();
|
||||||
this.spells.forEach(spell -> {
|
this.spells.stream().map(SpellType::toNBT).forEach(spells::add);
|
||||||
spells.add(spell.toNBT());
|
compound.put("spells", spells);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -100,17 +100,19 @@ public class PlaceableSpell extends AbstractDelegatingSpell {
|
||||||
compound.putString("dimension", dimension.toString());
|
compound.putString("dimension", dimension.toString());
|
||||||
}
|
}
|
||||||
compound.put("castEntity", castEntity.toNBT());
|
compound.put("castEntity", castEntity.toNBT());
|
||||||
|
compound.put("spell", SpellType.toNBT(spell));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(NbtCompound compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.toNBT();
|
super.fromNBT(compound);
|
||||||
if (compound.contains("dimension")) {
|
if (compound.contains("dimension")) {
|
||||||
dimension = new Identifier(compound.getString("dimension"));
|
dimension = new Identifier(compound.getString("dimension"));
|
||||||
}
|
}
|
||||||
if (compound.contains("castEntity")) {
|
if (compound.contains("castEntity")) {
|
||||||
castEntity.fromNBT(compound.getCompound("castEntity"));
|
castEntity.fromNBT(compound.getCompound("castEntity"));
|
||||||
}
|
}
|
||||||
|
spell = SpellType.fromNBT(compound.getCompound("spell"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -62,6 +63,18 @@ public class ThrowableSpell extends AbstractDelegatingSpell {
|
||||||
return Optional.empty();
|
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
|
@Override
|
||||||
public ThrowableSpell toThrowable() {
|
public ThrowableSpell toThrowable() {
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in a new issue