Move ability assignment to the races

This commit is contained in:
Sollace 2024-04-08 20:45:46 +01:00
parent 281e2ba26d
commit 4cb06bcc92
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
27 changed files with 217 additions and 200 deletions

View file

@ -1,12 +1,17 @@
package com.minelittlepony.unicopia;
import net.minecraft.util.Formatting;
import java.util.Locale;
public enum Affinity {
import net.minecraft.util.Formatting;
import net.minecraft.util.StringIdentifiable;
public enum Affinity implements StringIdentifiable {
GOOD(Formatting.BLUE, -1, 0),
NEUTRAL(Formatting.LIGHT_PURPLE, 0, 0.5F),
BAD(Formatting.RED, 1, 1);
public static final Codec<Affinity> CODEC = StringIdentifiable.createCodec(Affinity::values);
private final Formatting color;
private final int corruption;
@ -20,6 +25,11 @@ public enum Affinity {
this.alignment = alignment;
}
@Override
public String asString() {
return name().toLowerCase(Locale.ROOT);
}
public Formatting getColor() {
return color;
}

View file

@ -1,10 +1,23 @@
package com.minelittlepony.unicopia;
public enum Availability {
import java.util.Locale;
import net.minecraft.util.StringIdentifiable;
public enum Availability implements StringIdentifiable {
DEFAULT,
COMMANDS,
NONE;
public static final Codec<Availability> CODEC = StringIdentifiable.createCodec(Availability::values);
private final String name = name().toLowerCase(Locale.ROOT);
@Override
public String asString() {
return name;
}
public boolean isSelectable() {
return this == DEFAULT;
}

View file

@ -1,15 +1,27 @@
package com.minelittlepony.unicopia;
import java.util.Locale;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.StringIdentifiable;
public enum FlightType {
public enum FlightType implements StringIdentifiable {
UNSET,
NONE,
AVIAN,
INSECTOID,
ARTIFICIAL;
public static final Codec<FlightType> CODEC = StringIdentifiable.createCodec(FlightType::values);
private final String name = name().toLowerCase(Locale.ROOT);
@Override
public String asString() {
return name;
}
public boolean isGrounded() {
return this == NONE;
}

View file

@ -1,20 +1,21 @@
package com.minelittlepony.unicopia;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.include.com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.common.base.Suppliers;
import com.minelittlepony.unicopia.ability.Abilities;
import com.minelittlepony.unicopia.ability.Ability;
import com.minelittlepony.unicopia.ability.magic.Affine;
import com.minelittlepony.unicopia.util.RegistryUtils;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.command.argument.RegistryKeyArgumentType;
import net.minecraft.entity.player.PlayerEntity;
@ -22,52 +23,89 @@ import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
public record Race (Supplier<Composite> compositeSupplier, Availability availability, boolean canCast, FlightType flightType, boolean canUseEarth, boolean isNocturnal, boolean canHang) implements Affine {
public record Race (
List<Ability<?>> abilities,
Affinity affinity,
Availability availability,
FlightType flightType,
boolean canCast,
boolean hasIronGut,
boolean canUseEarth,
boolean isNocturnal,
boolean canHang,
boolean isFish,
boolean canInfluenceWeather,
boolean canInteractWithClouds
) implements Affine {
public static final String DEFAULT_ID = "unicopia:unset";
public static final Registry<Race> REGISTRY = RegistryUtils.createDefaulted(Unicopia.id("race"), DEFAULT_ID);
public static final Registry<Race> COMMAND_REGISTRY = RegistryUtils.createDefaulted(Unicopia.id("race/grantable"), DEFAULT_ID);
public static final RegistryKey<? extends Registry<Race>> REGISTRY_KEY = REGISTRY.getKey();
private static final DynamicCommandExceptionType UNKNOWN_RACE_EXCEPTION = new DynamicCommandExceptionType(id -> Text.translatable("race.unknown", id));
private static final Function<Race, Composite> COMPOSITES = Util.memoize(race -> new Composite(race, null, null));
public static Race register(String name, Availability availability, boolean magic, FlightType flight, boolean earth, boolean nocturnal, boolean canHang) {
return register(Unicopia.id(name), availability, magic, flight, earth, nocturnal, canHang);
}
public static Race register(Identifier id, Availability availability, boolean magic, FlightType flight, boolean earth, boolean nocturnal, boolean canHang) {
Race race = Registry.register(REGISTRY, id, new Race(Suppliers.memoize(() -> new Composite(REGISTRY.get(id), null, null)), availability, magic, flight, earth, nocturnal, canHang));
if (availability.isGrantable()) {
Registry.register(COMMAND_REGISTRY, id, race);
}
return race;
}
public static RegistryKeyArgumentType<Race> argument() {
return RegistryKeyArgumentType.registryKey(COMMAND_REGISTRY.getKey());
}
public static final Codec<Race> CODEC = RecordCodecBuilder.create(i -> i.group(
Abilities.REGISTRY.getCodec().listOf().fieldOf("abilities").forGetter(Race::abilities),
Affinity.CODEC.fieldOf("affinity").forGetter(Race::affinity),
Availability.CODEC.fieldOf("availability").forGetter(Race::availability),
FlightType.CODEC.fieldOf("flight").forGetter(Race::flightType),
Codec.BOOL.fieldOf("magic").forGetter(Race::canCast),
Codec.BOOL.fieldOf("can_forage").forGetter(Race::hasIronGut),
Codec.BOOL.fieldOf("earth_pony_strength").forGetter(Race::canUseEarth),
Codec.BOOL.fieldOf("nocturnal").forGetter(Race::isNocturnal),
Codec.BOOL.fieldOf("hanging").forGetter(Race::canHang),
Codec.BOOL.fieldOf("aquatic").forGetter(Race::isFish),
Codec.BOOL.fieldOf("weather_magic").forGetter(Race::canInfluenceWeather),
Codec.BOOL.fieldOf("cloud_magic").forGetter(Race::canInteractWithClouds)
).apply(i, Race::new));
/**
* The default, unset race.
* This is used if there are no other races.
*/
public static final Race UNSET = register("unset", Availability.COMMANDS, false, FlightType.NONE, false, false, false);
public static final Race HUMAN = register("human", Availability.COMMANDS, false, FlightType.NONE, false, false, false);
public static final Race EARTH = register("earth", Availability.DEFAULT, false, FlightType.NONE, true, false, false);
public static final Race UNICORN = register("unicorn", Availability.DEFAULT, true, FlightType.NONE, false, false, false);
public static final Race PEGASUS = register("pegasus", Availability.DEFAULT, false, FlightType.AVIAN, false, false, false);
public static final Race BAT = register("bat", Availability.DEFAULT, false, FlightType.AVIAN, false, true, true);
public static final Race ALICORN = register("alicorn", Availability.COMMANDS, true, FlightType.AVIAN, true, false, false);
public static final Race CHANGELING = register("changeling", Availability.DEFAULT, false, FlightType.INSECTOID, false, false, true);
public static final Race KIRIN = register("kirin", Availability.DEFAULT, true, FlightType.NONE, false, false, false);
public static final Race HIPPOGRIFF = register("hippogriff", Availability.DEFAULT, false, FlightType.AVIAN, false, false, false);
public static final Race SEAPONY = register("seapony", Availability.NONE, false, FlightType.NONE, false, false, false);
public static final Race UNSET = register("unset", new Builder().availability(Availability.COMMANDS));
public static final Race HUMAN = register("human", new Builder().availability(Availability.COMMANDS));
public static final Race EARTH = register("earth", new Builder().foraging().earth()
.abilities(Abilities.HUG, Abilities.STOMP, Abilities.KICK, Abilities.GROW)
);
public static final Race UNICORN = register("unicorn", new Builder().foraging().magic()
.abilities(Abilities.TELEPORT, Abilities.GROUP_TELEPORT, Abilities.SHOOT, Abilities.DISPELL)
);
public static final Race PEGASUS = register("pegasus", new Builder().foraging().flight(FlightType.AVIAN).weatherMagic().cloudMagic()
.abilities(Abilities.TOGGLE_FLIGHT, Abilities.RAINBOOM, Abilities.CAPTURE_CLOUD, Abilities.CARRY)
);
public static final Race BAT = register("bat", new Builder().foraging().flight(FlightType.AVIAN).canHang().cloudMagic()
.abilities(Abilities.TOGGLE_FLIGHT, Abilities.CARRY, Abilities.HANG, Abilities.EEEE)
);
public static final Race ALICORN = register("alicorn", new Builder().foraging().availability(Availability.COMMANDS).flight(FlightType.AVIAN).earth().magic().weatherMagic().cloudMagic()
.abilities(
Abilities.TELEPORT, Abilities.GROUP_TELEPORT, Abilities.SHOOT, Abilities.DISPELL,
Abilities.TOGGLE_FLIGHT, Abilities.RAINBOOM, Abilities.CAPTURE_CLOUD, Abilities.CARRY,
Abilities.HUG, Abilities.STOMP, Abilities.KICK, Abilities.GROW,
Abilities.TIME
)
);
public static final Race CHANGELING = register("changeling", new Builder().foraging().affinity(Affinity.BAD).flight(FlightType.INSECTOID).canHang()
.abilities(Abilities.DISPELL, Abilities.TOGGLE_FLIGHT, Abilities.FEED, Abilities.DISGUISE, Abilities.CARRY)
);
public static final Race KIRIN = register("kirin", new Builder().foraging().magic()
.abilities(Abilities.DISPELL, Abilities.RAGE, Abilities.NIRIK_BLAST, Abilities.KIRIN_CAST)
);
public static final Race HIPPOGRIFF = register("hippogriff", new Builder().foraging().flight(FlightType.AVIAN).cloudMagic()
.abilities(Abilities.TOGGLE_FLIGHT, Abilities.SCREECH, Abilities.PECK, Abilities.DASH, Abilities.CARRY)
);
public static final Race SEAPONY = register("seapony", new Builder().foraging().fish()
.abilities(Abilities.SONAR_PULSE)
);
public static void bootstrap() {}
public Composite composite() {
return compositeSupplier.get();
return COMPOSITES.apply(this);
}
public Composite composite(@Nullable Race pseudo, @Nullable Race potential) {
@ -76,11 +114,7 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
@Override
public Affinity getAffinity() {
return this == CHANGELING ? Affinity.BAD : Affinity.NEUTRAL;
}
public boolean hasIronGut() {
return !isHuman();
return affinity;
}
public boolean isUnset() {
@ -91,12 +125,8 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
return !isHuman();
}
public boolean isFish() {
return this == SEAPONY;
}
public boolean isHuman() {
return this == UNSET || this == HUMAN;
return isUnset() || this == HUMAN;
}
public boolean isDayurnal() {
@ -107,18 +137,14 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
return !flightType().isGrounded();
}
public boolean canInteractWithClouds() {
return canFly() && this != CHANGELING;
}
public boolean canInfluenceWeather() {
return canFly() && this != CHANGELING && this != BAT && this != HIPPOGRIFF;
}
public boolean hasPersistentWeatherMagic() {
return canInfluenceWeather();
}
public boolean canUse(Ability<?> ability) {
return abilities.contains(ability);
}
public Identifier getId() {
return REGISTRY.getId(this);
}
@ -132,13 +158,11 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
}
public String getTranslationKey() {
Identifier id = getId();
return String.format("%s.race.%s", id.getNamespace(), id.getPath().toLowerCase());
return Util.createTranslationKey("race", getId());
}
public Identifier getIcon() {
Identifier id = getId();
return new Identifier(id.getNamespace(), "textures/gui/race/" + id.getPath() + ".png");
return getId().withPath(p -> "textures/gui/race/" + p + ".png");
}
public boolean isPermitted(@Nullable PlayerEntity sender) {
@ -161,16 +185,6 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
return isEquine() ? this : other;
}
@Override
public int hashCode() {
return getId().hashCode();
}
@Override
public boolean equals(Object o) {
return o instanceof Race race && Objects.equal(race.getId(), getId());
}
@Override
public String toString() {
return "Race{ " + getId().toString() + " }";
@ -195,8 +209,20 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
return def;
}
public static Race fromName(String name) {
return fromName(name, EARTH);
public static Race register(String name, Builder builder) {
return register(Unicopia.id(name), builder);
}
public static Race register(Identifier id, Builder builder) {
Race race = Registry.register(REGISTRY, id, builder.build());
if (race.availability().isGrantable()) {
Registry.register(COMMAND_REGISTRY, id, race);
}
return race;
}
public static RegistryKeyArgumentType<Race> argument() {
return RegistryKeyArgumentType.registryKey(COMMAND_REGISTRY.getKey());
}
public static Race fromArgument(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
@ -233,6 +259,10 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
return any(Race::canCast);
}
public boolean canUse(Ability<?> ability) {
return any(r -> r.canUse(ability));
}
public boolean canInteractWithClouds() {
return any(Race::canInteractWithClouds);
}
@ -252,6 +282,85 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
return physical().flightType().or(pseudo().flightType());
}
}
public static final class Builder {
private final List<Ability<?>> abilities = new ArrayList<>();
private Affinity affinity = Affinity.NEUTRAL;
private Availability availability = Availability.DEFAULT;
private boolean canCast;
private boolean hasIronGut;
private FlightType flightType = FlightType.NONE;
private boolean canUseEarth;
private boolean isNocturnal;
private boolean canHang;
private boolean isFish;
private boolean canInfluenceWeather;
private boolean canInteractWithClouds;
public Builder abilities(Ability<?>...abilities) {
this.abilities.addAll(List.of(abilities));
return this;
}
public Builder foraging() {
hasIronGut = true;
return this;
}
public Builder affinity(Affinity affinity) {
this.affinity = affinity;
return this;
}
public Builder availability(Availability availability) {
this.availability = availability;
return this;
}
public Builder flight(FlightType flight) {
flightType = flight;
return this;
}
public Builder magic() {
canCast = true;
return this;
}
public Builder earth() {
canUseEarth = true;
return this;
}
public Builder nocturnal() {
isNocturnal = true;
return this;
}
public Builder canHang() {
canHang = true;
return this;
}
public Builder fish() {
isFish = true;
return this;
}
public Builder weatherMagic() {
canInfluenceWeather = true;
return this;
}
public Builder cloudMagic() {
canInteractWithClouds = true;
return this;
}
public Race build() {
return new Race(List.copyOf(abilities), affinity, availability, flightType, canCast, hasIronGut, canUseEarth, isNocturnal, canHang, isFish, canInfluenceWeather, canInteractWithClouds);
}
}
}

View file

@ -68,7 +68,9 @@ public interface Ability<T extends Hit> {
* Checks if the given race is permitted to use this ability
* @param playerSpecies The player's species
*/
boolean canUse(Race playerSpecies);
default boolean canUse(Race race) {
return race.canUse(this);
}
/**
* Called when an ability is about to be triggered. This event occurs on both the client and server so check {@code Pony#isClient} if you need to know which one you're on.

View file

@ -1,6 +1,5 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.*;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
import com.minelittlepony.unicopia.entity.player.Pony;
@ -11,17 +10,11 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.TypedActionResult;
abstract class AbstractSpellCastingAbility implements Ability<Hit> {
@Override
public int getCooldownTime(Pony player) {
return 0;
}
@Override
public boolean canUse(Race race) {
return race.canCast() && race != Race.KIRIN;
}
@Override
public Text getName(Pony player) {
CustomisedSpellType<?> spell = player.getCharms().getEquippedSpell(player.getCharms().getHand());

View file

@ -1,7 +1,6 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.AwaitTickQueue;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
@ -16,11 +15,6 @@ import net.minecraft.world.event.GameEvent;
public class BatEeeeAbility extends ScreechAbility {
public static final int SELF_SPOOK_PROBABILITY = 20000;
@Override
public boolean canUse(Race race) {
return race == Race.BAT;
}
@Override
protected void playSounds(Pony player, Random rng, float strength) {
int count = 1 + rng.nextInt(10) + (int)(strength * 10);

View file

@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.ability;
import java.util.Optional;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Multi;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.TraceHelper;
@ -30,11 +29,6 @@ public class BatPonyHangAbility implements Ability<Multi> {
return 0;
}
@Override
public boolean canUse(Race race) {
return race == Race.BAT;
}
@Override
public Optional<Multi> prepare(Pony player) {

View file

@ -6,7 +6,6 @@ import java.util.UUID;
import java.util.stream.StreamSupport;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.Living;
import com.minelittlepony.unicopia.entity.player.Pony;
@ -37,11 +36,6 @@ public class CarryAbility implements Ability<Hit> {
return 0;
}
@Override
public boolean canUse(Race race) {
return race.canFly();
}
@Override
public Optional<Hit> prepare(Pony player) {
return Hit.INSTANCE;

View file

@ -7,7 +7,6 @@ import java.util.stream.Stream;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.magic.spell.ChangelingFeedingSpell;
@ -48,11 +47,6 @@ public class ChangelingFeedAbility implements Ability<Hit> {
return !SpellType.FEED.isOn(player) && ChangelingFeedingSpell.canFeed(player) ? 15 : 80;
}
@Override
public boolean canUse(Race race) {
return race == Race.CHANGELING;
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.ability;
import java.util.Optional;
import java.util.function.DoubleSupplier;
import java.util.function.Supplier;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.ability.data.Hit;
@ -48,11 +47,6 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
return 50;
}
@Override
public boolean canUse(Race race) {
return race.canUseEarth();
}
@Override
public Optional<Pos> prepare(Pony player) {
return TraceHelper.findBlock(player.asEntity(), 3, 1).map(Pos::new);

View file

@ -53,11 +53,6 @@ public class EarthPonyKickAbility implements Ability<Pos> {
return 50;
}
@Override
public boolean canUse(Race race) {
return race.canUseEarth();
}
@Override
public Identifier getIcon(Pony player) {
return getId().withPath(p -> "textures/gui/ability/" + p

View file

@ -62,11 +62,6 @@ public class EarthPonyStompAbility implements Ability<Hit> {
return 50;
}
@Override
public boolean canUse(Race race) {
return race.canUseEarth();
}
@Override
public Identifier getIcon(Pony player) {
Identifier id = Abilities.REGISTRY.getId(this);

View file

@ -4,7 +4,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
@ -23,11 +22,6 @@ public class FlyingDashAbility implements Ability<Hit> {
return 30;
}
@Override
public boolean canUse(Race race) {
return race == Race.HIPPOGRIFF;
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -1,6 +1,5 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
import com.minelittlepony.unicopia.entity.Living;
@ -16,12 +15,6 @@ import net.minecraft.particle.ParticleTypes;
* Ability to hug mobs. Not all of them are receptive to your advances though, so be careful!
*/
public class HugAbility extends CarryAbility {
@Override
public boolean canUse(Race race) {
return race.canUseEarth();
}
@Override
public boolean apply(Pony pony, Hit data) {
PlayerEntity player = pony.asEntity();

View file

@ -1,16 +1,10 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.particle.ParticleTypes;
public class KirinCastingAbility extends UnicornCastingAbility {
@Override
public boolean canUse(Race race) {
return race == Race.KIRIN;
}
@Override
public void coolDown(Pony player, AbilitySlot slot) {
player.spawnParticles(ParticleTypes.FLAME, 5);

View file

@ -4,7 +4,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod;
@ -30,11 +29,6 @@ public class KirinRageAbility implements Ability<Hit> {
return 60;
}
@Override
public boolean canUse(Race race) {
return race == Race.KIRIN;
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -5,7 +5,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation.Recipient;
@ -36,11 +35,6 @@ public class NirikBlastAbility implements Ability<Hit> {
return 3;
}
@Override
public boolean canUse(Race race) {
return race == Race.KIRIN;
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.ability;
import java.util.Optional;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Numeric;
@ -54,11 +53,6 @@ public class PeckAbility implements Ability<Hit> {
return true;
}
@Override
public boolean canUse(Race race) {
return race == Race.HIPPOGRIFF;
}
@Override
public Optional<Hit> prepare(Pony player) {
return Hit.INSTANCE;

View file

@ -4,7 +4,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems;
@ -33,11 +32,6 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
return 6;
}
@Override
public boolean canUse(Race race) {
return race.canInfluenceWeather();
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -4,7 +4,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
@ -26,11 +25,6 @@ public class PegasusRainboomAbility implements Ability<Hit> {
return 60;
}
@Override
public boolean canUse(Race race) {
return race.canInfluenceWeather();
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.ability;
import java.util.Optional;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.ability.data.Numeric;
@ -49,11 +48,6 @@ public class ScreechAbility implements Ability<Numeric> {
return true;
}
@Override
public boolean canUse(Race race) {
return race == Race.HIPPOGRIFF;
}
@Override
public Optional<Numeric> prepare(Pony player) {
return player.getAbilities().getActiveStat()

View file

@ -5,7 +5,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.AwaitTickQueue;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UPOIs;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.data.Hit;
@ -38,11 +37,6 @@ public class SeaponySonarPulseAbility implements Ability<Hit> {
return 100;
}
@Override
public boolean canUse(Race race) {
return race == Race.SEAPONY;
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -12,11 +12,6 @@ import com.minelittlepony.unicopia.server.world.UGameRules;
public class TimeChangeAbility implements Ability<Rot> {
@Override
public boolean canUse(Race race) {
return race == Race.ALICORN;
}
@Override
public boolean canUse(Race.Composite race) {
return canUse(race.physical()) || race.pseudo() == Race.UNICORN;

View file

@ -24,11 +24,6 @@ public class ToggleFlightAbility implements Ability<Hit> {
return 0;
}
@Override
public boolean canUse(Race race) {
return race.canFly();
}
@Nullable
@Override
public Optional<Hit> prepare(Pony player) {

View file

@ -33,11 +33,6 @@ public class UnicornDispellAbility implements Ability<Pos> {
return 0;
}
@Override
public boolean canUse(Race race) {
return race.canCast() || race == Race.CHANGELING;
}
@Override
public int getColor(Pony player) {
return SpellType.PORTAL.getColor();

View file

@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.ability;
import java.util.Optional;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Pos;
@ -60,11 +59,6 @@ public class UnicornTeleportAbility implements Ability<Pos> {
return (int)(50 - Math.min(45F, player.getLevel().get() * 0.75F));
}
@Override
public boolean canUse(Race race) {
return race.canCast() && race != Race.KIRIN;
}
@Override
public double getCostEstimate(Pony player) {
return prepare(player).map(pos -> pos.distanceTo(player) / 10).orElse(0D);