mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
When switching bodies you will now inherit the race and abilities of whoever you switch with
This commit is contained in:
parent
9a19ed36c1
commit
8b38c54df0
4 changed files with 34 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<NbtCompound> writer) {
|
||||
writer.accept(subTag(name, parent));
|
||||
return parent;
|
||||
}
|
||||
|
||||
interface Serializer<T> {
|
||||
T read(NbtCompound compound);
|
||||
|
||||
|
@ -83,6 +94,14 @@ public interface NbtSerialisable {
|
|||
return list.stream().map(this::read).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
static <T extends NbtSerialisable> Serializer<T> of(Supplier<T> factory) {
|
||||
return of(nbt -> {
|
||||
T value = factory.get();
|
||||
value.fromNBT(nbt);
|
||||
return value;
|
||||
}, value -> value.toNBT());
|
||||
}
|
||||
|
||||
static <T> Serializer<T> of(Function<NbtCompound, T> read, Function<T, NbtCompound> write) {
|
||||
return new Serializer<>() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue