Some minor touchups, and use the race's affinity for the player's caster

This commit is contained in:
Sollace 2020-10-08 17:06:36 +02:00
parent 05dc1aa132
commit 02dc0affcb
3 changed files with 6 additions and 9 deletions

View file

@ -12,7 +12,6 @@ public interface Affine {
*/
Affinity getAffinity();
default boolean isEnemy(Affine other) {
return !getAffinity().alignsWith(other.getAffinity());
}

View file

@ -5,7 +5,7 @@ package com.minelittlepony.unicopia.entity.player;
*/
public interface Motion {
/**
* True is we're currently flying.
* True if we're currently flying.
*/
boolean isFlying();

View file

@ -158,7 +158,7 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
@Override
public Affinity getAffinity() {
return Affinity.NEUTRAL;
return getSpecies().getAffinity();
}
public void setDirty() {
@ -384,12 +384,10 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
}
public Optional<Text> trySleep(BlockPos pos) {
if (findAllSpellsInRange(10).filter(p -> p instanceof Pony).map(Pony.class::cast).map(Pony::getSpecies).anyMatch(r -> r.isEnemy(getSpecies()))) {
return Optional.of(new TranslatableText("block.unicopia.bed.not_safe"));
}
return Optional.empty();
return findAllSpellsInRange(10)
.filter(p -> p instanceof Pony && ((Pony)p).isEnemy(this))
.findFirst()
.map(p -> new TranslatableText("block.unicopia.bed.not_safe"));
}
public void onEat(ItemStack stack) {