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(); Affinity getAffinity();
default boolean isEnemy(Affine other) { default boolean isEnemy(Affine other) {
return !getAffinity().alignsWith(other.getAffinity()); return !getAffinity().alignsWith(other.getAffinity());
} }

View file

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

View file

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