From 02dc0affcb47887ffed1ece31339ab47f943437f Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 8 Oct 2020 17:06:36 +0200 Subject: [PATCH] Some minor touchups, and use the race's affinity for the player's caster --- .../unicopia/ability/magic/Affine.java | 1 - .../unicopia/entity/player/Motion.java | 2 +- .../minelittlepony/unicopia/entity/player/Pony.java | 12 +++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/Affine.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/Affine.java index 39810977..03d829e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/Affine.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/Affine.java @@ -12,7 +12,6 @@ public interface Affine { */ Affinity getAffinity(); - default boolean isEnemy(Affine other) { return !getAffinity().alignsWith(other.getAffinity()); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java index 0b99d5ab..72f70b3f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java @@ -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(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index 660eb56c..51757b3a 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -158,7 +158,7 @@ public class Pony implements Caster, Equine, Transmi @Override public Affinity getAffinity() { - return Affinity.NEUTRAL; + return getSpecies().getAffinity(); } public void setDirty() { @@ -384,12 +384,10 @@ public class Pony implements Caster, Equine, Transmi } public Optional 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) {