diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java index 3ec4a475..54b86b36 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java @@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.*; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.entity.EntityReference; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.particle.FollowingParticleEffect; import com.minelittlepony.unicopia.particle.MagicParticleEffect; import com.minelittlepony.unicopia.particle.UParticles; @@ -120,6 +121,7 @@ public class AttractiveSpell extends ShieldSpell implements ProjectileSpell, Hom } } target.setVelocity(x, y, z); + Living.updateVelocity(target); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index bf3acdb3..16f80ecb 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -125,7 +125,7 @@ public class UHud extends DrawableHelper { matrices.pop(); - if (pony.getSpecies().canCast()) { + if (pony.getActualSpecies().canCast()) { renderSpell(pony.getCharms().getEquippedSpell(Hand.MAIN_HAND), hudX + 15 - xDirection * 13, hudY + 3); renderSpell(pony.getCharms().getEquippedSpell(Hand.OFF_HAND), hudX + 15 - xDirection * 2, hudY - 3); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityAppearance.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityAppearance.java index 6284ab2a..0fd3de46 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityAppearance.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityAppearance.java @@ -348,14 +348,19 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi entityNbt.putString("playerName", profile.getName()); entityNbt.putByte("playerVisibleParts", player.getDataTracker().get(Disguise.PlayerAccess.getModelBitFlag())); - NbtCompound playerNbt = player.writeNbt(new NbtCompound()); - playerNbt.remove("unicopia_caster"); - entityNbt.put("playerNbt", playerNbt); - } else { - entity.saveSelfNbt(entityNbt); - entityNbt.remove("unicopia_caster"); + return NbtSerialisable.subTag("playerNbt", entityNbt, playerNbt -> { + player.writeNbt(playerNbt); + playerNbt.remove("unicopia_caster"); + Pony pony = Pony.of(player); + if (pony != null) { + NbtSerialisable.subTag("unicopia_caster", playerNbt, pony::toSyncronisedNbt); + } + }); } + entity.saveSelfNbt(entityNbt); + entityNbt.remove("unicopia_caster"); + return entityNbt; } diff --git a/src/main/java/com/minelittlepony/unicopia/util/NbtSerialisable.java b/src/main/java/com/minelittlepony/unicopia/util/NbtSerialisable.java index c978dd6c..7f40eb69 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/NbtSerialisable.java +++ b/src/main/java/com/minelittlepony/unicopia/util/NbtSerialisable.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia.util; import java.util.*; -import java.util.function.Function; +import java.util.function.*; import java.util.stream.Stream; import com.mojang.datafixers.util.Pair; @@ -54,6 +54,17 @@ public interface NbtSerialisable { return codec.encodeStart(NbtOps.INSTANCE, value).result().get(); } + static NbtCompound subTag(String name, NbtCompound parent) { + NbtCompound child = new NbtCompound(); + parent.put(name, child); + return child; + } + + static NbtCompound subTag(String name, NbtCompound parent, Consumer writer) { + writer.accept(subTag(name, parent)); + return parent; + } + interface Serializer { T read(NbtCompound compound); @@ -83,6 +94,14 @@ public interface NbtSerialisable { return list.stream().map(this::read).filter(Objects::nonNull); } + static Serializer of(Supplier factory) { + return of(nbt -> { + T value = factory.get(); + value.fromNBT(nbt); + return value; + }, value -> value.toNBT()); + } + static Serializer of(Function read, Function write) { return new Serializer<>() { @Override