From efc50c5cbd3a46013d5e2d4004cbe869d137fee0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 23 Sep 2020 17:19:28 +0200 Subject: [PATCH] Races now have an affinity --- .../unicopia/{ability/magic => }/Affinity.java | 6 +++++- src/main/java/com/minelittlepony/unicopia/Race.java | 9 +++++++-- .../minelittlepony/unicopia/ability/magic/Affine.java | 7 +++++++ .../unicopia/ability/magic/ThrowableSpell.java | 1 + .../unicopia/ability/magic/spell/AttractiveSpell.java | 2 +- .../unicopia/ability/magic/spell/AwkwardSpell.java | 2 +- .../unicopia/ability/magic/spell/DisguiseSpell.java | 2 +- .../unicopia/ability/magic/spell/FireSpell.java | 2 +- .../unicopia/ability/magic/spell/GenericSpell.java | 2 +- .../unicopia/ability/magic/spell/IceSpell.java | 2 +- .../unicopia/ability/magic/spell/InfernoSpell.java | 2 +- .../unicopia/ability/magic/spell/NecromancySpell.java | 2 +- .../unicopia/ability/magic/spell/RevealingSpell.java | 2 +- .../unicopia/ability/magic/spell/ScorchSpell.java | 2 +- .../unicopia/ability/magic/spell/ShieldSpell.java | 2 +- .../unicopia/ability/magic/spell/SiphoningSpell.java | 2 +- .../unicopia/ability/magic/spell/SpellRegistry.java | 2 +- .../unicopia/client/gui/SettingsScreen.java | 2 +- .../com/minelittlepony/unicopia/entity/Creature.java | 2 +- .../com/minelittlepony/unicopia/entity/player/Pony.java | 2 +- .../unicopia/projectile/MagicProjectileEntity.java | 2 +- 21 files changed, 37 insertions(+), 20 deletions(-) rename src/main/java/com/minelittlepony/unicopia/{ability/magic => }/Affinity.java (90%) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/Affinity.java b/src/main/java/com/minelittlepony/unicopia/Affinity.java similarity index 90% rename from src/main/java/com/minelittlepony/unicopia/ability/magic/Affinity.java rename to src/main/java/com/minelittlepony/unicopia/Affinity.java index 6bc2aea9..9bda0a1a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/Affinity.java +++ b/src/main/java/com/minelittlepony/unicopia/Affinity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.ability.magic; +package com.minelittlepony.unicopia; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; @@ -40,6 +40,10 @@ public enum Affinity { return this == NEUTRAL; } + public boolean alignsWith(Affinity other) { + return isNeutral() || other.isNeutral() || this == other; + } + public Affinity[] getImplicators() { if (implications != null) { return implications; diff --git a/src/main/java/com/minelittlepony/unicopia/Race.java b/src/main/java/com/minelittlepony/unicopia/Race.java index bcf0f2f9..c558981a 100644 --- a/src/main/java/com/minelittlepony/unicopia/Race.java +++ b/src/main/java/com/minelittlepony/unicopia/Race.java @@ -7,10 +7,11 @@ import java.util.function.Function; import java.util.stream.Collectors; import com.google.common.base.Strings; +import com.minelittlepony.unicopia.ability.magic.Affine; import net.minecraft.entity.player.PlayerEntity; -public enum Race { +public enum Race implements Affine { /** * The default, unset race. * This is used if there are no other races. @@ -35,6 +36,11 @@ public enum Race { this.earth = earth; } + @Override + public Affinity getAffinity() { + return this == CHANGELING ? Affinity.BAD : Affinity.NEUTRAL; + } + public boolean hasIronGut() { return isUsable() && this != CHANGELING; } @@ -71,7 +77,6 @@ public enum Race { return String.format("unicopia.race.%s", name().toLowerCase()); } - public boolean isPermitted(PlayerEntity sender) { if (isOp() && (sender == null || !sender.abilities.creativeMode)) { return false; 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 d6fe1da0..39810977 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/Affine.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/Affine.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.ability.magic; +import com.minelittlepony.unicopia.Affinity; + /** * Interface for things that have an affine alignment. */ @@ -9,4 +11,9 @@ public interface Affine { * Good/Bad/Neutral */ Affinity getAffinity(); + + + default boolean isEnemy(Affine other) { + return !getAffinity().alignsWith(other.getAffinity()); + } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/ThrowableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/ThrowableSpell.java index fd17459a..46371197 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/ThrowableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/ThrowableSpell.java @@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.ability.magic; import javax.annotation.Nullable; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.UEntities; import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java index 15ec58aa..d7ee95d7 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java @@ -5,7 +5,7 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.particle.MagicParticleEffect; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AwkwardSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AwkwardSpell.java index e32b9850..5a2860cd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AwkwardSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AwkwardSpell.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.ArrayList; import java.util.List; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.ThrowableSpell; import com.minelittlepony.unicopia.util.shape.Sphere; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java index bf665f5c..4a5ee62b 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java @@ -5,12 +5,12 @@ import java.util.UUID; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.InteractionManager; import com.minelittlepony.unicopia.Owned; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.FlightPredicate; import com.minelittlepony.unicopia.ability.HeightPredicate; -import com.minelittlepony.unicopia.ability.magic.Affinity; import com.minelittlepony.unicopia.ability.magic.AttachableSpell; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.CasterUtils; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/FireSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/FireSpell.java index 685a43ec..f4c1e716 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/FireSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/FireSpell.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia.ability.magic.spell; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.ability.magic.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Magical; import com.minelittlepony.unicopia.block.state.StateMaps; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/GenericSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/GenericSpell.java index f7293849..ab6cfbdf 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/GenericSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/GenericSpell.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.function.Supplier; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; import com.minelittlepony.unicopia.particle.MagicParticleEffect; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java index f695c09e..7bc93eab 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.magic.spell; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.block.state.StateMaps; import com.minelittlepony.unicopia.util.MagicalDamageSource; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/InfernoSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/InfernoSpell.java index df1a2189..2c2d058d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/InfernoSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/InfernoSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.magic.spell; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.block.state.StateMaps; import com.minelittlepony.unicopia.util.MagicalDamageSource; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java index 5ff49b04..b7c8f8a2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.List; import com.google.common.collect.Lists; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.WorldEvent; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RevealingSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RevealingSpell.java index e2945a29..d76f8b3d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RevealingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RevealingSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.magic.spell; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Suppressable; import com.minelittlepony.unicopia.particle.MagicParticleEffect; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java index 0280941f..37ba9fc5 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic.spell; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.ThrowableSpell; import com.minelittlepony.unicopia.block.state.StateMaps; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java index 2d0049c7..f0c2e359 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java @@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.List; import java.util.stream.Collectors; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.ability.magic.Affinity; import com.minelittlepony.unicopia.ability.magic.AttachableSpell; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.entity.player.Pony; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java index 1e0feea2..a19cb0fd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java @@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.List; import java.util.stream.Collectors; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.ability.magic.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.util.MagicalDamageSource; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellRegistry.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellRegistry.java index 0254e2a7..4560af2e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellRegistry.java @@ -10,7 +10,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Spell; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java index 97a5c51b..43328d6b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java @@ -18,7 +18,7 @@ public class SettingsScreen extends GameGui { addButton(new Label(width / 2, 15)) .getStyle() .setColor(16777215) - .setText(title.asString()); + .setText(title); addButton(new Button(width / 2 - 100, height / 6 + 168)) .onClick(s -> finish()) .getStyle().setText("gui.done"); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java index 2c59953f..d1d88008 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java @@ -1,8 +1,8 @@ package com.minelittlepony.unicopia.entity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.magic.Affine; -import com.minelittlepony.unicopia.ability.magic.Affinity; import com.minelittlepony.unicopia.ability.magic.AttachableSpell; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; 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 0ea10c9b..f54b40b3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -2,10 +2,10 @@ package com.minelittlepony.unicopia.entity.player; import javax.annotation.Nullable; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.InteractionManager; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.AbilityDispatcher; -import com.minelittlepony.unicopia.ability.magic.Affinity; import com.minelittlepony.unicopia.ability.magic.AttachableSpell; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java index f757cc96..04b80eb1 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.projectile; import java.util.UUID; -import com.minelittlepony.unicopia.ability.magic.Affinity; +import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Magical; import com.minelittlepony.unicopia.ability.magic.Spell;